Tell me more ×
Server Fault is a question and answer site for professional 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 SvW, Maxwell, MadHatter, Ward, pauska Oct 18 '12 at 11:48

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined in the FAQ. 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 closed questions here.

1 Answer

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.