From 81eec081afea9fc017a175581ceea7c420a0dfc3 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 18 May 2014 13:49:46 +0200 Subject: matroskaenc: base DefaultDuration on the framerate, not the codec timebase This results in DefaultDuration not being written when the framerate is not known, but as this field is purely informative, this should not break any sane demuxers. --- libavformat/matroskaenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libavformat/matroskaenc.c') diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index f2b9ee91af..0a3775daea 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -676,7 +676,8 @@ static int mkv_write_tracks(AVFormatContext *s) switch (codec->codec_type) { case AVMEDIA_TYPE_VIDEO: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO); - put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, av_q2d(codec->time_base)*1E9); + if (st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0) + put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1E9 / av_q2d(st->avg_frame_rate)); if (!native_id && ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id) && -- cgit v1.2.3