What command line applications can I use on OS X to get the movie running time? I would like to be able to do something like this:

$ running_time matrix.avi
136 min
link|improve this question
feedback

migrated from stackoverflow.com Dec 11 '09 at 15:17

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 2 down vote accepted

Most commandline encoding tools can provide this information. Tack on some shell scripting to trim the output to just the line including duration.

Tack on some more to process that line into your desired "xxx min" output. Exactly what you need for that depends on which tool you'd be using. (See the mplayer example for a suggestion.) Once you've got that, you can create a shell script or alias to run that command with running_time.

FFMpeg:

ffmpeg -i foo.avi
ffmpeg -i foo.avi 2>&1 | grep Duration

Mplayer/Mencoder (ID_LENGTH is in seconds):

mplayer -vo null -ao null -identify -frames 0 foo.avi
mplayer -vo null -ao null -identify -frames 0 foo.avi | grep ID_LENGTH

# ugly, but outputs "xx mins"
mplayer -identify -ao null -vo null -frames 0 foo.avi | grep ^ID_LENGTH= | cut -d = -f 2 | perl -lne 'print sprintf("%d mins", $_/60)'

Transcode (with tcprobe tool):

tcprobe -i foo.avi
tcprobe -i foo.avi | grep duration
link|improve this answer
feedback

You might want to have a look at the following tools:

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.