Commit 42934647 authored by ChanMin Kim's avatar ChanMin Kim Committed by 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: 's avatarChanMin Kim <kcm1700@gmail.com>
Signed-off-by: 's avatarStefano Sabatini <stefasab@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 6253cee4
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment