Cowfod
Cowfod

Reputation: 41

Standardizing many mp4 files into same resolution

I have a huge collection of Instagram videos in different resolutions and with different audio codecs.

Some videos are 640x640, others are 640x800. You get the picture.

When I try to concat the videos, the video and audio go out of sync in the final output and the in some places the audio is slowed down(?).

This is my ffmpeg concat command:

ffmpeg -i "$(cat /home/list.txt)" -c:v copy -c:a copy /home/output.mp4

list.txt contains over 800 clips and is formatted correctly:

file 'clip1.mp4'
file 'clip2.mp4'
file 'clip3.mp4'
etc...

I believe the issue is due to all the different resolutions and different codecs used, so how can I standardize my collection of clips in order to concat them into a working video file?

Upvotes: 2

Views: 439

Answers (1)

Cowfod
Cowfod

Reputation: 41

After much digging, I found a solution that'll upscale videos to 1920x1080 while keeping aspect ratio and adding black bars if needed. This should work for all resolutions.

ffmpeg -i input.mp4 -vsync 2 \
-codec:v libx264 -preset fast -codec:a copy \
-vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" \
-crf 17 -pix_fmt yuv420p -movflags +faststart output.mp4

Upvotes: 2

Related Questions