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.
This commit is contained in:
ekisu 2019-08-06 22:02:10 -03:00 committed by sfan5
parent ae8cb39ab2
commit cd7bcb9d0c
1 changed files with 5 additions and 0 deletions

View File

@ -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);