Wednesday, December 25, 2019

Bash batch. Converting .avi to .mp4 for import to Davinci Resolve

Bash makes things so easy for doing batch operations on a bunch of files.  I have a bunch of .AVI files from my old camera that Davinci Resolve won't handle.  ffmpeg converts well enough to .mp4 for import.  Since I have a bunch of clips, conversion is just a bunch of command lines:


$ for filename in *.AVI; do filepart=${filename%%.AVI}; if [ ! -e ${filepart}.mp4 ] ; then echo ffmpeg -i ${filepart}.avi ${filepart}.mp4; fi;  done | sh -x
 Formatting and readability is a bit fugly on the command line but this does it nicely.  As a bonus it sees if things are converted already and don't do a conversion.