PR #26013 opened by Baptiste Coudurier (bcoudurier) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26013 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26013.patch
Apple's [HDR metadata document](https://developer.apple.com/av-foundation/High-Dynamic-Range-Metadata-for-Apple-Devices.pdf) requires a `colr` box with primaries, transfer and matrix all set to 2 (unspecified) for Dolby Vision profile 5. movenc only wrote `colr` when all three values were known, when `+write_colr` was set, or when an ICC profile was present. A profile 5 stream, whose colours are unspecified, got no `colr` at all. movenc now also writes `colr` when the stream has a Dolby Vision configuration, in MOV and MP4 (not AVIF): - `mov/dovi-p5.mp4` remuxed: MP4 gets `nclx 2/2/2 full=1`, MOV gets `nclc 2/2/2`. Before, neither got a `colr`. - Profiles 7 and 8.1 (`dovi-p7`, `dovi-p81`, `dovi-p7-hvce`) still get their 9/16/9 values. - Streams without Dolby Vision are unchanged. The "no ICC profile found" message is now only logged when an ICC profile is actually present, rather than every time `colr` is written without full colour info. New FATE test `fate-mov-dovi-p5-colr` remuxes the profile 5 sample to MOV; it fails without the change. Full FATE passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) From 3cdaad0af35ae3dc5db5de8ee7bb9dc6e1360d98 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier <[email protected]> Date: Thu, 12 Nov 2026 17:32:27 -0800 Subject: [PATCH] avformat/movenc: write colr for Dolby Vision Profile 5 signals unspecified colours, which Apple still requires as colr 2/2/2. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Baptiste Coudurier <[email protected]> --- libavformat/movenc.c | 14 ++++++++++---- tests/fate/mov.mak | 4 ++++ tests/ref/fate/mov-dovi-p5-colr | 10 ++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 tests/ref/fate/mov-dovi-p5-colr diff --git a/libavformat/movenc.c b/libavformat/movenc.c index f36072470f3..07bc9a3bff6 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3021,10 +3021,16 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex int has_color_info = track->par->color_primaries != AVCOL_PRI_UNSPECIFIED && track->par->color_trc != AVCOL_TRC_UNSPECIFIED && track->par->color_space != AVCOL_SPC_UNSPECIFIED; - if (has_color_info || mov->flags & FF_MOV_FLAG_WRITE_COLR || - av_packet_side_data_get(track->st->codecpar->coded_side_data, track->st->codecpar->nb_coded_side_data, - AV_PKT_DATA_ICC_PROFILE)) { - int prefer_icc = mov->flags & FF_MOV_FLAG_PREFER_ICC || !has_color_info; + const AVPacketSideData *icc = av_packet_side_data_get(track->st->codecpar->coded_side_data, + track->st->codecpar->nb_coded_side_data, + AV_PKT_DATA_ICC_PROFILE); + const AVPacketSideData *dovi = av_packet_side_data_get(track->st->codecpar->coded_side_data, + track->st->codecpar->nb_coded_side_data, + AV_PKT_DATA_DOVI_CONF); + // Dolby Vision requires colr, even with unspecified values + if (has_color_info || mov->flags & FF_MOV_FLAG_WRITE_COLR || icc || + (dovi && track->mode != MODE_AVIF)) { + int prefer_icc = mov->flags & FF_MOV_FLAG_PREFER_ICC || (!has_color_info && icc); mov_write_colr_tag(pb, track, prefer_icc); } } else if (mov->flags & FF_MOV_FLAG_WRITE_COLR) { diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 01b1346cec5..a2cad3b17b5 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -350,6 +350,10 @@ FATE_MOV_FFMPEG_FFPROBE_SAMPLES-$(call REMUX, MP4 MOV, MATROSKA_DEMUXER HEVC_DEC += fate-mov-dovi-hvce-mkv-to-mp4 fate-mov-dovi-hvce-mkv-to-mp4: CMD = transcode matroska $(TARGET_SAMPLES)/mkv/dovi-p7-hvce.mkv mp4 "-map 0 -c copy -strict unofficial" "-map 0 -c copy" "-show_entries stream_side_data_list -select_streams v" +# Dolby Vision profile 5 signals no colours; colr must still be written, as 2/2/2 +FATE_MOV_FFMPEG_SAMPLES-$(call REMUX, MOV, HEVC_PARSER) += fate-mov-dovi-p5-colr +fate-mov-dovi-p5-colr: CMD = stream_remux mov $(TARGET_SAMPLES)/mov/dovi-p5.mp4 "" mov "-map 0:v -frames:v 2" "" "-c:v copy" + FATE_MOV_FFMPEG_SAMPLES-$(call REMUX, MP4 MOV, H264_PARSER) \ += fate-mov-mp4-multiple-stsd-muxing fate-mov-mp4-multiple-stsd-muxing: CMD = transcode mov $(TARGET_SAMPLES)/h264/extradata-reload-multi-stsd.mov mp4 "-c:v copy" "-c:v copy" diff --git a/tests/ref/fate/mov-dovi-p5-colr b/tests/ref/fate/mov-dovi-p5-colr new file mode 100644 index 00000000000..85fee6cef0d --- /dev/null +++ b/tests/ref/fate/mov-dovi-p5-colr @@ -0,0 +1,10 @@ +93a4e112fdea6354133091cb681c4d73 *tests/data/fate/mov-dovi-p5-colr.mov +1881 tests/data/fate/mov-dovi-p5-colr.mov +#extradata 0: 23, 0x34a20617 +#tb 0: 1/12288 +#media_type 0: video +#codec_id 0: hevc +#dimensions 0: 1920x1080 +#sar 0: 1/1 +0, -1024, 0, 512, 812, 0x720f633e +0, -512, 2048, 512, 260, 0x91e1492e, F=0x0 -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
