ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: axelrose on April 08, 2014, 08:34:30 AM

Title: rounding problem on Composite:Duration with/without -n ?
Post by: axelrose on April 08, 2014, 08:34:30 AM
Is this a rounding problem?

My default check of an audio input file gives 0:03:14

➜  ~/Downloads/Image-ExifTool-9.56/exiftool -X 1-22-dallas.wav| grep Duration
<Composite:Duration>0:03:14</Composite:Duration>


If I compare with Apple Finder or iTunes I get 0:03:15

So I checked again with -n
➜  ~/Downloads/Image-ExifTool-9.56/exiftool -n -X 1-22-dallas.wav| grep Duration
<Composite:Duration>194.907125</Composite:Duration>


The numerical value of 194.907125 is closer to the iTunes value 0:03:15

➜  perl -le 'my $rest3 = 194.907125/60-3; print "0:03:", $rest3*60'
0:03:14.907125


So is exiftool not rounding properly?


Thanks,
Axel.
Title: Re: rounding problem on Composite:Duration with/without -n ?
Post by: Phil Harvey on April 08, 2014, 08:45:01 AM
Hi Axel,

ExifTool is not rounding.  By design it is reporting the whole number of seconds (ie. truncating the fraction).  If you wish, we can debate the design decision, but I don't see a problem with this.

- Phil
Title: Re: rounding problem on Composite:Duration with/without -n ?
Post by: axelrose on April 08, 2014, 08:49:50 AM
Hi Phil,

understood.

I'd love to see this rounding as a new feature or even a change of the existing time value conversions.
Otherwise I'd need to change all my parsing done for HH:MM:SS values ...

Thanks, Axel.
Title: Re: rounding problem on Composite:Duration with/without -n ?
Post by: Phil Harvey on April 08, 2014, 08:52:11 AM
Hi Axel,

What is your requirement?  Do you require agreement with the iTunes values?  I would like to understand why the rounding is important to you.  Note that ExifTool will report the fractional seconds to 2 decimal places for durations less than 30 seconds (where fractional seconds become more significant).

- Phil
Title: Re: rounding problem on Composite:Duration with/without -n ?
Post by: axelrose on April 08, 2014, 09:01:33 AM
Yes. Agreement with the time value shown in other apps (I just think of iTunes, Apple Finder, Apple QuickLook)
is important to me since the length is prominently shown in my app and otherwise users will wonder and ask me ...

OTOH I should have used "-n" long before.

For AIFF I now just calculate "AIFF:NumSampleFrames" / "AIFF:SampleRate" myself.
For WAV, MP3 etc I rely on Composite:Duration.


Regards, Axel.
Title: Re: rounding problem on Composite:Duration with/without -n ?
Post by: Phil Harvey on April 08, 2014, 09:15:41 AM
Hi Axel,

I think that -n (or -duration#) is what you should be doing.  This is the computer-readable value you are meant to use when reading this via other software.

But I will add a Composite Duration tag for AIFF.  Thanks for mentioning this.

- Phil