Get whole duration of folders and subfolders with sound files

Solution 1:

If you have ffmpeg installed you probly have ffprobe too.

man ffprobe

for example, to ouput only the duration in format seconds you can do

ffprobe -hide_banner -v error -of default=noprint_wrappers=1:nokey=1 -show_entries stream=duration sound.mp3

If you want duration for each file you need to recurse.

find . -type f -name "*.mp3" -print0 | parallel -0 'echo "{} : `ffprobe -hide_banner -v error -of default=noprint_wrappers=1:nokey=1 -show_entries stream=duration {}`"'

ffprobe takes some time so we parallelized

You might want to sum durations to get a whole directories hierarchy duration:

find . -type f -name "*.mp3" -print0 | parallel -0 ffprobe -hide_banner -v error -of default=noprint_wrappers=1:nokey=1 -show_entries stream=duration | paste - -sd+ - | bc