cvrt: FFMPEG, made slightly easier

[linkstandalone]

If you've been using Linux for a few days now, you're probably already aware of the swiss-army knife of media conversion and compression: FFMPEG. It's often pre-installed on most Linux distros, and it offers a simple command-line way of converting between all (most) media formats.

However, despite its compatibility and ubiquity, I've always felt FFMPEG doesn't do enough to handle repetitive, batch-like conversions using regular expressions. For example: imagine you had a file full of mp4 files, and you wanted to convert each of them to mov. With cvrt, you can run the following command:

cvrt *.mp4 mov

All this script does is take two arguments: the input files (*.mp4), and the last argument passed, which is the output format/file (mov). Another useful feature of cvrt is the fact you can specify cases for outputs. For example: if I wanted each mov file to be in a specific audio and video codec (ie. for DaVinci Resolve), then you can specify it in the script:

# Exception options for specific formats
case "$ext" in
*flac) OPT=$OPT:" -vn" ;;
*mov) OPT=$OPT:" -c:v mpeg4 -q:v 0 -pix_fmt yuv420p -c:a pcm_s16le" ;;
*mp4) OPT=$OPT:" -c:v libx264 -crf 21 -c:a libopus -b:a 320k" ;;
esac

In this case, there are cases for flac, mov and mp4 output files, to ensure the resulting files always come out with specific codecs, using FFMPEG flags.

Download cvrt from my dotfiles.

*the script is still a WIP, not every bug has been fixed yet. If you have any suggestions, feel free to contact me or open an issue on GitLab!