[FFmpeg-devel] [PATCH 5/5] ffmpeg.c/ffprobe: use new metadata conversion API

Anton Khirnov anton
Sun Oct 3 21:14:26 CEST 2010


---
 ffmpeg.c  |   19 ++++---------------
 ffprobe.c |    2 +-
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 52028ba..e5b3e6c 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1935,7 +1935,6 @@ static int copy_chapters(int infile, int outfile)
 
     for (i = 0; i < is->nb_chapters; i++) {
         AVChapter *in_ch = is->chapters[i], *out_ch;
-        AVMetadataTag *t = NULL;
         int64_t ts_off   = av_rescale_q(start_time - input_files_ts_offset[infile],
                                       AV_TIME_BASE_Q, in_ch->time_base);
         int64_t rt       = (recording_time == INT64_MAX) ? INT64_MAX :
@@ -1956,8 +1955,7 @@ 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)))
-            av_metadata_set2(&out_ch->metadata, t->key, t->value, 0);
+        av_metadata_clone(&in_ch->metadata, &out_ch->metadata, os->oformat->metadata_conv, NULL, 0);
 
         os->nb_chapters++;
         os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters);
@@ -2163,7 +2161,6 @@ static int transcode(AVFormatContext **output_files,
 
     /* for each output stream, we compute the right encoding parameters */
     for(i=0;i<nb_ostreams;i++) {
-        AVMetadataTag *t = NULL;
         ost = ost_table[i];
         os = output_files[ost->file_index];
         ist = ist_table[ost->source_index];
@@ -2171,9 +2168,7 @@ 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))) {
-            av_metadata_set2(&ost->st->metadata, t->key, t->value, AV_METADATA_DONT_OVERWRITE);
-        }
+        av_metadata_clone(&ist->st->metadata, &ost->st->metadata, os->oformat->metadata_conv, NULL, 0);
 
         ost->st->disposition = ist->st->disposition;
         codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
@@ -2418,7 +2413,6 @@ static int transcode(AVFormatContext **output_files,
     for (i=0;i<nb_meta_data_maps;i++) {
         AVFormatContext *out_file;
         AVFormatContext *in_file;
-        AVMetadataTag *mtag;
 
         int out_file_index = meta_data_maps[i].out_file;
         int in_file_index = meta_data_maps[i].in_file;
@@ -2438,12 +2432,7 @@ static int transcode(AVFormatContext **output_files,
         out_file = output_files[out_file_index];
         in_file = input_files[in_file_index];
 
-
-        mtag=NULL;
-        while((mtag=av_metadata_get(in_file->metadata, "", mtag, AV_METADATA_IGNORE_SUFFIX)))
-            av_metadata_set2(&out_file->metadata, mtag->key, mtag->value, AV_METADATA_DONT_OVERWRITE);
-        av_metadata_conv(out_file, out_file->oformat->metadata_conv,
-                                    in_file->iformat->metadata_conv);
+        av_metadata_clone(&in_file->metadata, &out_file->metadata, NULL, NULL, 0);
     }
 
     /* copy chapters from the first input file that has them*/
@@ -3780,7 +3769,7 @@ static void opt_output_file(const char *filename)
             av_metadata_set2(&oc->metadata, metadata[metadata_count-1].key,
                                             metadata[metadata_count-1].value, 0);
         }
-        av_metadata_conv(oc, oc->oformat->metadata_conv, NULL);
+        av_metadata_clone(&oc->metadata, &oc->metadata, oc->oformat->metadata_conv, NULL, 0);
     }
 
     output_files[nb_output_files++] = oc;
diff --git a/ffprobe.c b/ffprobe.c
index ac908e1..97a8f6f 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -256,7 +256,7 @@ static void show_format(AVFormatContext *fmt_ctx)
                                                  unit_bit_per_second_str));
 
     if (convert_tags)
-        av_metadata_conv(fmt_ctx, NULL, fmt_ctx->iformat->metadata_conv);
+        av_metadata_clone_ctx(fmt_ctx, fmt_ctx, NULL, NULL, 0);
     while ((tag = av_metadata_get(fmt_ctx->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
         printf("TAG:%s=%s\n", tag->key, tag->value);
 
-- 
1.7.1




More information about the ffmpeg-devel mailing list