ffmpeg downscale all videos in a directory

February 11, 2018

Prerequisites

This article assumes that you've already installed ffmpeg.

Description

If you want to downscale your videos for sharing, this little one liner is a nice way to do so.

# Look through all files in the current directory
for file in ./*;
do
  ffmpeg -i "$file" -filter:v scale=960:-1 -c:a copy "$file.mp4";
done

You'll need to make sure that the first number for the scale ratio is a number that's the source video dimensions are divisible by. So for example the source video files were 1920 x 1080, 960 is half of 1920.

If you aren't sure what the dimensions of your videos are, you can also use this one liner for json output.

ffprobe -v quiet -print_format json -show_format -show_streams ~/your/path/yourvideo.format

References


© 2023, Built with ❤️ by Blake Dietz