Search code examples
ffmpeg

FFMPEG MOV to MP4 error {Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument}


I'm using FFMPEG to convert and watermark videos

ffmpeg -i "MVI_9692.MOV"   -i 360.png  -acodec copy -threads 12  -filter_complex "scale=-2:360,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2"  "MVI_9692.MOV_360.mp4"

this command is working OK with diffrent format videos but I got this error message for one of the MOV videos

Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

and these are the warnings I got before the error message:

[swscaler @ 0x47adf20] deprecated pixel format used, make sure you did set range correctly

[mp4 @ 0x4729540] Codec for stream 1 does not use global headers but container format requires global headers
[mp4 @ 0x4729540] Could not find tag for codec pcm_s16le in stream #1, codec not currently supported in container

Solution

  • FFmpeg does not mux PCM audio in MP4 files, so you'll have to convert using a supported codec like AAC, MP3, AC3..etc.

    For AAC encoding, use -c:a aac

    e.g.

    ffmpeg -i "MVI_9692.MOV" -i 360.png -threads 12 -c:a aac 
           -filter_complex "scale=-2:360,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2"
           "MVI_9692.MOV_360.mp4"