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

Fixes #21544: a `-c copy` remux of an iPhone file dropped its 
`com.apple.quicktime.*` metadata (location, capture date, make and model, Live 
Photo identifier), because the mov muxer only writes the keys it maps to udta 
atoms.

1. **mdta placement**: with `use_metadata_tags`, mov now writes the mdta 
metadata in `moov/meta`, without version/flags as in the QTFF, instead of 
`moov/udta/meta`, which QuickTime readers ignore (Trac #4209).
2. **mov default**: the `com.apple.quicktime.*` keys are now kept in that box 
without `use_metadata_tags`. Six FATE refs change because their iPhone sources 
now keep their keys.
3. **No duplicate location**: mov with `use_metadata_tags` no longer writes 
`loci`, as `location` is already an mdta key.
4. **loci language**: without a language suffix on `location`, the language was 
0, which 3GPP TS 26.244 forbids, and readers ignore such boxes. It is now 
"und". Adds `fate-mov-loci-lang-mp4` and `-3gp`.
5. **mp4 and ipod**: written the way Apple's own files are. 
`com.apple.quicktime.location.ISO6709` becomes `loci` when there is no 
`location`; the capture date becomes a `udta/date` box in mp4, and `©day` with 
the make as `©mak` in ipod (m4a/m4v).

Tested on macOS with QuickTime readers, `avconvert` and Spotlight, and on an 
iPhone by importing the files into Photos:
- mov, with and without `use_metadata_tags`: location and capture date shown, 
every key reads back;
- mp4 and m4v: location and capture date shown, with the same boxes Apple's 
tools write for these formats;
- files without these keys are unchanged apart from the `loci` language; ismv 
and f4v are unchanged;
- full FATE passes.

Conflicts with #26001 around `get_metadata_lang()`; whichever lands second 
rebases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)



From 94316a9b4d97e4149f4dd738115a8f8ab853de25 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Fri, 13 Nov 2026 14:10:54 -0800
Subject: [PATCH 1/5] avformat/movenc: write mov mdta metadata in moov/meta

QuickTime only reads mdta metadata there, not in moov/udta/meta.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavformat/movenc.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c3fa66d816c..5b10a38260a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5095,6 +5095,23 @@ static int mov_write_mdta_ilst_tag(AVIOContext *pb, 
MOVMuxContext *mov,
     return update_size(pb, pos);
 }
 
+/* QuickTime metadata, stored in moov/meta where QuickTime looks for it */
+static int mov_write_mdta_meta_tag(AVIOContext *pb, MOVMuxContext *mov,
+                                   AVFormatContext *s)
+{
+    int64_t pos = avio_tell(pb);
+
+    if (!(mov->flags & FF_MOV_FLAG_USE_MDTA) || !av_dict_count(s->metadata))
+        return 0;
+
+    avio_wb32(pb, 0); /* size */
+    ffio_wfourcc(pb, "meta");
+    mov_write_mdta_hdlr_tag(pb, mov, s);
+    mov_write_mdta_keys_tag(pb, mov, s);
+    mov_write_mdta_ilst_tag(pb, mov, s);
+    return update_size(pb, pos);
+}
+
 /* meta data tags */
 static int mov_write_meta_tag(AVIOContext *pb, MOVMuxContext *mov,
                               AVFormatContext *s)
@@ -5260,8 +5277,9 @@ static int mov_write_udta_tag(AVIOContext *pb, 
MOVMuxContext *mov,
         mov_write_string_metadata(s, pb_buf, "\251key", "keywords",    0);
         mov_write_raw_metadata_tag(s, pb_buf, "XMP_", "xmp");
     } else {
-        /* iTunes meta data */
-        mov_write_meta_tag(pb_buf, mov, s);
+        /* iTunes meta data; mov writes mdta metadata in moov/meta instead */
+        if (mov->mode != MODE_MOV)
+            mov_write_meta_tag(pb_buf, mov, s);
         mov_write_loci_tag(s, pb_buf);
     }
 
@@ -5603,6 +5621,8 @@ static int mov_write_moov_tag(AVIOContext *pb, 
MOVMuxContext *mov,
         mov_write_uuidusmt_tag(pb, s);
     else if (mov->mode != MODE_AVIF)
         mov_write_udta_tag(pb, mov, s);
+    if (mov->mode == MODE_MOV)
+        mov_write_mdta_meta_tag(pb, mov, s);
     for (i = 0; i < mov->nb_streams; i++)
         mov_write_pssh_tag(pb, mov->tracks[i].st);
 
-- 
2.54.0


From 5d8a37808debe67b6320308e9a8122410363b646 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Fri, 13 Nov 2026 14:11:39 -0800
Subject: [PATCH 2/5] avformat/movenc: keep com.apple.quicktime metadata in mov
 by default

They have no udta equivalent and were dropped without use_metadata_tags,
losing e.g. iPhone location. Fixes #21544.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavformat/movenc.c                            | 17 ++++++++++++++++-
 tests/ref/fate/autorotate                       |  4 ++--
 tests/ref/fate/copy-trac236                     |  4 ++--
 tests/ref/fate/ffmpeg-side-data-bsf-keep-stream |  4 ++--
 .../ref/fate/ffmpeg-side-data-bsf-remove-stream |  4 ++--
 tests/ref/fate/filter-meta-4560-rotate0         |  4 ++--
 tests/ref/lavf-fate/mv_hevc.mov                 |  4 ++--
 7 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5b10a38260a..9f9e4f6a345 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5045,6 +5045,13 @@ static int mov_write_mdta_hdlr_tag(AVIOContext *pb, 
MOVMuxContext *mov,
     return 33;
 }
 
+/* Without use_metadata_tags, only keys that have no udta equivalent */
+static int mov_mdta_key_wanted(const MOVMuxContext *mov, const char *key)
+{
+    return (mov->flags & FF_MOV_FLAG_USE_MDTA) ||
+           av_strstart(key, "com.apple.quicktime.", NULL);
+}
+
 static int mov_write_mdta_keys_tag(AVIOContext *pb, MOVMuxContext *mov,
                                    AVFormatContext *s)
 {
@@ -5061,6 +5068,8 @@ static int mov_write_mdta_keys_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 
     while (t = av_dict_iterate(s->metadata, t)) {
         size_t key_len = strlen(t->key);
+        if (!mov_mdta_key_wanted(mov, t->key))
+            continue;
         avio_wb32(pb, key_len + 8);
         ffio_wfourcc(pb, "mdta");
         avio_write(pb, t->key, key_len);
@@ -5086,6 +5095,8 @@ static int mov_write_mdta_ilst_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 
     while (t = av_dict_iterate(s->metadata, t)) {
         int64_t entry_pos = avio_tell(pb);
+        if (!mov_mdta_key_wanted(mov, t->key))
+            continue;
         avio_wb32(pb, 0); /* size */
         avio_wb32(pb, count); /* key */
         mov_write_string_data_tag(pb, t->value, 0, 1);
@@ -5099,9 +5110,13 @@ static int mov_write_mdta_ilst_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 static int mov_write_mdta_meta_tag(AVIOContext *pb, MOVMuxContext *mov,
                                    AVFormatContext *s)
 {
+    const AVDictionaryEntry *t = NULL;
     int64_t pos = avio_tell(pb);
 
-    if (!(mov->flags & FF_MOV_FLAG_USE_MDTA) || !av_dict_count(s->metadata))
+    while ((t = av_dict_iterate(s->metadata, t)) &&
+           !mov_mdta_key_wanted(mov, t->key))
+        ;
+    if (!t)
         return 0;
 
     avio_wb32(pb, 0); /* size */
diff --git a/tests/ref/fate/autorotate b/tests/ref/fate/autorotate
index da067bb885f..3c633bc8cd3 100644
--- a/tests/ref/fate/autorotate
+++ b/tests/ref/fate/autorotate
@@ -1,5 +1,5 @@
-bf81f4500608ee48f8be81d391bed452 *tests/data/fate/autorotate.mov
-153258 tests/data/fate/autorotate.mov
+544adec3dae96ac971d304ae5091dd3b *tests/data/fate/autorotate.mov
+153688 tests/data/fate/autorotate.mov
 #extradata 0:       34, 0x9d7d073f
 #tb 0: 1/15360
 #media_type 0: video
diff --git a/tests/ref/fate/copy-trac236 b/tests/ref/fate/copy-trac236
index 187d5989002..093fcbd2635 100644
--- a/tests/ref/fate/copy-trac236
+++ b/tests/ref/fate/copy-trac236
@@ -1,5 +1,5 @@
-1aba24bd0b58133d3c59bccde9daad08 *tests/data/fate/copy-trac236.mov
-630918 tests/data/fate/copy-trac236.mov
+7ab2c9c094d6521ef686e0150dfeb56a *tests/data/fate/copy-trac236.mov
+632020 tests/data/fate/copy-trac236.mov
 #tb 0: 100/2997
 #media_type 0: video
 #codec_id 0: rawvideo
diff --git a/tests/ref/fate/ffmpeg-side-data-bsf-keep-stream 
b/tests/ref/fate/ffmpeg-side-data-bsf-keep-stream
index b22eb1e90a7..d2f5aa49164 100644
--- a/tests/ref/fate/ffmpeg-side-data-bsf-keep-stream
+++ b/tests/ref/fate/ffmpeg-side-data-bsf-keep-stream
@@ -1,5 +1,5 @@
-5e6354ce54a9c6e031beee981a3befbd 
*tests/data/fate/ffmpeg-side-data-bsf-keep-stream.mov
-61851 tests/data/fate/ffmpeg-side-data-bsf-keep-stream.mov
+2c8c00f8b07c24e5c05a82a06e465b2b 
*tests/data/fate/ffmpeg-side-data-bsf-keep-stream.mov
+62281 tests/data/fate/ffmpeg-side-data-bsf-keep-stream.mov
 #extradata 0:       29, 0x757e07f6
 #tb 0: 1/19200
 #media_type 0: video
diff --git a/tests/ref/fate/ffmpeg-side-data-bsf-remove-stream 
b/tests/ref/fate/ffmpeg-side-data-bsf-remove-stream
index 9d9ad4b2f5b..6c611c47f78 100644
--- a/tests/ref/fate/ffmpeg-side-data-bsf-remove-stream
+++ b/tests/ref/fate/ffmpeg-side-data-bsf-remove-stream
@@ -1,5 +1,5 @@
-7c5b0bf7edaabe9d5267a69d2261cf00 
*tests/data/fate/ffmpeg-side-data-bsf-remove-stream.mov
-61851 tests/data/fate/ffmpeg-side-data-bsf-remove-stream.mov
+3ad21d78f93291e973869e4af9e4c29a 
*tests/data/fate/ffmpeg-side-data-bsf-remove-stream.mov
+62281 tests/data/fate/ffmpeg-side-data-bsf-remove-stream.mov
 #extradata 0:       29, 0x757e07f6
 #tb 0: 1/19200
 #media_type 0: video
diff --git a/tests/ref/fate/filter-meta-4560-rotate0 
b/tests/ref/fate/filter-meta-4560-rotate0
index 8606137e454..6d1f71ac531 100644
--- a/tests/ref/fate/filter-meta-4560-rotate0
+++ b/tests/ref/fate/filter-meta-4560-rotate0
@@ -1,5 +1,5 @@
-796b09d860affeeed44b95d622c214f1 *tests/data/fate/filter-meta-4560-rotate0.mov
-347425 tests/data/fate/filter-meta-4560-rotate0.mov
+6d1b2a5878da663f9f4e46ebad50b34e *tests/data/fate/filter-meta-4560-rotate0.mov
+347855 tests/data/fate/filter-meta-4560-rotate0.mov
 #tb 0: 1/30
 #media_type 0: video
 #codec_id 0: rawvideo
diff --git a/tests/ref/lavf-fate/mv_hevc.mov b/tests/ref/lavf-fate/mv_hevc.mov
index 9918c4cdc5f..df83e3a5861 100644
--- a/tests/ref/lavf-fate/mv_hevc.mov
+++ b/tests/ref/lavf-fate/mv_hevc.mov
@@ -1,3 +1,3 @@
-60baf7bdf2b0d8a4ceccfb0f8c6b4875 *tests/data/lavf-fate/lavf.mv_hevc.mov
-145383 tests/data/lavf-fate/lavf.mv_hevc.mov
+30811425957f1b9ada0a89eb749eed8f *tests/data/lavf-fate/lavf.mv_hevc.mov
+145978 tests/data/lavf-fate/lavf.mv_hevc.mov
 tests/data/lavf-fate/lavf.mv_hevc.mov CRC=0xb71b4938
-- 
2.54.0


From f43cb13092c5528ff8190372f00854146916f554 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Fri, 13 Nov 2026 15:22:46 -0800
Subject: [PATCH 3/5] avformat/movenc: do not write loci in mov with
 use_metadata_tags

The location key is already stored as mdta, so it was written twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavformat/movenc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 9f9e4f6a345..c3e27e079e9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5291,10 +5291,9 @@ static int mov_write_udta_tag(AVIOContext *pb, 
MOVMuxContext *mov,
         mov_write_string_metadata(s, pb_buf, "\251xyz", "location",    0);
         mov_write_string_metadata(s, pb_buf, "\251key", "keywords",    0);
         mov_write_raw_metadata_tag(s, pb_buf, "XMP_", "xmp");
-    } else {
-        /* iTunes meta data; mov writes mdta metadata in moov/meta instead */
-        if (mov->mode != MODE_MOV)
-            mov_write_meta_tag(pb_buf, mov, s);
+    } else if (mov->mode != MODE_MOV) {
+        /* iTunes meta data; mov writes its mdta metadata in moov/meta */
+        mov_write_meta_tag(pb_buf, mov, s);
         mov_write_loci_tag(s, pb_buf);
     }
 
-- 
2.54.0


From 6ad85147cbb4efd1ae93909d8f1526f6285d9b80 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Fri, 13 Nov 2026 15:48:25 -0800
Subject: [PATCH 4/5] avformat/movenc: write und as the loci language when none
 is set

A zero packed language is invalid per 3GPP TS 26.244, and readers
ignore such loci boxes. Default get_metadata_lang() to und instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavformat/movenc.c             |  4 +---
 tests/fate/mov.mak               |  6 ++++++
 tests/ref/fate/mov-loci-lang-3gp | 15 +++++++++++++++
 tests/ref/fate/mov-loci-lang-mp4 | 15 +++++++++++++++
 4 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 tests/ref/fate/mov-loci-lang-3gp
 create mode 100644 tests/ref/fate/mov-loci-lang-mp4

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c3e27e079e9..6a6330595d6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4741,8 +4741,6 @@ static int mov_write_string_data_tag(AVIOContext *pb, 
const char *data, int lang
         return size;
     } else {
         avio_wb16(pb, data_len); /* string length */
-        if (!lang)
-            lang = ff_mov_iso639_to_lang("und", 1);
         avio_wb16(pb, lang);
         avio_write(pb, data, data_len);
         return data_len + 4;
@@ -4799,7 +4797,7 @@ static AVDictionaryEntry 
*get_metadata_lang(AVFormatContext *s,
     AVDictionaryEntry *t, *t2 = NULL;
     char tag2[16];
 
-    *lang = 0;
+    *lang = ff_mov_iso639_to_lang("und", 1);
 
     if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
         return NULL;
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index bb94f66f67d..7868963e9b5 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -635,6 +635,12 @@ fate-mov-chpl-utf8: tests/data/chpl-utf8.ffmeta
 FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, COLOR_FILTER MPEG4_ENCODER 
FFMETADATA_DEMUXER TGP_MUXER MOV_DEMUXER FILE_PROTOCOL) += fate-mov-chpl-utf8
 fate-mov-chpl-utf8: CMD = run_with_temp "$(FFMPEG) -nostdin -v error 
-filter_complex color=c=black:s=2x2:r=1 -f ffmetadata -i 
$(TARGET_PATH)/tests/data/chpl-utf8.ffmeta -map_chapters 0 -frames:v 1 -c:v 
mpeg4 -threads 1 -flags +bitexact -fflags +bitexact -f 3gp -y" 
"ffprobe$(PROGSSUF)$(EXESUF) -loglevel error -bitexact -show_chapters" 3gp
 
+MOV_LOCI_LANG_OPTS = -frames:v 1 -c:v mpeg4 -threads 1 -metadata 
location=+48.8584+002.2945/Paris
+FATE_MOV_FFMPEG_FFPROBE-$(call TRANSCODE, MPEG4, MP4 MOV, LAVFI_INDEV 
COLOR_FILTER) += fate-mov-loci-lang-mp4
+fate-mov-loci-lang-mp4: CMD = transcode lavfi color=c=black:s=2x2:r=1 mp4 
"$(MOV_LOCI_LANG_OPTS)" "-c copy" "-show_entries format_tags"
+FATE_MOV_FFMPEG_FFPROBE-$(call TRANSCODE, MPEG4, TGP MOV, LAVFI_INDEV 
COLOR_FILTER) += fate-mov-loci-lang-3gp
+fate-mov-loci-lang-3gp: CMD = transcode lavfi color=c=black:s=2x2:r=1 3gp 
"$(MOV_LOCI_LANG_OPTS)" "-c copy" "-show_entries format_tags"
+
 FATE_FFMPEG += $(FATE_MOV_FFMPEG-yes)
 FATE_FFMPEG_FFPROBE += $(FATE_MOV_FFMPEG_FFPROBE-yes)
 
diff --git a/tests/ref/fate/mov-loci-lang-3gp b/tests/ref/fate/mov-loci-lang-3gp
new file mode 100644
index 00000000000..96c5753b1fd
--- /dev/null
+++ b/tests/ref/fate/mov-loci-lang-3gp
@@ -0,0 +1,15 @@
+7c2ec3375e4b649db5803cafa4c5b3bc *tests/data/fate/mov-loci-lang-3gp.3gp
+807 tests/data/fate/mov-loci-lang-3gp.3gp
+#extradata 0:       30, 0x434804d7
+#tb 0: 1/16384
+#media_type 0: video
+#codec_id 0: mpeg4
+#dimensions 0: 2x2
+#sar 0: 1/1
+0,          0,          0,    16384,       17, 0x13820331
+[FORMAT]
+TAG:major_brand=3gp4
+TAG:minor_version=512
+TAG:compatible_brands=3gp4isomiso2
+TAG:location=+48.8584+002.2945/Paris
+[/FORMAT]
diff --git a/tests/ref/fate/mov-loci-lang-mp4 b/tests/ref/fate/mov-loci-lang-mp4
new file mode 100644
index 00000000000..93f2b562f4e
--- /dev/null
+++ b/tests/ref/fate/mov-loci-lang-mp4
@@ -0,0 +1,15 @@
+f909673b563f8bc2b9a729b0fce68db6 *tests/data/fate/mov-loci-lang-mp4.mp4
+880 tests/data/fate/mov-loci-lang-mp4.mp4
+#extradata 0:       30, 0x434804d7
+#tb 0: 1/16384
+#media_type 0: video
+#codec_id 0: mpeg4
+#dimensions 0: 2x2
+#sar 0: 1/1
+0,          0,          0,    16384,       17, 0x13820331
+[FORMAT]
+TAG:major_brand=isom
+TAG:minor_version=512
+TAG:compatible_brands=isomiso2mp41
+TAG:location=+48.8584+002.2945/Paris
+[/FORMAT]
-- 
2.54.0


From abefbba7d44d1037e7cbc78a1f5df7077951f7f2 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Fri, 13 Nov 2026 15:24:50 -0800
Subject: [PATCH 5/5] avformat/movenc: write the QuickTime location and capture
 date in mp4

As Apple does: location as loci; capture date as date in mp4, and
with the make as iTunes tags in ipod.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavformat/movenc.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6a6330595d6..90e1b8b2f3d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4865,6 +4865,8 @@ static int mov_write_loci_tag(AVFormatContext *s, 
AVIOContext *pb)
     const char *ptr, *place = "";
     char *end;
     static const char *astronomical_body = "earth";
+    if (!t)
+        t = av_dict_get(s->metadata, "com.apple.quicktime.location.ISO6709", 
NULL, 0);
     if (!t)
         return 0;
 
@@ -4998,7 +5000,12 @@ static int mov_write_ilst_tag(AVIOContext *pb, 
MOVMuxContext *mov,
     mov_write_string_metadata(s, pb, "aART", "album_artist", 1);
     mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1);
     mov_write_string_metadata(s, pb, "\251alb", "album"    , 1);
-    mov_write_string_metadata(s, pb, "\251day", "date"     , 1);
+    /* ipod: as Apple, also write the QuickTime capture date and make */
+    if (!mov_write_string_metadata(s, pb, "\251day", "date", 1) && mov->mode 
== MODE_IPOD)
+        mov_write_string_metadata(s, pb, "\251day", 
"com.apple.quicktime.creationdate", 1);
+    if (mov->mode == MODE_IPOD &&
+        !mov_write_string_metadata(s, pb, "\251mak", "make", 1))
+        mov_write_string_metadata(s, pb, "\251mak", 
"com.apple.quicktime.make", 1);
     if (!mov_write_string_metadata(s, pb, "\251too", "encoding_tool", 1)) {
         if (!(s->flags & AVFMT_FLAG_BITEXACT))
             mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1);
@@ -5247,6 +5254,22 @@ static int mov_write_chpl_tag(AVIOContext *pb, 
AVFormatContext *s)
     return update_size(pb, pos);
 }
 
+/* Capture date, as ISO 8601, where Apple writes it in mp4 */
+static int mov_write_date_tag(AVFormatContext *s, AVIOContext *pb)
+{
+    const AVDictionaryEntry *t = av_dict_get(s->metadata,
+                                             
"com.apple.quicktime.creationdate",
+                                             NULL, 0);
+    size_t len;
+
+    if (!t || !(len = strlen(t->value)) || len > INT_MAX - 8)
+        return 0;
+    avio_wb32(pb, len + 8);
+    ffio_wfourcc(pb, "date");
+    avio_write(pb, t->value, len);
+    return len + 8;
+}
+
 static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
                               AVFormatContext *s)
 {
@@ -5293,6 +5316,8 @@ static int mov_write_udta_tag(AVIOContext *pb, 
MOVMuxContext *mov,
         /* iTunes meta data; mov writes its mdta metadata in moov/meta */
         mov_write_meta_tag(pb_buf, mov, s);
         mov_write_loci_tag(s, pb_buf);
+        if (mov->mode == MODE_MP4)
+            mov_write_date_tag(s, pb_buf);
     }
 
     if (s->nb_chapters && !(mov->flags & FF_MOV_FLAG_DISABLE_CHPL))
-- 
2.54.0

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

Reply via email to