PR #26142 opened by Baptiste Coudurier (bcoudurier)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26142
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26142.patch

# Summary of changes

Write the fixed ChannelCount value of 2 required by section 2.4 of Dolby's 
TrueHD-in-ISO-BMFF specification. Multichannel TrueHD previously wrote the 
stream's actual channel count in the mlpa sample entry.

Remove the experimental compliance requirement for TrueHD in MP4. The MP4-only 
format restriction is retained.

Independent reader checks on an FFmpeg-generated MP4 containing Dolby's 
8-channel, 96 kHz channel-identification stream:

- AVFoundation on macOS 27.2.1 recognized mlpa and read all 59,465 compressed 
samples to completion. Native PCM decoding returned an unsupported-format error.
- VideoLAN's VLC 4.0.0-dev c13b3f29 used its own MP4 demuxer and decoded 
4,757,146 PCM frames through libavcodec, matching the source frame count. VLC 
skipped the dmlp payload.

Media3 also has an independent Java mlpa parser and a checked-in TrueHD MP4 
extraction test. It reads the sample rate as a 32-bit integer and ignores the 
sample-entry channel count in favor of an initial value of 2. ExoPlayer was 
inspected but was not executed against this output.

Validation on this branch uses Dolby's stream to check default-strictness MP4 
muxing, byte-identical TrueHD extraction, the ChannelCount value, and MOV 
rejection.

References

- [Dolby TrueHD carriage specification, section 
2.4](https://developer.dolby.com/globalassets/technology/dolby-truehd/dolby-truehd-mlp-bitstreams-within-the-iso-base-media-file-format.pdf)
- [Dolby channel-identification 
stream](https://github.com/DolbyLaboratories/dlb_mp4base/blob/master/test/signals/bd_channel_ID_8ch_96k.mlp)
- [Original experimental-status 
rationale](https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248435.html)
- [Independent-reader verification 
criterion](https://ffmpeg.org/pipermail/ffmpeg-devel/2022-November/303851.html)
- [Media3 mlpa 
parser](https://github.com/androidx/media/blob/8c6678b657ede1e7883fc164ef73ed483c7796c3/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/BoxParser.java#L2261)
- [Media3 TrueHD extraction 
test](https://github.com/androidx/media/blob/8c6678b657ede1e7883fc164ef73ed483c7796c3/libraries/extractor/src/test/java/androidx/media3/extractor/mp4/Mp4ExtractorParameterizedTest.java#L141)



>From 1c2e7c5cb4d4bd539c89b6c65ff1a578a861220a Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Tue, 17 Nov 2026 14:30:01 -0800
Subject: [PATCH] avformat/movenc: mark TrueHD in MP4 as stable

Write the fixed channel count required by the Dolby mlpa mapping and remove the 
experimental compliance check. Keep the MP4-only restriction.
---
 libavformat/movenc.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 293a85633e5..1897bb5a131 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1534,7 +1534,8 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
             avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
         } else { /* reserved for mp4/3gp */
             avio_wb16(pb, track->tag == MKTAG('i', 'a', 'm', 'f') ?
-                      0 : track->par->ch_layout.nb_channels);
+                      0 : track->par->codec_id == AV_CODEC_ID_TRUEHD ?
+                      2 : track->par->ch_layout.nb_channels);
             if (track->par->codec_id == AV_CODEC_ID_FLAC ||
                 track->par->codec_id == AV_CODEC_ID_ALAC) {
                 avio_wb16(pb, track->par->bits_per_raw_sample);
@@ -8827,14 +8828,6 @@ static int mov_init(AVFormatContext *s)
                     av_log(s, AV_LOG_ERROR, "%s only supported in MP4.\n", 
avcodec_get_name(track->par->codec_id));
                     return AVERROR(EINVAL);
                 }
-                if (track->par->codec_id == AV_CODEC_ID_TRUEHD &&
-                    s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
-                    av_log(s, AV_LOG_ERROR,
-                           "%s in MP4 support is experimental, add "
-                           "'-strict %d' if you want to use it.\n",
-                           avcodec_get_name(track->par->codec_id), 
FF_COMPLIANCE_EXPERIMENTAL);
-                    return AVERROR_EXPERIMENTAL;
-                }
             }
         } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
             track->timescale = st->time_base.den;
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to