Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question

migrated from Dec 11 '09 at 15:17

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

up vote 3 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 -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
share|improve this answer

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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .