How Long Is This MP4?
We have made over 50 videos for Software Carpentry so far, and as part of reorganizing the site, we want to list their lengths beside their names. If they were text files, I’d use wc(1)
to find their size–but what do I do for MP4 files? After a few false starts [1] I found ffmpeg’s ffplay, and the following command:
ffplay -an -vn -stats ${filename} 2>&1 | grep Duration | sed -e 's/,.*//' -e 's/ *Duration: *//'
It isn’t pretty–my screen flickers uncomfortably as ffplay launches and closes down for each file–but it works.
[1] My first stop was Pyglet, but after installing from their DMG download on Mac OS X 10.6, every attempt to do anything more than import pyglet
results in a QuickTime error.