Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.54k stars 1.57k forks source link

ERROR : incorrect codec parameters #1796

Open Ashokaas opened 2 years ago

Ashokaas commented 2 years ago

Hello, I am trying to merge audio and video files but I don't understand this error. Could you help me?

Code :

def fusionner_video_audio(video,audio,output, vcodec='copy',
                             acodec='copy', ffmpeg_output=False,
                             logger = 'bar'):
    """ merges video file ``video`` and audio file ``audio`` into one
        movie file ``output``. """
    cmd = [get_setting("FFMPEG_BINARY"), "-y", "-i", audio,"-i", video,
             "-vcodec", vcodec, "-acodec", acodec, output]

    call(cmd)

Error : Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM. Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

MohamedAbdultawab commented 2 years ago

Basically it's saying you are trying to merge incompatible audio and video files. As I can understand from the error message, you want the output file to be webm format, but you are providing video and audio that aren't compatible with this output format, and since you are instructing ffmpeg to copy the audio and video stream without rencoding, you mist provide compatible formats for audio and video

Ashokaas commented 2 years ago

Thank you but how can I fix this problem then? How to change the codec of a video and audio?

MohamedAbdultawab commented 2 years ago

You specify the correct codec for audio and video to match your desired output extension, for example, output.mp4 you can use vcodec as libx264 and acodec as aac. for webm you can use libvpx for vcodec and libvorbis for acodec