decodeAudioData results in significantly different buffer lengths for identical-length input .ogg files
Reported by
vince.ru...@gmail.com,
Sep 16
|
|||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36 Steps to reproduce the problem: Run the attached test case, examine the input .ogg files, and observe the console output. OR Start with multiple .ogg that are exactly the same duration (down to the sample) but are different file sizes due to different content/compression ratios. Use decodeAudioData to decode the audio files to a buffer. Observe that the resulting buffer lengths are significantly different from each other. What is the expected behavior? In the attached test case, all 3 input .ogg files are exactly 264600 samples long at 44.1 kHz. The resulting buffer lengths should all be identical, either 264600 or 288000 (when resampled from 44.1 to 48 kHz). The same test case works as expected in Firefox latest. What went wrong? - Did this work before? N/A Does this work in other browsers? N/A Chrome version: 69.0.3497.92 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version:
,
Sep 16
Notes: - .wav, .flac, .m4a/.aac files do not exhibit this problem, and are decoded correctly - .ogg seems to be the only affected format - Ignore the correlation.png file in the attached test case. After testing on more files, there doesn't seem to be a correlation between the file size and the error in decoded buffer length.
,
Sep 18
I see that the files all have different lengths (Linux, Chromium ToT today): metronome: 265536 (6.0212 sec) clave: 264896 (6.0067 sec) drum: 264768 (6.0038 sec) WebAudio decodes the entire file, without using the estimated duration. I see from avprobe each of the files is 6.00 sec long (264600 frames at 44.1 kHz). +chcunningham who works with chrome's ffmpeg (I think)
,
Sep 18
Eh, we clamp based on duration for aac, but I'd be wary of doing that for ogg too since I generally feel that format isn't as precise -- though that may be a reason _to_ clamp actually.
,
Sep 18
I'm not sure what you mean by ogg being less precise. Unlike mp3, ogg (vorbis) was designed to be capable of sample-perfect looping. So being able to reconstruct the file exactly is possible and necessary. Any other commercial software that supports loading of oggs (audacity, wavosaur, ocen, protools) will and does (I just tested) show the test files having exactly 264600 samples.
,
Sep 18
!!! Somewhat good news. I just tested the conversion with ffmpeg itself, and it also decodes the files incorrectly, with the same sample lengths as listed by "rtoy" above. So the source of the bug is in ffmpeg. I'll file this issue through the appropriate channels at ffmpeg.
,
Sep 18
I don't disagree that's the intention. In this case ffmpeg's decoder is spitting out more samples. Why that's the case, I don't know. It seems like a bug worth reporting to them upstream. Even relying on the tagged packet duration appears to be insufficient in this case. We could clamp to the reported file duration 6s, but I'd worry this breaks more files than it helps.
,
Sep 18
decodeAudioData used to trust the reported file duration but in many cases, the duration was sometimes shorter (sometimes very, very much shorter) than the actual duration and we would end up not decoding the rest of the file. And for aac files, there were cases where the estimated duration of a very short file would be so short that the pre-roll frames were all that were included because we couldn't remove the pre-roll frames ahead of time. (No metadata indicating if the pre-roll were included or not.) So we switched to decoding everything in the file, ignoring the duration.
,
Sep 18
Oh, and I vaguely remember cases where the estimated duration was huge (more than 4GB) and we would fail to decode the file, even though the actual data was pretty small. (This might have been an Android problem, before we switched to using ffmpeg on Android.)
,
Sep 19
Marking as ExternalDependency since ffmpeg also produces different lengths.
,
Sep 19
Link to bug report in ffmpeg for anyone who wishes to follow the resolution of this issue: https://trac.ffmpeg.org/ticket/7447
,
Sep 19
Apologies. Apparently this is a duplicate issue in both Chromium and FFmpeg (even though I did do a quite thorough search and couldn't find them): https://trac.ffmpeg.org/ticket/6367 https://bugs.chromium.org/p/chromium/issues/detail?id=456252 |
|||
►
Sign in to add a comment |
|||
Comment 1 by susan.boorgula@chromium.org
, Sep 16