knik0 / faad2

Freeware Advanced Audio (AAC) Decoder faad2 mirror
https://sourceforge.net/projects/faac/
Other
175 stars 78 forks source link

Distorted sound in AAC stream #67

Open jpalus opened 4 years ago

jpalus commented 4 years ago

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 commented 2 years ago

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

eustas commented 1 year ago

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 commented 1 year ago

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

jpalus commented 1 year ago

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 commented 1 year ago

Thanks. This will help a lot.

eustas commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

eustas commented 1 year ago

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

fabiangreffrath commented 1 year ago

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

eustas commented 1 year ago

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 commented 1 year ago

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

bahusoid commented 8 months ago

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):

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