[FFmpeg-devel] [PATCH 3/4] ffmpeg.c: copy global metadata by default

Anton Khirnov anton
Tue Oct 26 23:38:15 CEST 2010


---
 ffmpeg.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index dad5617..0acdb4d 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -128,6 +128,7 @@ static int nb_stream_maps;
 /* first item specifies output metadata, second is input */
 static AVMetaDataMap (*meta_data_maps)[2] = NULL;
 static int nb_meta_data_maps;
+static int metadata_global_autocopy = 1;
 
 /* indexed by output file stream index */
 static int *streamid_map = NULL;
@@ -2351,6 +2352,15 @@ static int transcode(AVFormatContext **output_files,
             av_metadata_set2(meta[0], mtag->key, mtag->value, AV_METADATA_DONT_OVERWRITE);
     }
 
+    /* copy global metadata by default */
+    if (metadata_global_autocopy) {
+        AVMetadataTag *t = NULL;
+
+        while ((t = av_metadata_get(input_files[0]->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
+            for (i = 0; i < nb_output_files; i++)
+                av_metadata_set2(&output_files[i]->metadata, t->key, t->value, AV_METADATA_DONT_OVERWRITE);
+    }
+
     /* copy chapters from the first input file that has them*/
     for (i = 0; i < nb_input_files; i++) {
         if (!input_files[i]->nb_chapters)
@@ -2942,6 +2952,9 @@ static void opt_map_meta_data(const char *arg)
     m1 = &meta_data_maps[nb_meta_data_maps - 1][1];
     m1->file = strtol(p, &p, 0);
     parse_meta_type(p, &m1->type, &m1->index, &p);
+
+    if (m->type == 'g' || m1->type == 'g')
+        metadata_global_autocopy = 0;
 }
 
 static void opt_input_ts_scale(const char *arg)
-- 
1.7.1




More information about the ffmpeg-devel mailing list