Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

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 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:

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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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