From db9aacd530340e44e3202c2aeba0ee18f6b09fe5 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Wed, 20 Mar 2024 09:07:15 +0100 Subject: [PATCH 01/16] mov: read 'name' track tag written by movenc. --- libavformat/mov.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 8d1135270c..e91da339ee 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -337,6 +337,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL; int raw = 0; int num = 0; + AVDictionary *metadata; switch (atom.type) { case MKTAG( '@','P','R','M'): key = "premiere_version"; raw = 1; break; @@ -369,6 +370,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) return mov_metadata_loci(c, pb, atom.size); case MKTAG( 'm','a','n','u'): key = "make"; break; case MKTAG( 'm','o','d','l'): key = "model"; break; + case MKTAG( 'n','a','m','e'): key = "title"; raw = 1; break; case MKTAG( 'p','c','s','t'): key = "podcast"; parse = mov_metadata_int8_no_padding; break; case MKTAG( 'p','g','a','p'): key = "gapless_playback"; @@ -554,17 +556,23 @@ retry: } str[str_size] = 0; } - c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; - av_dict_set(&c->fc->metadata, key, str, 0); + if (c->trak_index < 0) { + metadata = c->fc->metadata; + c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; + if (!strcmp(key, "encoder")) { + int major, minor, micro; + if (sscanf(str, "HandBrake %d.%d.%d", &major, &minor, µ) == 3) { + c->handbrake_version = 1000000*major + 1000*minor + micro; + } + } + } + else { + metadata = c->fc->streams[c->trak_index]->metadata; + } + av_dict_set(&metadata, key, str, 0); if (*language && strcmp(language, "und")) { snprintf(key2, sizeof(key2), "%s-%s", key, language); - av_dict_set(&c->fc->metadata, key2, str, 0); - } - if (!strcmp(key, "encoder")) { - int major, minor, micro; - if (sscanf(str, "HandBrake %d.%d.%d", &major, &minor, µ) == 3) { - c->handbrake_version = 1000000*major + 1000*minor + micro; - } + av_dict_set(&metadata, key2, str, 0); } } -- 2.39.3 (Apple Git-146)