Determine video length summary of multiple files on UNIX console

Raw duration to duration conversionSometimes a clients wants to buy the raw video footage from me. So I have to determine the the length of all files. Fortunately, working on a Mac OS X based computer you have the power of the UNIX shell. So just use the following shell command-line (if you’ve got ffmpeg installed with MacPorts):

find . -type f -name "*.MOV" -print0 | xargs -0 -I file ffmpeg -i file 2>&1 | grep Duration | awk '{print $2}' | tr -d ,

The orange marked „.“ diretly after the find command and the „*.MOV“ have to be adjusted to your needs. For example, if you’ve got sub-directories containing the movie files, you go to the folder atop of those sub-directories, just leave the dot – it stands for the current directory. The file extension .MOV could be easily replaced by every other video file extension you need (and ffmpeg is able to read).

This outputs the duration of each found video in a new line. You just can copy it to an empty Apple Numbers spreadsheet, change the cell data type to duration and then create the sum of all durations. That’s it.

Of course you’d could write an Automator script – but this one is quick 😉

Einen Kommentar hinterlassen

Ihre E-Mail wird niemals veröffentlicht oder weitergegeben. Erforderliche Felder sind mit * markiert

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>