From 11b06e17dcfb44233871b5d19e1dfcb531e95ba5 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Tue, 24 Oct 2023 13:04:43 +0200 Subject: [PATCH] Fix timestamp generation for MPEG-2 DVD streams (and probably others) --- decoder/LAVVideo/decoders/avcodec.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/decoder/LAVVideo/decoders/avcodec.cpp b/decoder/LAVVideo/decoders/avcodec.cpp index 38e88514a..26fca6a90 100644 --- a/decoder/LAVVideo/decoders/avcodec.cpp +++ b/decoder/LAVVideo/decoders/avcodec.cpp @@ -1513,6 +1513,9 @@ STDMETHODIMP CDecAvcodec::ConvertPixFmt(AVFrame *pFrame, LAVFrame *pOutFrame) STDMETHODIMP_(REFERENCE_TIME) CDecAvcodec::GetFrameDuration() { + if (m_pAVCtx->framerate.den && m_pAVCtx->framerate.num) + return (REF_SECOND_MULT * m_pAVCtx->framerate.den / m_pAVCtx->framerate.num); + if (m_pAVCtx->time_base.den && m_pAVCtx->time_base.num) return (REF_SECOND_MULT * m_pAVCtx->time_base.num / m_pAVCtx->time_base.den) * ((m_pAVCtx->codec_descriptor && m_pAVCtx->codec_descriptor->props & AV_CODEC_PROP_FIELDS) ? 2 : 1);