'Writes one frame in the file.'

def write_frame(self, img_array):

    try:
        if PY3:
            self.proc.stdin.write(img_array.tobytes())
        else:
            self.proc.stdin.write(img_array.tostring())
    except IOError as err:
        (_, ffmpeg_error) = self.proc.communicate()
        error = (str(err) + ('\n\nMoviePy    error:    FFMPEG    encountered    the    following    error    while    writing    file    %s:\n\n    %s' % (self.filename, str(ffmpeg_error))))
        if ('Unknown    encoder' in ffmpeg_error):
            error = (error + ("\n\nThe    video    export    failed    because    FFMPEG    didn't    find    the    specified    codec    for    video    encoding    (%s).    Please    install    this    codec    or    change    the    codec    when    calling    write_videofile.    For    instance:\n        >>>    clip.write_videofile('myvid.webm',    codec='libvpx')" % self.codec))
        elif ('incorrect    codec    parameters    ?' in ffmpeg_error):
            error = (error + ("\n\nThe    video    export    failed,    possibly    because    the    codec    specified    for    the    video    (%s)    is    not    compatible    with    the    given    extension    (%s).    Please    specify    a    valid    'codec'    argument    in    write_videofile.    This    would    be    'libx264'    or    'mpeg4'    for    mp4,    'libtheora'    for    ogv,    'libvpx    for    webm.    Another    possible    reason    is    that    the    audio    codec    was    not    compatible    with    the    video    codec.    For    instance    the    video    extensions    'ogv'    and    'webm'    only    allow    'libvorbis'    (default)    as    avideo    codec." % (self.codec, self.ext)))
        elif ('encoder    setup    failed' in ffmpeg_error):
            error = (error + '\n\nThe    video    export    failed,    possibly    because    the    bitrate    you    specified    was    too    high    or    too    low    for    the    video    codec.')
        elif ('Invalid    encoder    type' in ffmpeg_error):
            error = (error + '\n\nThe    video    export    failed    because    the    codec    or    file    extension    you    provided    is    not    a    video')
        raise IOError(error)
