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

Anton Khirnov wyskas
Thu Mar 18 20:54:14 CET 2010


Metadata is copied from the first input file with at least one tag to
all output files.
---
 ffmpeg.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 5a22dde..a04f052 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2175,6 +2175,26 @@ static int av_encode(AVFormatContext **output_files,
                                     in_file->iformat->metadata_conv);
     }
 
+    if (!nb_meta_data_maps) {
+        for (i = 0; i < nb_input_files; i++) {
+            is = input_files[i];
+
+            if (!av_metadata_get(is->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
+                continue;
+
+            for (j = 0; j < nb_output_files; j++) {
+                AVMetadataTag *t = NULL;
+
+                os = output_files[j];
+                while ((t = av_metadata_get(is->metadata, "", t,
+                                            AV_METADATA_IGNORE_SUFFIX)))
+                    av_metadata_set2(&os->metadata, t->key, t->value, 0);
+                av_metadata_conv(os, os->oformat->metadata_conv,
+                                 is->iformat->metadata_conv);
+            }
+        }
+    }
+
     /* copy chapters from the first input file that has them*/
     for (i = 0; i < nb_input_files; i++) {
         if (!input_files[i]->nb_chapters)
-- 
1.7.0




More information about the ffmpeg-devel mailing list