-
Batch conversion with conditions
I have a folder full of videos of various different formats and resolutions. I provide these videos for download from my site (they are my creation or free-use.) I’m adding a mobile section to my site where i’d like to provide these videos in a mobile-streamable format. I know the format that I want, the resolution, bitrate, and audio bitrate, so that’s not an issue. The issue is the fact that these videos are not all the same resolution to start with. Some are smaller than the resolution I want to use for my conversion, some are the same size, and some are larger, some have different aspect rations, and they’re all sorts of different formats.
I need a way to batch-convert these using ffmpeg to my specific format, but I don’t want to stretch the videos if they’re smaller than my format, I only want to shrink the ones that are larger. I still need to convert the other ones to the right format, just without resizing those specifically.
I’m using a Linux Shell on my server (shared hosting) to perform this. I’ve used this command:
for I in *.[ext]; do ffmpeg -i I -size WxH -b ##k -ab ##k converted/I.[new ext]; done
To good effect, but that’s when all the videos are of the same starting resolution. Any ideas on how I might ignore the size option for videos that are already smaller than the required size, only resizing the ones larger, but converting them all?