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

Ralf Mardorf ralf.mardorf at alice-dsl.net
Thu Aug 18 11:19:10 UTC 2016

On Thu, 18 Aug 2016 03:50:00 +0000, Eric Wong wrote:
>And was able to reproduce soxi showing the the length as
>3:49.80 but "sox .. -n stats" showed only 44.304s


I get three times the same duration for a wav

  $ exiftool Audio_Oberheim_Matrix.wav|tail -1
  Duration                        : 0:02:18
  $ soxi Audio_Oberheim_Matrix.wav|grep D|cut -d= -f1
  Duration       : 00:02:18.19
  $ sox Audio_Oberheim_Matrix.wav -n stats 2>&1|grep Len
  Length s     138.194

and three times the same duration for a mp3.

  $ exiftool *mix?.mp3|tail -1
  Duration                        : 0:02:42 (approx)
  $ soxi *mix?.mp3|grep D|cut -d= -f1|head -1
  Duration       : 00:02:42.25
  $ sox *mix?.mp3 -n stats 2>&1|grep Len
  Length s     162.246

I didn't check with a stopwatch, to ensure the duration is correct.

  $ pacman -Q perl-image-exiftool sox
  perl-image-exiftool 10.20-1
  sox 14.4.2-1


More information about the Linux-audio-user mailing list