With Chris Roddy’s help, I just figured out a pretty slick way to quickly get the duration of a bunch of video files.
ffmpeg includes duration information in the preliminary output when it is processing a file (or even when it is complaining that you haven’t given it an output file). So you can run ffmpeg and grep for the “Duration” string.
In a bash shell, you can just do this:
|If you use csh, instead of bash, here’s how to do the equivalent output redirect. Where bash uses 2>&1||, [t]csh uses||& to redirect stderr and stdout to the next command. The equivalent of the bash for loop in csh is a foreach that looks something like this:|
(As far as I know, there is no way to do single-line for statements in tcsh.)
If your videos aren’t all in the current directory and you want to find them in subdirectories, you could use the find command in instead of *.mp4, e.g.: