1 |
diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp |
2 |
index b70f921..a031ef7 100644 |
3 |
--- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp |
4 |
+++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp |
5 |
@@ -971,12 +971,23 @@ void CDVDDemuxFFmpeg::AddStream(int iId) |
6 |
if (m_bAVI && pStream->codec->codec_id == CODEC_ID_H264) |
7 |
st->bPTSInvalid = true; |
8 |
|
9 |
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 63, 0) |
10 |
//average fps is more accurate for mkv files |
11 |
if (m_bMatroska && pStream->avg_frame_rate.den && pStream->avg_frame_rate.num) |
12 |
{ |
13 |
st->iFpsRate = pStream->avg_frame_rate.num; |
14 |
st->iFpsScale = pStream->avg_frame_rate.den; |
15 |
} |
16 |
+#else |
17 |
+ // libavformat older than 2010-05-17 gets the avg wrong, use time_base instead |
18 |
+ // for H.264 (r_frame_rate is rounded up 23.976->24fps for H.264 by libavformat) |
19 |
+ if (m_bMatroska && pStream->codec->codec_id == CODEC_ID_H264 && |
20 |
+ pStream->codec->time_base.den && pStream->codec->time_base.num) |
21 |
+ { |
22 |
+ st->iFpsRate = pStream->codec->time_base.den; |
23 |
+ st->iFpsScale = pStream->codec->time_base.num * pStream->codec->ticks_per_frame; |
24 |
+ } |
25 |
+#endif |
26 |
else if(pStream->r_frame_rate.den && pStream->r_frame_rate.num) |
27 |
{ |
28 |
st->iFpsRate = pStream->r_frame_rate.num; |