I need to check the duration of a group of audio files. Is there a simple way to do this on the unix command-line?
> duration *
I have the a
ffprobe your_file.mp3 2>&1 | grep "Duration"
The output looks like this:
Duration: 00:44:33.50, start: 0.011995, bitrate: 128 kb/
sox --info -D file --> duration in seconds
sox --info -d file --> duration in HH:mm:ss.ss
sox --info file --> metadata
ffmpeg -i <audiofile> 2>&1 | grep Duration
Another soxi based answer including the file names and duration in hours, minutes and seconds format.
$for f in *amr; do printf "$f "; soxi -d $f; done
DGT20161216.amr 00:22:04.62
DGT20170108.amr 00:28:22.80
DGT20170117.amr 00:20:05.18
If you are interested in finding total duration of wav files in a directory using soxi you can use this:
soxi -D input_dir/*.wav | python -c "import sys;print(sum(float(l) for l in sys.stdin))
change input_dir
according to your input directory.
If you want to find max/min duration between all wav files feel free to change sum
to max
or min
.
on OSX
Print the length of each audio file in the current dir:
afinfo * | awk '/estimated duration/ { print $3 }'
Include the filepath:
afinfo * | awk '/File:/ { song=$2 } /estimated duration/ { print song, $3 }'