Commit 79e66e68c5 for ffmpeg
commit 79e66e68c58e4faf3818499a926a444c2b5a1326
Author: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
Date: Wed Sep 23 20:42:38 2026 +0200
avformat/movenc: preserve composer metadata in mov output
the MOV demuxer reads composer from the QuickTime ©com atom, but the
muxer drops it. write the atom so mov-to-mov remuxing keeps composer.
test the atom and metadata readback.
Signed-off-by: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index ea71acde42..ed49b361af 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5225,6 +5225,9 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
mov_write_string_metadata(s, pb_buf, "\251nam", "title", 0);
mov_write_string_metadata(s, pb_buf, "\251aut", "author", 0);
mov_write_string_metadata(s, pb_buf, "\251alb", "album", 0);
+ /* mov_read_udta_string() already maps this atom back to "composer";
+ * without it a mov to mov remux dropped the tag on the floor. */
+ mov_write_string_metadata(s, pb_buf, "\251com", "composer", 0);
mov_write_string_metadata(s, pb_buf, "\251day", "date", 0);
mov_write_string_metadata(s, pb_buf, "\251swr", "encoder", 0);
// currently ignored by mov.c
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 7aabe980d3..4914133f19 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -417,6 +417,14 @@ fate-mov-vfr: CMD = md5 -filter_complex testsrc=size=2x2:duration=1,setpts=N*N:s
fate-mov-vfr: CMP = oneline
fate-mov-vfr: REF = 1558b4a9398d8635783c93f84eb5a60d
+# The QuickTime user data list has to carry the composer atom the demuxer
+# already reads: without it a mov to mov remux dropped the tag.
+FATE_MOV_FFMPEG_FFPROBE-$(call TRANSCODE, PCM_S16LE, MOV, WAV_DEMUXER ARESAMPLE_FILTER) += fate-mov-composer-metadata
+fate-mov-composer-metadata: tests/data/asynth-44100-2.wav
+fate-mov-composer-metadata: CMD = transcode wav ./tests/data/asynth-44100-2.wav mov \
+ "-af aresample -c:a pcm_s16le -t 0.05 -metadata composer=Bach" \
+ "-af aresample -c:a pcm_s16le" "-show_entries format_tags"
+
FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, COLOR_FILTER SETPTS_FILTER MPEG4_ENCODER \
MOV_MUXER MOV_DEMUXER FILE_PROTOCOL) \
+= fate-mov-vfr-bframes-derived-duration
diff --git a/tests/ref/fate/mov-composer-metadata b/tests/ref/fate/mov-composer-metadata
new file mode 100644
index 0000000000..36ac7861d8
--- /dev/null
+++ b/tests/ref/fate/mov-composer-metadata
@@ -0,0 +1,16 @@
+2e6eec0db55953fbfc36508c97ad1a8e *tests/data/fate/mov-composer-metadata.mov
+9497 tests/data/fate/mov-composer-metadata.mov
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0, 0, 0, 1024, 4096, 0x29e3eecf
+0, 1024, 1024, 1024, 4096, 0x18390b96
+0, 2048, 2048, 157, 628, 0x4db5381d
+[FORMAT]
+TAG:major_brand=qt
+TAG:minor_version=512
+TAG:compatible_brands=qt
+TAG:composer=Bach
+[/FORMAT]