- Home
- Uncategorized
- Resizing Videos With ffmpeg or avconv
Resizing Videos With ffmpeg or avconv
In FFmpegand AvLib, filters are an invaluable tool where much of the magic happens. The scale filter is our friend when resizing videos. Let’s look at a couple of examples:
Imagine we want a 400x300px output video:
sudo ffmpeg -y -i /home/tom/sourceVid.mp4 -strict -2 -c:v libx264 -vf scale=400x300 /home/tom/myScaledVid.mp4
Note, you cannot use odd numbers of pixels for the width or the height
If you want a certain width and for the ffmpeg program to automatically calculate the height so that the aspect ratio is preserved, use width:-1:
sudo ffmpeg -y -i /home/tom/sourceVid.mp4 -strict -2 -c:v libx264 -vf scale=500:-1 /home/tom/myScaledVid.mp4
This command will resize the video to 500px in width and automatically calculate the height to stay true to the original aspect ratio