The following works very nicely to determine the length of various audio/video files:
mplayer -identify file.ogg 2>/dev/null | grep ID_LENGTH
However, I want to kill mplayer's output so I can determine the length of many files more efficiently. How do I do that?
FFMPEG can give you the same information in a different format (and doesn't attempt playing the file):
The
MPlayer
source ships with a sample script calledmidentify
, which looks like this:The
-frames 0
makesmplayer
exit immediately, and the-vo null -ao null
prevent it from trying to open any video or audio devices. These options are all documented inman mplayer
.There's another FF-way in addition to @codelogic's method, which doesn't exit with an error:
and look for the duration entry.
Or grep for it directly in the error stream:
looks like there are a few other libs available, see time length of an mp3 file