[FFmpeg-devel] avformat/mpegts: Only add keyframe index entries for keyframe packets

Submitted by fumoboy007 on Aug. 31, 2019, 10:06 a.m.

Details

Message ID 20190831100652.1598-1-fumoboy007@me.com
State New
Headers show

Commit Message

fumoboy007 Aug. 31, 2019, 10:06 a.m.
From: fumoboy007 <fumoboy007@me.com>

Signed-off-by: fumoboy007 <fumoboy007@me.com>
---
 libavformat/mpegts.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 47d8d5f877..a35ea65875 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -3201,8 +3201,11 @@  static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
         if (ret < 0)
             return AV_NOPTS_VALUE;
         if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0) {
+            int is_keyframe = (pkt.flags & AV_PKT_FLAG_KEY) != 0;
+
             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, is_keyframe ? AVINDEX_KEYFRAME : 0);
+
             if (pkt.stream_index == stream_index && pkt.pos >= *ppos) {
                 int64_t dts = pkt.dts;
                 *ppos = pkt.pos;