0

I currently have two videos, word.mp4 and word.matte.mp4. I'm trying to alphamerge these two videos with an image.jpg overlay.

The command I'm trying to use, which I tweaked from this question, is giving me an error

ffmpeg -i word.mp4 -i word.matte.mp4 -i image.jpg -filter_complex '[1][0]scale2ref[mask][main];[main][mask]alphamerge[vid];[2:v][vid]overlay=(W-w)/2:(H-h)/2[out]' -map [out] complete.mp4

but I get this error

Stream mapping:
  Stream #0:0 (hevc) -> scale2ref:ref
  Stream #1:0 (mpeg4) -> scale2ref:default
  Stream #2:0 (mjpeg) -> overlay:main
  overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x560faabe37c0] width not divisible by 2 (983x1115)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

Any help would be appreciated

1 Answer 1

1

Both width and height of the final output need to be even for widely-compatible playback. In this case, those dimensions are the same as the JPEG input.

The quickest way is to resize the JPEG.

ffmpeg -i image.jpeg -vf "scale=bitand(iw+1,65534):bitand(ih+1,65534)" -q:v 2 new.jpg
2
  • is there any way to auto scale the jpeg? As I'm unsure what the size of the videoes are going to be
    – nadermx
    Commented May 19, 2021 at 0:18
  • 1
    ffmpeg -i image.jpeg -i word.mp4 -filter_complex "scale2ref[img][vid];[img]setsar=1;[vid]nullsink" -q:v 2 new.jpg
    – Gyan
    Commented May 19, 2021 at 4:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .