Server Fault is a question and answer site for system and network administrators. 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

How to get video duration from shell!? I have a directory with too many videos file.
I want to print duration of total of the file in directory.

share|improve this question

closed as off topic by Sven, Maxwell, MadHatter, Ward, pauska Oct 18 '12 at 11:48

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

I dont think there is a command that can do what you want directly. You can try installing ffmpeg, and with it you get ffprobe.

If you run:

ffprobe videofile.avi

you get all the data about it (including the duration). Since it's based on ffmpeg, it supports more-or-less all the popular codecs.

With this, you can write a script to parse and sum up all the durations.

ps: for some unknown reason, my version of ffmpeg outputs data to STDERR instead of STDOUT. Dont know if it's a bug or a feature.

share|improve this answer

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