Home » Questions » Computers [ Ask a new question ]

Command line app to show movie running time

Command line app to show movie running time

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:

Asked by: Guest | Views: 284
Total answers/comments: 1
Guest [Entry]

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