AAC audio stops and seeking can stall after an ADTS PCE-to-stereo transition

Author: JunliangRenCreated Sep 23, 2026Updated Sep 23, 2026

Hi,

I encountered an AAC decoding issue with a broadcast MPEG-TS recording. The audio is AAC-LC at 48 kHz. At approximately 9.58 seconds, the ADTS channel_configuration changes from 0 (using a Program Config Element) to 2 (explicit stereo).

Observed behavior:

  • Playing through the transition: video continues, but audio stops.
  • Seeking past the transition: playback can stall.
  • Seeking back before the transition: playback recovers.

The decoder reports:

channel element 1.2 is not allocated

Cause and proposed fix

In LAV's FFmpeg fork, parse_adts_frame_header() in libavcodec/aac/aacdec.c installs the explicit ADTS channel configuration but leaves m4ac.pce set from the earlier PCE.

Consequently, ff_aac_get_che() continues using PCE element-tag mapping after the configuration has changed.

Clearing the stale flag when an explicit ADTS channel configuration is installed fixes this recording:

diff
         if (hdr_info.chan_config) {
             ac->oc[1].m4ac.chan_config = hdr_info.chan_config;
+            /* An explicit ADTS channel configuration replaces an earlier PCE. */
+            ac->oc[1].m4ac.pce = 0;
             if ((ret = ff_aac_set_default_channel_config(ac, ac->avctx,

The patch applies to LAV's FFmpeg revision 43410e614d781272a18b06a917d1d7d773bb763a. It retains the separate PCE flag and leaves the LATM handling unchanged.

Validation

Local tests used Windows x86 and x64 builds of clsid2/LAVFilters with FFmpeg base 29e0b0813d855d55536cd11ae4a8b6de88ee6461.

  • Without the fix, 5 of 7 audio playback/seek cases fail; the two backward-seek cases pass.
  • With the fix, all 7 audio-only and 7 audio/video cases pass on both architectures, including playback across the transition and repeated seeks using the same graph and decoder.
  • Complete-file audio decoding also passes on both architectures, producing approximately 72 minutes of PCM audio.

The AAC source directory and libavcodec/mpeg4audio.h are identical between the tested FFmpeg base and LAV's 43410e614d revision.

These tests used accelerated, headless DirectShow graphs. A separate full build of Nevcairiel/LAVFilters with this patch, and playback through a player's actual audio/video renderers, have not yet been tested.

Could this fix be reviewed for LAV's FFmpeg fork and picked up through a LAVFilters submodule update?

Thank you.