0

I've seen this kind of thing before, but cannot find anything now that I need it. I just want it to be able to recurse a given directory structure and return the total play time of all the video files.

1 Answer 1

1

This should give you the total time in seconds of all files of the given type in your current working directory:

find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration {} \; | paste -sd+ -| bc

To do it recursively in a folder that has several subfolders, AND to include media files with varying extensions (.mp4, .avi, .mkv, etc.) you would just remove the '-maxdepth' and '-iname' arguments, so the command would be.

find . -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration {} \; | paste -sd+ -| bc

ffprobe is a part of ffmpeg, so whatever media you are using has to be supported by ffmpeg.

Source of original command: https://unix.stackexchange.com/questions/170961/get-total-duration-of-video-files-in-a-directory

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .