- Concatenation videos with different resolution. Part 1. Pad
- Concatenation videos with different resolution. Part 2. Crop
- Concatenation videos with different resolution. Part 3. Blur
One more way – use original size of videos ( scale only if video size large, than our canvas ) but add blurred background.
ffmpeg -y -loglevel warning -i 5sec_640x480.mp4 -i 5sec_1920x1080.mp4 -i 5sec_720x1280.mp4 -filter_complex " [0:v] split=2 [video0-1][video0-2]; [1:v] split=2 [video1-1][video1-2]; [2:v] split=2 [video2-1][video2-2]; [video0-1] scale=w=1280:h=720,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1, setsar=1 [bg0]; [video1-1] scale=w=1280:h=720,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1, setsar=1 [bg1]; [video2-1] scale=w=1280:h=720,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1, setsar=1 [bg2]; [video0-2] scale=w=min( iw\, min(iw*720/ih\,1280)):h=min( ih\, min(720\,ih*1280/iw)), setsar=1 [video0-2-scaled]; [video1-2] scale=w=min( iw\, min(iw*720/ih\,1280)):h=min( ih\, min(720\,ih*1280/iw)), setsar=1 [video1-2-scaled]; [video2-2] scale=w=min( iw\, min(iw*720/ih\,1280)):h=min( ih\, min(720\,ih*1280/iw)), setsar=1 [video2-2-scaled]; [bg0][video0-2-scaled] overlay=x=(W-w)/2:y=(H-h)/2 [video0]; [bg1][video1-2-scaled] overlay=x=(W-w)/2:y=(H-h)/2 [video1]; [bg2][video2-2-scaled] overlay=x=(W-w)/2:y=(H-h)/2 [video2]; [video0][video1][video2] concat=n=3:v=1[v]" -map "[v]" -an -c:v h264 -crf 18 -preset veryfast -f mp4 output.mp4
or version with concatenation audio streams too
ffmpeg -y -loglevel warning -i 5sec_640x480.mp4 -i 5sec_1920x1080.mp4 -i 5sec_720x1280.mp4 -filter_complex " [0:v] split=2 [video0-1][video0-2]; [1:v] split=2 [video1-1][video1-2]; [2:v] split=2 [video2-1][video2-2]; [video0-1] scale=w=1280:h=720,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1, setsar=1 [bg0]; [video1-1] scale=w=1280:h=720,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1, setsar=1 [bg1]; [video2-1] scale=w=1280:h=720,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1, setsar=1 [bg2]; [video0-2] scale=w=min( iw\, min(iw*720/ih\,1280)):h=min( ih\, min(720\,ih*1280/iw)), setsar=1 [video0-2-scaled]; [video1-2] scale=w=min( iw\, min(iw*720/ih\,1280)):h=min( ih\, min(720\,ih*1280/iw)), setsar=1 [video1-2-scaled]; [video2-2] scale=w=min( iw\, min(iw*720/ih\,1280)):h=min( ih\, min(720\,ih*1280/iw)), setsar=1 [video2-2-scaled]; [bg0][video0-2-scaled] overlay=x=(W-w)/2:y=(H-h)/2 [video0]; [bg1][video1-2-scaled] overlay=x=(W-w)/2:y=(H-h)/2 [video1]; [bg2][video2-2-scaled] overlay=x=(W-w)/2:y=(H-h)/2 [video2]; [0:a] anull [audio0]; [1:a] anull [audio1]; [2:a] anull [audio2]; [video0][audio0][video1][audio1][video2][audio2] concat=n=3:v=1:a=1 [v][a] " -map "[v]" -map "[a]" -c:a aac -c:v h264 -crf 18 -preset veryfast -f mp4 output.mp4
Result:
Hi.
Thank you for sharing. The version without audio works fine. But i keep getting “Error while filtering” when using the aac and the libvo_aacenc codec. Any tips on solving that?
Thanks in advance.
Dennis