<div dir="ltr">I am struggling to make AAC encoding work with libav.<div><br></div><div>I have an example working for MP3. But I can't seem to figure out what is needed to make AAC encoding work. I get a whole bunch of errors when playing my encoder output.</div><div><br></div><div>I suspect I need some extra configuration for encoder context, but I have not been able to find hints that can help me.<br></div><div><br></div><div><div><div>I have made a repo here with my code:</div><div><a href="https://github.com/taxfromdk/audio_encode_test.git">https://github.com/taxfromdk/audio_encode_test.git</a></div><div><br></div><div>The juicy code is here: <a href="https://github.com/taxfromdk/audio_encode_test/blob/master/encode_audio.cpp">https://github.com/taxfromdk/audio_encode_test/blob/master/encode_audio.cpp</a></div><div></div></div><div><br></div><div>It can be run by checking the project out out and run "make test"</div><div><br></div><div></div></div><div>I suspect it could be related to my workflow, so I will just note that I test the output data by creating a file with either the extension .aac or .mp3 where I dump the raw encoded packages and play through ffplay.</div><div><br></div><div>I am on <span style="color:rgb(0,0,0);font-family:monospace">ffmpeg version n4.3.1 under Arch linux.</span></div><div><br></div><div>The output from ffplay in case of the AAC file is listed below.</div><div><br></div><div>I would appreciate pointers to what is needed for the codec context to spit out working AAC, as I need it to accompany some video. :)</div><div><br></div><div>Kind regards</div><div><br></div><div>Jesper</div><div><br></div><div><span style="color:rgb(0,0,0);font-family:monospace">------</span></div><div><span style="color:rgb(0,0,0);font-family:monospace"><br></span></div><div><span style="color:rgb(0,0,0);font-family:monospace">ffplay raw.aac -autoexit </span><br></div><div><span style="font-family:monospace">ffplay version n4.3.1 Copyright (c) 2003-2020 the FFmpeg developers
<br><span style="color:rgb(255,95,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8000bc0] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Format aac detected only with low score of 1, misdetection possible!</span><span style="color:rgb(0,0,0)">
</span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Error decoding AAC frame header.</span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">More than one AAC RDB per ADTS frame is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still o</span><br>ccurs, it means that your file has a feature which has not been implemented. <span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Sample rate index in program config element does not match the sample rate index configured by the container. </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Inconsistent channel configuration.</span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">get_buffer() failed </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">invalid band type </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">channel element 2.14 is not allocated </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Sample rate index in program config element does not match the sample rate index configured by the container.</span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Too large remapped id is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means</span><br> that your file has a feature which has not been implemented. <span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">If you want to help, upload a sample of this file to <a href="https://streams.videolan.org/upload/">https://streams.videolan.org/upload/</a> and contact the ffmpeg-devel mailing list. (</span><br><a href="mailto:ffmpeg-devel@ffmpeg.org">ffmpeg-devel@ffmpeg.org</a>) <span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Multiple frames in a packet. </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Reserved bit set.</span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Number of scalefactor bands in group (58) exceeds limit (47). </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Reserved bit set. </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Number of bands (24) exceeds limit (22). </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">channel element 1.0 is not allocated </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Reserved bit set. </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Number of scalefactor bands in group (15) exceeds limit (12). </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">channel element 1.10 is not allocated </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">SBR was found before the first channel element. </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">channel element 3.6 is not allocated </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(255,95,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8000bc0] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Packet corrupt (stream = 0, dts = NOPTS).</span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Sample rate index in program config element does not match the sample rate index configured by the container. </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Inconsistent channel configuration.</span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">get_buffer() failed </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">channel element 3.14 is not allocated </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Sample rate index in program config element does not match the sample rate index configured by the container.</span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">Inconsistent channel configuration.</span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(0,175,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8002600] </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)">get_buffer() failed </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(255,95,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8000bc0] </span><span style="color:rgb(0,0,0)">decoding for stream 0 failed</span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(255,95,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8000bc0] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Estimating duration from bitrate, this may be inaccurate</span><span style="color:rgb(0,0,0)">
</span><br><span style="color:rgb(255,95,255);background-color:rgb(0,0,0)">[aac @ 0x7fe6f8000bc0] </span><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Could not find codec parameters for stream 0 (Audio: aac (Main), mono, fltp, 58 kb/s): unspecified sample rate </span><span style="color:rgb(0,0,0)"> </span><br><span style="color:rgb(255,255,0);background-color:rgb(0,0,0)">Consider increasing the value for the 'analyzeduration' and 'probesize' options </span><span style="color:rgb(0,0,0)"> </span><br>Input #0, aac, from 'raw.aac':<span style="color:rgb(255,255,0);background-color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,0)"> </span><br> Duration: 00:00:04.26, bitrate: 58 kb/s
<br> Stream #0:0: Audio: aac (Main), mono, fltp, 58 kb/s
<br><span style="color:rgb(255,135,0);background-color:rgb(0,0,0)">Failed to open file 'raw.aac' or configure filtergraph</span><br><span style="color:rgb(0,0,0)">
</span><br></span></div><div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><br></div></div></div></div></div>