[FFmpeg-devel] [PATCH 4/4] ffmpeg.c: don't autocopy stream/chapter metadata if manual mapping is specified

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


---
 ffmpeg.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 0acdb4d..338b0d7 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -129,6 +129,8 @@ static int nb_stream_maps;
 static AVMetaDataMap (*meta_data_maps)[2] = NULL;
 static int nb_meta_data_maps;
 static int metadata_global_autocopy = 1;
+static int metadata_streams_autocopy  = 1;
+static int metadata_chapters_autocopy = 1;
 
 /* indexed by output file stream index */
 static int *streamid_map = NULL;
@@ -1836,7 +1838,8 @@ static int copy_chapters(int infile, int outfile)
         out_ch->start     = FFMAX(0,  in_ch->start - ts_off);
         out_ch->end       = FFMIN(rt, in_ch->end   - ts_off);
 
-        while ((t = av_metadata_get(in_ch->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
+        while (metadata_chapters_autocopy &&
+               (t = av_metadata_get(in_ch->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
             av_metadata_set2(&out_ch->metadata, t->key, t->value, 0);
 
         os->nb_chapters++;
@@ -2065,7 +2068,8 @@ static int transcode(AVFormatContext **output_files,
         codec = ost->st->codec;
         icodec = ist->st->codec;
 
-        while ((t = av_metadata_get(ist->st->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
+        while (metadata_streams_autocopy &&
+               (t = av_metadata_get(ist->st->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
             av_metadata_set2(&ost->st->metadata, t->key, t->value, AV_METADATA_DONT_OVERWRITE);
         }
 
@@ -2955,6 +2959,10 @@ static void opt_map_meta_data(const char *arg)
 
     if (m->type == 'g' || m1->type == 'g')
         metadata_global_autocopy = 0;
+    if (m->type == 's' || m1->type == 's')
+        metadata_streams_autocopy = 0;
+    if (m->type == 'c' || m1->type == 'c')
+        metadata_chapters_autocopy = 0;
 }
 
 static void opt_input_ts_scale(const char *arg)
-- 
1.7.1




More information about the ffmpeg-devel mailing list