Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distorted sound in AAC stream #67

Open
jpalus opened this issue Nov 1, 2020 · 14 comments
Open

Distorted sound in AAC stream #67

jpalus opened this issue Nov 1, 2020 · 14 comments

Comments

@jpalus
Copy link

jpalus commented Nov 1, 2020

48kbps AAC stream is decoded fine with ffmpeg while faad2 decodes it distorted. However I think for a small fraction of second at the very beginning it plays fine (volume level is significantly different between "good" and "bad"). Sample can be downloaded here:

http://jpalus.fastmail.com/out.aac

@Kazzaky
Copy link

Kazzaky commented Jan 7, 2022

i have same issue but its way more noticeable like the sound is almost muted, just occasionally few fraction of seconds

@eustas
Copy link
Contributor

eustas commented Apr 18, 2023

Hello, @jpalus @Kazzaky.

Unfortunately old link is not working. Please consider re-sharing (I believe you can attach file to message by simply drag-n-dropping).

I would be glad to investigate the problem. Also, please mention an alternative decoder you use, so I will have a baseline for comparison.

@jpalus
Copy link
Author

jpalus commented Apr 18, 2023

Link still works fine for me but here it is compressed with zip (due to file type restrictions in GH).
out-aac.zip

@jpalus
Copy link
Author

jpalus commented Apr 18, 2023

Regarding decoders:

Those that work well: ffmpeg, fdk-aac, ie using gstreamer:

# ffmpeg
$ gst-launch-1.0  filesrc location=out.aac ! aacparse ! avdec_aac ! audioresample ! audioconvert ! audio/x-raw,format=S16LE,rate=41000 ! wavenc ! filesink location=out-av.wav
# fdk-aac
$ gst-launch-1.0  filesrc location=out.aac ! aacparse ! fdkaacdec ! audioresample ! audioconvert ! audio/x-raw,format=S16LE,rate=41000 ! wavenc ! filesink location=out-fdk-aac.wav

And for faad:

$ gst-launch-1.0  filesrc location=out.aac ! aacparse ! faad ! audioresample ! audioconvert ! audio/x-raw,format=S16LE,rate=41000 ! wavenc ! filesink location=out-faad.wav

@eustas
Copy link
Contributor

eustas commented Apr 20, 2023

Thanks. This will help a lot.

@eustas
Copy link
Contributor

eustas commented May 15, 2023

Even with faad executable distortion is reproducible.
Trying to compare with other aac decoding library. Unfortunately, there is no open libraries that just build and work...

@eustas
Copy link
Contributor

eustas commented May 16, 2023

Likely found one problem: faad2 drops the first frame output.
(that is because object type is LC, not LD?)

But distortion is still there...

@eustas
Copy link
Contributor

eustas commented May 16, 2023

It seems that sound is not distorted at the beginning... It is just goes very quiet after first few frames.

Top: current faad2
Middle: modified faad2 that does not swallow first frame
Bottom: Fraunhofer decoder
Screenshot 2023-05-16 at 18 36 10

@eustas
Copy link
Contributor

eustas commented Jun 6, 2023

One more clue - decoding in "fixed_point" mode produces loud noise... Still do not have enough time to pinpoint the problem...

@eustas
Copy link
Contributor

eustas commented Jun 8, 2023

#149 should fix dropping of the first frame. Not adding primer as FDK does, because it seems to be too much.

@fabiangreffrath
Copy link
Collaborator

This is still marked as one of the release blockers in #115. How are the chances to fix this? @eustas

@eustas
Copy link
Contributor

eustas commented Aug 22, 2023

At last debugging session I've got some insights and understood that I need to dive deeper. Going to remove it from blocker list, as have no resources to fix it timely.

@ghost
Copy link

ghost commented Sep 22, 2023

Noticed this for some iTunes M4A files as well. Using minimp4 as demuxer, though. Problem vanishes with libfdk-aac.

@bahusoid
Copy link
Contributor

Unfortunately, there is no open libraries that just build and work...

Found simple example with fdk-aac here.
I prepared sample project based on it for debugging decoding with fdk-aac with supplied file. See https://github.com/bahusoid/aac-example

Debugging dec_test.cpp I noticed that second frame is decoded differently with libfaad and fdk-aac. In fdk-aac second frame is decoded to all zeroes (same as first frame) but it has some values in libfaad.
Looks suspicious.

In fdk-aac second frame has some values initially and data are zeroed in sbr processing (inside sbrDecoder_DecodeElement):

qmfSynPrototypeFirSlot qmf.cpp:184
qmfSynthesisFilteringSlot qmf.cpp:881
qmfSynthesisFiltering qmf.cpp:951
sbr_dec sbr_dec.cpp:571
sbrDecoder_DecodeElement sbrdecoder.cpp:1473
sbrDecoder_Apply sbrdecoder.cpp:1624
aacDecoder_DecodeFrame aacdecoder_lib.cpp:951
AacDecoder::aacdec_decode_frame fdkaac_dec.cpp:79
main dec_test.cpp:100
  • And then left non-zero values are zeroed here

So seems libfaad makes something differently in sbr processing (if I properly found similar place something wrong might be here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants