HydrogenAudio

Lossy Audio Compression => AAC => AAC - Tech => Topic started by: trungnq on 2013-02-27 09:40:55

Title: How do I get frameLength from packets from FFmpeg?
Post by: trungnq on 2013-02-27 09:40:55
Hi all,

I use ffmpeg to generate adts stream:

ffmpeg -re -i input.mp3 -acodec aac -strict experimental -ab 64k -f adts tcp://localhost:1234

I have a sequence of packets with different size (normally around 200bytes each). I can extract the adts header with 7 bytes by following this http://wiki.multimedia.cx/index.php?title=ADTS (http://wiki.multimedia.cx/index.php?title=ADTS) (by the way, do anybody know about the field calls "Buffer fullness" in ADTS header?).

To decode (using http://labs.official.fm/codecs/aac/) (http://labs.official.fm/codecs/aac/)) I need to know frameLength, but I don't know how to get this value from packets I receive from ffmpeg. As I understand, frame length is the number of samples in one frame. I don't know if it's correct or not (please correct me if I am wrong). The packets are varies in size, does it mean the frameLength is not fixed for ADTS packets?

Thanks a lot in advance!!

--Trung

Title: How do I get frameLength from packets from FFmpeg?
Post by: trungnq on 2013-02-27 16:42:07
After googling around, I see the frameLength is always 1024 (samples in a frame). I am going to test the decoder, see if it works.
Title: How do I get frameLength from packets from FFmpeg?
Post by: trungnq on 2013-02-28 09:43:52
Thing goes well with frameLength 1024

But one strange thing with ffmpeg is, sometimes it generates some big adts packet. Normally adts packet with 64kbs is around 200bytes per frame, but sometimes, I get 1000+bytes packet. This make the sound a bit weird (at least with my decoder). But in the adts header, the actual frame size is much smaller than 1000+bytes. So there are some redundant bytes (don't know what does it use for).
Title: How do I get frameLength from packets from FFmpeg?
Post by: trungnq on 2013-03-01 09:03:48
It seems there is no problem when I use ffmpeg with -acodec libfaac.

Thing goes well with frameLength 1024

But one strange thing with ffmpeg is, sometimes it generates some big adts packet. Normally adts packet with 64kbs is around 200bytes per frame, but sometimes, I get 1000+bytes packet. This make the sound a bit weird (at least with my decoder). But in the adts header, the actual frame size is much smaller than 1000+bytes. So there are some redundant bytes (don't know what does it use for).

Title: Re: How do I get frameLength from packets from FFmpeg?
Post by: xsbee on 2022-04-25 13:50:56
Hi all,

I use ffmpeg to generate adts stream:

ffmpeg -re -i input.mp3 -acodec aac -strict experimental -ab 64k -f adts tcp://localhost:1234

I have a sequence of packets with different size (normally around 200bytes each). I can extract the adts header with 7 bytes by following this http://wiki.multimedia.cx/index.php?title=ADTS (http://wiki.multimedia.cx/index.php?title=ADTS) (by the way, do anybody know about the field calls "Buffer fullness" in ADTS header?).

To decode (using http://labs.official.fm/codecs/aac/) (http://labs.official.fm/codecs/aac/)) I need to know frameLength, but I don't know how to get this value from packets I receive from ffmpeg. As I understand, frame length is the number of samples in one frame. I don't know if it's correct or not (please correct me if I am wrong). The packets are varies in size, does it mean the frameLength is not fixed for ADTS packets?

Thanks a lot in advance!!

--Trung



It is the state (available number of bits) in the bit reservoir divided by number of channels divided by 32. It is a useless field which decoders don't make a use of and neither do encoders put meaningful information. It is usually 0x7FF denoting VBR configuration, for which it is explicitly stated that it serves no use in the ISO/IEC 13818-7 specification.