[FFmpeg-devel] avformat/mpegts: index only keyframes to ensure accurate seeks

Submitted by Aman Gupta on May 7, 2019, 3:26 a.m.

Details

Message ID 20190507032623.80375-1-ffmpeg@tmm1.net
State New
Headers show

Commit Message

Aman Gupta May 7, 2019, 3:26 a.m.
From: Aman Gupta <aman@tmm1.net>

Signed-off-by: Aman Gupta <aman@tmm1.net>
---
 libavformat/mpegts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8a84e5cc19..49e282903c 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -3198,9 +3198,9 @@  static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
         ret = av_read_frame(s, &pkt);
         if (ret < 0)
             return AV_NOPTS_VALUE;
-        if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0) {
+        if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0 && (pkt.flags & AV_PKT_FLAG_KEY)) {
             ff_reduce_index(s, pkt.stream_index);
-            av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
+            av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME);
             if (pkt.stream_index == stream_index && pkt.pos >= *ppos) {
                 int64_t dts = pkt.dts;
                 *ppos = pkt.pos;