[FFmpeg-cvslog] lavf/segment: do not copy codec_tag when not available

ChanMin Kim git at videolan.org
Tue Nov 20 19:20:16 CET 2012


ffmpeg | branch: master | ChanMin Kim <kcm1700 at gmail.com> | Sat Nov 17 17:39:51 2012 +0100| [4293464705d01ddd47b52822d0a0f1021895bc30] | committer: Michael Niedermayer

lavf/segment: do not copy codec_tag when not available

Some muxers do not allow stream if codec_tag is incompatible.

Sometimes the passed input codec's codec_tag is not compatible with the
output muxer.

Because the codec_tag field of the segment muxer cannot be set, ffmpeg.c
doesn't know how to handle these cases.

Signed-off-by: ChanMin Kim <kcm1700 at gmail.com>
Signed-off-by: Stefano Sabatini <stefasab at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4293464705d01ddd47b52822d0a0f1021895bc30
---

 libavformat/segment.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index f31b25f..339f968 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -108,9 +108,20 @@ static int segment_mux_init(AVFormatContext *s)
 
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st;
+        AVCodecContext *icodec, *ocodec;
+
         if (!(st = avformat_new_stream(oc, NULL)))
             return AVERROR(ENOMEM);
-        avcodec_copy_context(st->codec, s->streams[i]->codec);
+        icodec = s->streams[i]->codec;
+        ocodec = st->codec;
+        avcodec_copy_context(ocodec, icodec);
+        if (!oc->oformat->codec_tag ||
+            av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == ocodec->codec_id ||
+            av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0) {
+            ocodec->codec_tag = icodec->codec_tag;
+        } else {
+            ocodec->codec_tag = 0;
+        }
         st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
     }
 



More information about the ffmpeg-cvslog mailing list