[FFmpeg-devel] [PATCH 1/1] avformat/hlsenc: Fix bug on start_pts

Hongcheng Zhong sj.hc_Zhong at sjtu.edu.cn
Sun May 16 11:59:39 EEST 2021


From: spartazhc <spartazhc at gmail.com>

This patch fixes Bug #9237
In some bitstream, pts of some video packet can be N/A, which will set
start_pts to AV_NOPTS_VALUE. Adding an if condition can fix it.

Signed-off-by: spartazhc <spartazhc at gmail.com>
---
 libavformat/hlsenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 5db7a744b4..fd265d0ffd 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2446,7 +2446,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
         if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
             vs->start_pts_from_audio = 1;
     }
-    if (vs->start_pts_from_audio && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && vs->start_pts > pkt->pts) {
+    if (vs->start_pts_from_audio && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
+        && vs->start_pts > pkt->pts && pkt->pts != AV_NOPTS_VALUE) {
         vs->start_pts = pkt->pts;
         vs->start_pts_from_audio = 0;
     }
-- 
2.31.1



More information about the ffmpeg-devel mailing list