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

From: Dan Hitt <dan.hitt@email-addr-hidden>
Date: Fri Aug 19 2016 - 06:58:31 EEST

Thanks Paul, Eric, and Ralf,

Eric --- your command certainly works on my problematic sound file, thanks!

Paul --- thanks for pointing out sndfile-info. This also works, and
puts the results on stdout. (Presumably sox wants to write to stderr
to because it wants to reserve stdout for samples?)

Ralf --- thanks for pointing out exiftool. I had no idea it dealt
with sound files. Now, in my particular case, it didn't work because
my sound file is au/snd, and it doesn't know that format, so it
interpreted it as a (huge) jpeg. I think the reason that soxi can be
correct for some formats but not others is that the flow of control
goes through different paths depending on the file type, and some of
the handlers may be more capable than others (or at least have
different weak spots). Thus a problem showed up with Eric's flac and
my au/snd, but not your wav. (Pure conjecture here!)

Thanks again everybody for educating me!!

dan

On Thu, Aug 18, 2016 at 5:13 AM, Paul Davis <paul@email-addr-hidden> wrote:
> sndfile_info checks both the header and the file contents.
>
> On Wed, Aug 17, 2016 at 11:50 PM, Eric Wong <e@email-addr-hidden> wrote:
>>
>> Dan Hitt <dan.hitt@email-addr-hidden> 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
>> _______________________________________________
>> Linux-audio-user mailing list
>> Linux-audio-user@email-addr-hidden
>> http://lists.linuxaudio.org/listinfo/linux-audio-user
>
>
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-user
Received on Fri Aug 19 08:15:01 2016

This archive was generated by hypermail 2.1.8 : Fri Aug 19 2016 - 08:15:01 EEST