[FFmpeg-devel] [PATCH] segment: fix remuxing and copy metadata

Mika Raento mika.raento at elisa.fi
Mon Sep 1 19:05:44 CEST 2014


To get mpegts metadata copied when segmenting.
---
 libavformat/segment.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 1cb6454..0be77da 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -139,6 +139,15 @@ static int segment_mux_init(AVFormatContext *s)
         return AVERROR(ENOMEM);
 
     oc->oformat            = seg->oformat;
+    if (oc->oformat->priv_data_size > 0) {
+        oc->priv_data = av_mallocz(oc->oformat->priv_data_size);
+        if (!oc->priv_data)
+            return AVERROR(ENOMEM);
+        if (oc->oformat->priv_class) {
+            *(const AVClass **) oc->priv_data = oc->oformat->priv_class;
+            av_opt_set_defaults(oc->priv_data);
+        }
+    }
     oc->interrupt_callback = s->interrupt_callback;
     av_dict_copy(&oc->metadata, s->metadata, 0);
 
@@ -159,6 +168,9 @@ static int segment_mux_init(AVFormatContext *s)
             ocodec->codec_tag = 0;
         }
         st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
+        if (s->streams[i]->metadata) {
+            av_dict_copy(&st->metadata, s->streams[i]->metadata, 0);
+        }
     }
 
     return 0;
@@ -220,8 +232,10 @@ static int segment_start(AVFormatContext *s, int write_header)
         return err;
     }
 
-    if (oc->oformat->priv_class && oc->priv_data)
-        av_opt_set(oc->priv_data, "resend_headers", "1", 0); /* mpegts specific */
+    if (oc->oformat->priv_class && oc->priv_data) {
+        av_log(s, AV_LOG_VERBOSE, "setting mpegts resend_headers\n");
+        av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0);
+    }
 
     if (write_header) {
         if ((err = avformat_write_header(oc, NULL)) < 0)
-- 
1.8.5.2 (Apple Git-48)



More information about the ffmpeg-devel mailing list