Project

General

Profile

Bug #6165

Demuxing AAC audio fails when channel config not set in ADTS header

Added by Adam W over 2 years ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Muxers
Target version:
-
Start date:
2022-05-01
Due date:
% Done:

0%

Estimated time:
Found in version:
4.3-2025
Affected Versions:

Description

In some audio channels using AAC (in ADTS packets), the MPEG-4 channel config is not set in the ADTS frame header - it's set to zero.

This is allowed in the spec according to https://wiki.multimedia.cx/index.php/ADTS

When set to zero it should be assumed that the channel configuration is sent via an inband PCE (Program Config Element) within the AAC frame body.

This doesn't work with TVHeadend when re-muxing from MPEG-TS to either HTSP or raw audio. No audio is received at all when using either the audio profile or trying to listen to an affected channel via HTSP in Kodi.

The services in question that I can replicate this with are the ALOUETTE radio channel via satellite (Eutelsat 5WB 5°W 11465.2H 667 DVB-S2 8PSK 3/5) -

Example ADTS header in hex:

FF F1 4C 00 55 40 00

Last bit of byte 3 and first two bytes of byte 4 = 0

0100110 0 00 000000

Editing the file parsers.c as shown below to force a channels value of 1 where it's set to zero in the header fixes this - I now get audio when using HTSP/raw audio stream. There are actually 2 channels in the specific problem audio stream but any value above zero seems to make it work.

This fix does work and doesn't seem to break anything that does have its number of channels flagged in the header in the normal way, but I wanted to raise this as a bug in case there's a neater way to fix.

diff --git a/src/parsers/parsers.c b/src/parsers/parsers.c
index 7c20d01d2..5e21da183 100644
--- a/src/parsers/parsers.c
+++ b/src/parsers/parsers.c
@@ -615,6 +615,11 @@ static void parse_mp4a_data(parser_t *t, parser_es_t *st,

           int channels = ((p[2] & 0x01) << 2) | ((p[3] & 0xc0) >> 6);

+          // Set a fallback channel config where flagged as inband PCE.
+          if(channels == 0) {
+            channels = 1;
+          }
+
           makeapkt(t, st, p, fsize, dts, duration, channels, sri);
           sbuf_cut(&st->es_buf_a, i + fsize);
           goto again;

Files

ALOUETTE_5W.ts (928 KB) ALOUETTE_5W.ts Adam W, 2022-05-01 16:31

History

#1

Updated by Adam W over 2 years ago

Also available in: Atom PDF