rounding problem on Composite:Duration with/without -n ?

Started by axelrose, April 08, 2014, 08:34:30 AM

Previous topic - Next topic

axelrose

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.

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

axelrose

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.

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

axelrose

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.

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).