Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

1 Answer 1

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.