From cd7bcb9d0c12ee4e252024235cc8bbb395960118 Mon Sep 17 00:00:00 2001 From: ekisu Date: Tue, 6 Aug 2019 22:02:10 -0300 Subject: encode: set sample_aspect_ratio on AVStream struct Some libavformat muxers (e.g. matroskaenc.c) expect this field to be set on the AVStream struct, and not only in the AVCodecParameters. --- common/encode_lavc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'common/encode_lavc.c') diff --git a/common/encode_lavc.c b/common/encode_lavc.c index 213e2ba5a1..968ced280c 100644 --- a/common/encode_lavc.c +++ b/common/encode_lavc.c @@ -422,6 +422,11 @@ static struct mux_stream *encode_lavc_add_stream(struct encode_lavc_context *ctx dst->encoder_timebase = info->timebase; dst->st->time_base = info->timebase; // lavf will change this on muxer init + // Some muxers (e.g. Matroska one) expect the sample_aspect_ratio to be + // set on the AVStream. + if (info->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) + dst->st->sample_aspect_ratio = info->codecpar->sample_aspect_ratio; + if (avcodec_parameters_copy(dst->st->codecpar, info->codecpar) < 0) MP_HANDLE_OOM(0); -- cgit v1.2.3