Linux – concatenate image and video using ffmpeg


I have 1 image and 1 video that I would like to concatenate
I tried to resize the image and the video to the samesize using this command:

ffmpeg -i image.jpg -vf scale=432:432 -strict -2 image_out.jpg
ffmpeg -i video.mp4 -vf scale=432:432 -strict -2 video_out.jpg

after resizing the image and video. I run the command to concatenate them:

ffmpeg -loop 1 -framerate 24 -t 10 -i image_out.jpg -i video_out.mp4 -filter_complex "[0][1]concat=n=2:v=1:a=0" out.mp4

but received error:

[Parsed_concat_0 @ 0x3850cc0] Input link in1:v0 parameters (size 432×432, SAR 4:3) do not match the corresponding output link in0:v0 parameters (432×432, SAR 1:1)
[Parsed_concat_0 @ 0x3850cc0] Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Conversion failed!

I think there is something wrong with the resizing command but I don't know how to make it works.

Best Answer


ffmpeg -loop 1 -framerate 24 -t 10 -i image.jpg -i video.mp4 -filter_complex "[0]scale=432:432,setsar=1[im];[1]scale=432:432,setsar=1[vid];[im][vid]concat=n=2:v=1:a=0" out.mp4

Video streams have a Sample Aspect Ratio. Video players resize the width during playback by multiplying the stored width by this number. The concat filter requires inputs to have the same SAR. I've added the setsar filter to keep the same SAR for both inputs.