- Concatenation videos with different resolution. Part 1. Pad
- Concatenation videos with different resolution. Part 2. Crop
- Concatenation videos with different resolution. Part 3. Blur
Ok, another way, resize all videosresize all videos by smaller side ( by width or height ) and crop to output size. We will use ffmpeg filter ‘crop‘
The same 3 videos with resolution 640×480, 1920×1080 and vertical video 720×1280.
ffmpeg -y -loglevel warning -i 5sec_640x480.mp4 -i 5sec_1920x1080.mp4 -i 5sec_720x1280.mp4 -filter_complex " [0:v] scale=w=max(iw*480/ih\,640):h=max(480\,ih*640/iw), setsar=1, crop=w=640:h=480 [video0]; [1:v] scale=w=max(iw*480/ih\,640):h=max(480\,ih*640/iw), setsar=1, crop=w=640:h=480 [video1]; [2:v] scale=w=max(iw*480/ih\,640):h=max(480\,ih*640/iw), setsar=1, crop=w=640:h=480 [video2]; [video0][video1][video2] concat=n=3:v=1 [v]" -map "[v]" -an -c:v h264 -crf 18 -preset veryfast -f mp4 output.mp4
The same but 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] scale=w=max(iw*480/ih\,640):h=max(480\,ih*640/iw), setsar=1, crop=w=640:h=480 [video0]; [1:v] scale=w=max(iw*480/ih\,640):h=max(480\,ih*640/iw), setsar=1, crop=w=640:h=480 [video1]; [2:v] scale=w=max(iw*480/ih\,640):h=max(480\,ih*640/iw), setsar=1, crop=w=640:h=480 [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: