diff mbox series

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

Message ID 20210516085939.605268-1-sj.hc_Zhong@sjtu.edu.cn
State New
Headers show
Series [FFmpeg-devel,1/1] avformat/hlsenc: Fix bug on start_pts | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Hongcheng Zhong May 16, 2021, 8:59 a.m. UTC
From: spartazhc <spartazhc@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@gmail.com>
---
 libavformat/hlsenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Lingjiang Fang May 25, 2021, 8:54 a.m. UTC | #1
On Sun, 16 May 2021 16:59:39 +0800
Hongcheng Zhong <sj.hc_Zhong@sjtu.edu.cn> wrote:

> From: spartazhc <spartazhc@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@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) {
maybe it's better put pkt->pts != AV_NOPTS_VALUE before pkt->pts !=
AV_NOPTS_VALUE ?

>          vs->start_pts = pkt->pts;
>          vs->start_pts_from_audio = 0;
>      }



Regards,
Lingjiang Fang
diff mbox series

Patch

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;
     }