Closed Bug 1166760 Opened 11 years ago Closed 10 years ago

[Aries] Videos on Facebook play back with extremely slow audio

Categories

(Firefox OS Graveyard :: AudioChannel, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:2.5+, firefox39 wontfix, firefox40 wontfix, firefox41 fixed, b2g-master verified)

VERIFIED FIXED
2.2 S14 (12june)
blocking-b2g 2.5+
Tracking Status
firefox39 --- wontfix
firefox40 --- wontfix
firefox41 --- fixed
b2g-master --- verified

People

(Reporter: cwiiis, Assigned: mchiang)

References

Details

(Whiteboard: [spark])

Attachments

(2 files, 1 obsolete file)

STR: Prerequisite: Aries device (tested on a Sony Xperia Z3C) with Facebook installed, logged in and a news feed with video links in it. 1. Locate a video on the Facebook news feed and tap it to watch it Expected: Video opens in new window and plays back normally. Actual: Video opens in new window and plays, but audio is very slow and pitched down (like slowed down 2-4x). When the video ends, the audio will continue playing and the time indicator starts to increment beyond the end of the video. This does not happen on a Flame or ZTE Open C last time I tried. YouTube videos play back fine, this seems specific to whatever format Facebook uses.
[Blocking Requested - why for this release]:
blocking-b2g: --- → spark?
Whiteboard: [spark]
Can you take a look at this please? It seems like it might be gonk related to the aries build.
blocking-b2g: spark? → spark+
Flags: needinfo?(kli)
I can't reproduce this on aries-l. But it is reproduced on aries-kk.
Flags: needinfo?(kli)
Bwu, With aries-kk, Video on youtube can be played correctly but playing video on facebook will get this audio issue. Do you have any suggestion?
Flags: needinfo?(bwu)
Alexandre, I am not sure if any library is missing in aries-kk. Do you get an idea?
Flags: needinfo?(lissyx+mozillians)
No. And this bug is totally useless without any build informations.
Flags: needinfo?(lissyx+mozillians)
(In reply to Kai-Zhen Li [:kli][:seinlin] from comment #4) > Bwu, With aries-kk, Video on youtube can be played correctly but playing > video on facebook will get this audio issue. Do you have any suggestion? Munro, May I have your help to check it? Thanks!
Flags: needinfo?(bwu) → needinfo?(mchiang)
This should be related to bug 1167500. GonkAudioDecoderManager got the wrong sample rate.
Flags: needinfo?(mchiang)
I can reproduce the bug with playing attachment 8612786 [details]. The clips audio track contains 4 channel. Format : AAC Format profile : HE-AACv2 / HE-AAC / LC Channel(s) : 2 channels / 1 channel / 1 channel Channel positions : Front: L R / Front: C / Front: C Sampling rate : 48.0 KHz / 48.0 KHz / 24.0 KHz MediaFormatReader configure channel# to 1 and sample rate to 24000. But actually we are playing 2 48 Khz channels. Blake, Could you help check the demuxer behavior?
Flags: needinfo?(bwu)
That's fun, I already ran into issues on some devices (including Xperia ZR) where decoding was being sent from Gecko to libstagefright with bogus mismatching sample rate, like 44 KHz when the stream was 48 KHz.
Recently there are several patches landed which refactor media reader design in KK m-c. Need to cowork with Jean & Blake to figure out the problem.
(In reply to Munro Chiang [:mchiang] from comment #10) > I can reproduce the bug with playing attachment 8612786 [details]. > The clips audio track contains 4 channel. > > Format : AAC > Format profile : HE-AACv2 / HE-AAC / LC > Channel(s) : 2 channels / 1 channel / 1 channel > Channel positions : Front: L R / Front: C / Front: C > Sampling rate : 48.0 KHz / 48.0 KHz / 24.0 KHz > > MediaFormatReader configure channel# to 1 and sample rate to 24000. > But actually we are playing 2 48 Khz channels. > > Blake, > > Could you help check the demuxer behavior? The problem is not in the demuxer nor the MediaFormatReader (you would have had the exact same behaviour with the older MP4Reader). The MediaFormatReader will read the metadata from the container, what is typically found there is the core AAC-LC stream information, so that's where your 24kHz sampling rate is coming from. Many AAC streams have the SBR inband, as such the demuxer isn't aware that it's HE-AAC. As such, we have to decode the first audio frame first. The MediaDataDecoder will typically detect the SBR data and return a frame with the updated sampling rate: 48kHz. It is expected that the MediaDataDecoder will wait until either the outband SBR (stored in the container and passed in mCodecSpecificData) or the inband SBR has been found before outputting a decoded audio sample. If the gonk decoder doesn't detect that it's an HE-AAC stream in the first frame but only does so in the following frames, there will be a mismatch of configuration, and the audio will not play properly. Glancing at the code, it appears that the gonk audio decoder set the audio rate to what is set in the demuxer (and stored in mAudioRate) and at no time queries the codec to see if the actual frame audio frame returned is of a different sampling rate. It assumes the sampling rate is the same. This is the reason why this file doesn't play properly. The gonk decoder needs to query the updated format. The OMX MediaCodecReader appears to do it properly http://mxr.mozilla.org/mozilla-central/source/dom/media/omx/MediaCodecReader.cpp#1470 And more particularly there: http://mxr.mozilla.org/mozilla-central/source/dom/media/omx/MediaCodecReader.cpp#1507 The Gonk MediaDataDecoder needs to perform a similar operation
(In reply to Munro Chiang [:mchiang] from comment #10) > I can reproduce the bug with playing attachment 8612786 [details]. > The clips audio track contains 4 channel. > > Format : AAC > Format profile : HE-AACv2 / HE-AAC / LC > Channel(s) : 2 channels / 1 channel / 1 channel > Channel positions : Front: L R / Front: C / Front: C > Sampling rate : 48.0 KHz / 48.0 KHz / 24.0 KHz > > MediaFormatReader configure channel# to 1 and sample rate to 24000. > But actually we are playing 2 48 Khz channels. Thanks for your help to narrow down the possible root causes!
Flags: needinfo?(bwu)
(In reply to Jean-Yves Avenard [:jya] from comment #13) > (In reply to Munro Chiang [:mchiang] from comment #10) > > I can reproduce the bug with playing attachment 8612786 [details]. > > The clips audio track contains 4 channel. > > > > Format : AAC > > Format profile : HE-AACv2 / HE-AAC / LC > > Channel(s) : 2 channels / 1 channel / 1 channel > > Channel positions : Front: L R / Front: C / Front: C > > Sampling rate : 48.0 KHz / 48.0 KHz / 24.0 KHz > > > > MediaFormatReader configure channel# to 1 and sample rate to 24000. > > But actually we are playing 2 48 Khz channels. > > > > Blake, > > > > Could you help check the demuxer behavior? > > The problem is not in the demuxer nor the MediaFormatReader (you would have > had the exact same behaviour with the older MP4Reader). > > The MediaFormatReader will read the metadata from the container, what is > typically found there is the core AAC-LC stream information, so that's where > your 24kHz sampling rate is coming from. > Many AAC streams have the SBR inband, as such the demuxer isn't aware that > it's HE-AAC. > > As such, we have to decode the first audio frame first. The MediaDataDecoder > will typically detect the SBR data and return a frame with the updated > sampling rate: 48kHz. > > It is expected that the MediaDataDecoder will wait until either the outband > SBR (stored in the container and passed in mCodecSpecificData) or the inband > SBR has been found before outputting a decoded audio sample. > > If the gonk decoder doesn't detect that it's an HE-AAC stream in the first > frame but only does so in the following frames, there will be a mismatch of > configuration, and the audio will not play properly. > > Glancing at the code, it appears that the gonk audio decoder set the audio > rate to what is set in the demuxer (and stored in mAudioRate) and at no time > queries the codec to see if the actual frame audio frame returned is of a > different sampling rate. It assumes the sampling rate is the same. > > This is the reason why this file doesn't play properly. > > The gonk decoder needs to query the updated format. > The OMX MediaCodecReader appears to do it properly > http://mxr.mozilla.org/mozilla-central/source/dom/media/omx/MediaCodecReader. > cpp#1470 > > And more particularly there: > http://mxr.mozilla.org/mozilla-central/source/dom/media/omx/MediaCodecReader. > cpp#1507 > > The Gonk MediaDataDecoder needs to perform a similar operation Thanks for your detailed information! I will check it.
I have come out some idea to mimic the way MediaOmxReader query the sample rate & channel# from codec. Will provide a WIP in these two days. However, it seems current design of Android MediaCodec doesn't expose a method for upstream to query these info. That means in Android, extractor takes the whole responsibility to parse the correct sample rate & channel# info.
(In reply to Munro Chiang [:mchiang] from comment #18) > That means in Android, extractor > takes the whole responsibility to parse the correct sample rate & channel# > info. This can't work. The container doesn't contain any information about the AAC-HE stream
Sotaro, do you have any suggested next steps here, or people we can contact?
Flags: needinfo?(sotaro.ikeda.g)
(FWIW my dupe bug 1171179 reproduces on the Flame as well as the Aries device, which semi-conflicts with comment 0 here. Not sure if that means comment 0 was mistaken, or if bug 1171179 is not a dupe after all, or if only certain videos trigger this on the flame & I happen to have found one.)
(In reply to Doug Sherk (:drs) (use needinfo?) from comment #20) > Sotaro, do you have any suggested next steps here, or people we can contact? The following functions already do necessary things for android::MediaCodec. Jut mimic them seems enough to fix the problem. android::MediaCodec::getOutputFormat() provides necessary metadata. - MediaCodecReader::EnsureCodecFormatParsed() - MediaCodecReader::UpdateAudioInfo() https://dxr.mozilla.org/mozilla-central/source/dom/media/omx/MediaCodecReader.cpp#1554
Flags: needinfo?(sotaro.ikeda.g)
MediaCodecReader::UpdateVideoInfo() equivalent is also necessary.
Thanks, Sotaro. Munro, hopefully this information is helpful. I'm assigning this to you since you're actively working on this. Please let me know if this is a problem, or you've stopped working on it.
Assignee: nobody → mchiang
(In reply to Sotaro Ikeda [:sotaro] from comment #23) > (In reply to Doug Sherk (:drs) (use needinfo?) from comment #20) > > Sotaro, do you have any suggested next steps here, or people we can contact? > > The following functions already do necessary things for android::MediaCodec. > Jut mimic them seems enough to fix the problem. > android::MediaCodec::getOutputFormat() provides necessary metadata. > - MediaCodecReader::EnsureCodecFormatParsed() > - MediaCodecReader::UpdateAudioInfo() > > https://dxr.mozilla.org/mozilla-central/source/dom/media/omx/ > MediaCodecReader.cpp#1554 Thanks for the information! I port the snippet to GonkAudioDecoderManager.cpp. Please let me know if there is any concern.
Attachment #8615079 - Attachment is obsolete: true
Attachment #8615767 - Flags: review?(sotaro.ikeda.g)
Comment on attachment 8615767 [details] [diff] [review] bug-1166760-fix.patch Looks good!
Attachment #8615767 - Flags: review?(sotaro.ikeda.g) → review+
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.2 S14 (12june)
blocking-b2g: spark+ → 2.5+
This issue is verified fixed on the latest Spark and Flame 2.5 builds. Pandora and Facebook audio plays at the proper speed and sounds appropriate. Environmental Variables: Device: Flame 2.5 BuildID: 20150818030206 Gaia: d9d99f32762975a370f1abd34a3512bd6fe29111 Gecko: 90d9b7c391d38ae118865bd87b5d011feee6dded Gonk: c4779d6da0f85894b1f78f0351b43f2949e8decd Version: 43.0a1 (2.5) Firmware Version: v18D User Agent: Mozilla/5.0 (Mobile; rv:43.0) Gecko/43.0 Firefox/43.0 Environmental Variables: Device: Aries 2.5 BuildID: 20150818175310 Gaia: 507ba38fb64b27f87d11f4104dfcc58448e12b1a Gecko: 2c272af993c23e803f6ea7798a812b0c8abfad4d Gonk: 2916e2368074b5383c80bf5a0fba3fc83ba310bd Version: 43.0a1 (2.5) Firmware Version: D5803_23.1.A.1.28_NCB.ftf User Agent: Mozilla/5.0 (Mobile; rv:43.0) Gecko/43.0 Firefox/43.0
Status: RESOLVED → VERIFIED
QA Whiteboard: [QAnalyst-Triage?]
Flags: needinfo?(ktucker)
QA Whiteboard: [QAnalyst-Triage?] → [QAnalyst-Triage+]
Flags: needinfo?(ktucker)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: