MediaInfoLib icon indicating copy to clipboard operation
MediaInfoLib copied to clipboard

Incorrect sample count and duration for audio

Open 0xf0f opened this issue 6 years ago • 10 comments

The reported sample count (and by extension duration) of audio tracks seems to be incorrect. I've tried this with several different files of varying formats so far. (FLAC, WAV, AIF, MP3). See sbraz/pymediainfo#70 for test code and output.

0xf0f avatar May 16 '19 23:05 0xf0f

Looks like rounding issues in the way it is computed. Definitely something we should fix at some point, but don't expect a quick fix, at least on free support.

JeromeMartinez avatar May 17 '19 10:05 JeromeMartinez

This seems to be a regression: https://github.com/DvdKhl/AVDump3/issues/50 Version 18.20 seem to report correct values. In my case only avi files are so far affected and cannot be explained by rounding errors.

DvdKhl avatar Sep 03 '20 16:09 DvdKhl

Actually I forgot this issue ticket but was just working on it (https://github.com/MediaArea/MediaInfoLib/pull/1289), would it be better with latest snapshots?

JeromeMartinez avatar Sep 03 '20 16:09 JeromeMartinez

I was working on WAV, wondering about the other formats, but I'll check with AVI and others when I have some free time.

JeromeMartinez avatar Sep 03 '20 16:09 JeromeMartinez

And it looks like the last version where it worked was not 18.20 as I said earlier but 0.7.42. We'll try one of the snapshots and then report back if it is already fixed.

DvdKhl avatar Sep 03 '20 16:09 DvdKhl

I've got 3 files here showing this weird behaviour. Checking some old MIL versions I have lying around:

MIL 0.7.42:

  <Audio>
    <Count>157</Count>
    <StreamCount>1</StreamCount>
    <StreamKind>Audio</StreamKind>
    <StreamKindID>0</StreamKindID>
    <ID>1</ID>
    <Format>WMA</Format>
    <Format_Commercial>WMA</Format_Commercial>
    <Format_Version>Version 2</Format_Version>
    <CodecID>161</CodecID>
    <CodecID-Info>Windows Media Audio</CodecID-Info>
    <CodecID-Url>http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx</CodecID-Url>
    <Codec>161</Codec>
    <Codec-Info>Windows Media Audio 2</Codec-Info>
    <Codec-Url>http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx</Codec-Url>
    <Codec-CC>161</Codec-CC>
    <Duration Unit="ms">5028307</Duration>
    <BitRate Unit="bps">9992</BitRate>
    <Channels Unit="channel">1</Channels>
    <SamplingRate Unit="Hz">11025</SamplingRate>
    <SamplingCount>55437085</SamplingCount>
    <Resolution Unit="bit">16</Resolution>
    <BitDepth Unit="bit">16</BitDepth>
    <StreamSize Unit="byte">6280356</StreamSize>
    <StreamSize_Proportion>0.03342</StreamSize_Proportion>
    <Interleave_VideoFrames>4.19</Interleave_VideoFrames>
    <Interleave_Duration>139</Interleave_Duration>
    <Interleave_Preload>696</Interleave_Preload>
  </Audio>

MIL 0.7.90:

  <Audio>
    <Count>272</Count>
    <StreamCount>1</StreamCount>
    <StreamKind>Audio</StreamKind>
    <StreamKindID>0</StreamKindID>
    <ID>1</ID>
    <Format>WMA</Format>
    <Format_Commercial>WMA</Format_Commercial>
    <Format_Version>Version 2</Format_Version>
    <CodecID>161</CodecID>
    <CodecID-Info>Windows Media Audio</CodecID-Info>
    <CodecID-Url>http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx</CodecID-Url>
    <Codec>161</Codec>
    <Codec-Info>Windows Media Audio 2</Codec-Info>
    <Codec-Url>http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx</Codec-Url>
    <Codec-CC>161</Codec-CC>
    <Duration Unit="ms">17646</Duration>
    <Source_Duration Unit="ms">5028307</Source_Duration>
    <BitRate Unit="bps">9992</BitRate>
    <Channels Unit="channel">1</Channels>
    <SamplingRate Unit="Hz">11025</SamplingRate>
    <SamplingCount>194547</SamplingCount>
    <Resolution Unit="bit">16</Resolution>
    <BitDepth Unit="bit">16</BitDepth>
    <StreamSize Unit="byte">6280356</StreamSize>
    <StreamSize_Proportion>0.03342</StreamSize_Proportion>
    <Interleave_VideoFrames>4.19</Interleave_VideoFrames>
    <Interleave_Duration>139</Interleave_Duration>
    <Interleave_Preload>696</Interleave_Preload>
  </Audio>

MIL 0.7.99:

  <Audio>
    <Count>275</Count>
    <StreamCount>1</StreamCount>
    <StreamKind>Audio</StreamKind>
    <StreamKindID>0</StreamKindID>
    <ID>1</ID>
    <Format>WMA</Format>
    <Format_Commercial>WMA</Format_Commercial>
    <Format_Version>Version 2</Format_Version>
    <CodecID>161</CodecID>
    <CodecID-Info>Windows Media Audio</CodecID-Info>
    <CodecID-Url>http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx</CodecID-Url>
    <Codec>161</Codec>
    <Codec-Info>Windows Media Audio 2</Codec-Info>
    <Codec-Url>http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx</Codec-Url>
    <Codec-CC>161</Codec-CC>
    <Duration Unit="ms">17646</Duration>
    <Source_Duration Unit="ms">5028307</Source_Duration>
    <BitRate Unit="bps">9992</BitRate>
    <Channels Unit="channel">1</Channels>
    <SamplingRate Unit="Hz">11025</SamplingRate>
    <SamplingCount>194547</SamplingCount>
    <Resolution Unit="bit">16</Resolution>
    <BitDepth Unit="bit">16</BitDepth>
    <StreamSize Unit="byte">6280356</StreamSize>
    <StreamSize_Proportion>0.03342</StreamSize_Proportion>
    <Interleave_VideoFrames>4.19</Interleave_VideoFrames>
    <Interleave_Duration>139</Interleave_Duration>
    <Interleave_Preload>696</Interleave_Preload>
  </Audio>

MIL 18.12:

  <Audio>
    <Count>277</Count>
    <StreamCount>1</StreamCount>
    <StreamKind>Audio</StreamKind>
    <StreamKindID>0</StreamKindID>
    <ID>1</ID>
    <Format>WMA</Format>
    <Format_Commercial>WMA</Format_Commercial>
    <Format_Version>Version 2</Format_Version>
    <CodecID>161</CodecID>
    <CodecID-Info>Windows Media Audio</CodecID-Info>
    <CodecID-Url>http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx</CodecID-Url>
    <Duration Unit="ms">17646</Duration>
    <Source_Duration Unit="ms">5028307</Source_Duration>
    <BitRate Unit="bps">9992</BitRate>
    <Channels Unit="channel">1</Channels>
    <SamplingRate Unit="Hz">11025</SamplingRate>
    <SamplingCount>194547</SamplingCount>
    <BitDepth Unit="bit">16</BitDepth>
    <StreamSize Unit="byte">6280356</StreamSize>
    <StreamSize_Proportion>0.03342</StreamSize_Proportion>
    <Interleave_VideoFrames>4.19</Interleave_VideoFrames>
    <Interleave_Duration Unit="ms">139</Interleave_Duration>
    <Interleave_Preload Unit="ms">696</Interleave_Preload>
  </Audio>

MIL 20.08:

  <Audio>
    <Count Unit="">280</Count>
    <StreamCount Unit="">1</StreamCount>
    <StreamKind Unit="">Audio</StreamKind>
    <StreamKindID Unit="">0</StreamKindID>
    <ID Unit="">1</ID>
    <Format Unit="">WMA</Format>
    <Format_Commercial Unit="">WMA</Format_Commercial>
    <Format_Version Unit="">Version 2</Format_Version>
    <CodecID Unit="">161</CodecID>
    <CodecID-Info Unit="">Windows Media Audio</CodecID-Info>
    <CodecID-Url Unit="">http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx</CodecID-Url>
    <Duration Unit="ms">17646</Duration>
    <Source_Duration Unit="ms">5028307</Source_Duration>
    <BitRate Unit="bps">9992</BitRate>
    <Channels Unit="channel">1</Channels>
    <SamplingRate Unit="Hz">11025</SamplingRate>
    <SamplingCount Unit="">194547</SamplingCount>
    <BitDepth Unit="bit">16</BitDepth>
    <StreamSize Unit="byte">6280356</StreamSize>
    <StreamSize_Proportion Unit="">0.03342</StreamSize_Proportion>
    <Interleave_VideoFrames Unit="">4.19</Interleave_VideoFrames>
    <Interleave_Duration Unit="ms">139</Interleave_Duration>
    <Interleave_Preload Unit="ms">696</Interleave_Preload>
  </Audio>

kheldorn avatar Sep 03 '20 16:09 kheldorn

So somewhere between 0.7.42 and 0.7.90 the regression was introduced ... the correct duration was moved to a newly introduced <Source_Duration/> node and the original <Duration/> node now carries ... whatever duration that might be.

kheldorn avatar Sep 03 '20 16:09 kheldorn

Just checked with 20.08.20200828. Same result.

<track type="Audio">
  <ID>1</ID>
  <Format>WMA</Format>
  <Format_Version>2</Format_Version>
  <CodecID>161</CodecID>
  <Duration>17.646</Duration>
  <Source_Duration>5028.307</Source_Duration>
  <BitRate>9992</BitRate>
  <Channels>1</Channels>
  <SamplingRate>11025</SamplingRate>
  <SamplingCount>194547</SamplingCount>
  <BitDepth>16</BitDepth>
  <StreamSize>6280356</StreamSize>
  <StreamSize_Proportion>0.03342</StreamSize_Proportion>
  <Interleave_VideoFrames>4.19</Interleave_VideoFrames>
  <Interleave_Duration>0.139</Interleave_Duration>
  <Interleave_Preload>0.696</Interleave_Preload>
</track>

If you want one (or all three) of the files I got here, let me know.

kheldorn avatar Sep 03 '20 16:09 kheldorn

the correct duration was moved to a newly introduced <Source_Duration/> node and the original node now carries ... whatever duration that might be.

This is another issue not related to a rounding issue, more an issue about potential mismatch between container and raw stream (we aim to detect container related duration, sometimes the container indicates to play only a portion of the file). Please open a specific ticket with a sample file (could be private sending if the file is copyrighted).

JeromeMartinez avatar Sep 03 '20 16:09 JeromeMartinez

Well, the detected sampling count changed between 0.7.42 and 0.7.90 for these files too.

kheldorn avatar Sep 03 '20 16:09 kheldorn