[LAU] robust command line tool to determine duration of sound file using more than the header

Eric Wong e at 80x24.org
Thu Aug 18 03:50:00 UTC 2016


Dan Hitt <dan.hitt at gmail.com> wrote:
> I'm looking for a command line tool that can determine the length
> (duration in seconds) of a sound file using more than just the file
> header.

Try: sox $FILE -n stats 2>&1 | awk '/^Length / {print $2}'

That will decode the entire file and run it through the
sox "stats" effect.

I just tried it on a 28MB FLAC file (3:49.80s) truncated to 5MB
with:

	dd if=$ORIG of=truncated.flac bs=5M count=1

And was able to reproduce soxi showing the the length as
3:49.80 but "sox .. -n stats" showed only 44.304s


More information about the Linux-audio-user mailing list