diff mbox series

[FFmpeg-devel] avformat/hlsenc: process hls_time value too small sence

Message ID 20200818024411.31718-1-lq@chinaffmpeg.org
State Accepted
Commit a424671e4f1beccca5a5958add86b69eb4fe8da7
Headers show
Series [FFmpeg-devel] avformat/hlsenc: process hls_time value too small sence | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Liu Steven Aug. 18, 2020, 2:44 a.m. UTC
The target duration will be a negative value when there are
some b frames after prevous frame, the pts after current packet
is large than the pts of current packet, so the target duration
will compute as 0.040000 - 0.080000, then the value of the target
duration will be -0.040000. so hls muxer should check the pts after
current packet minus the pts of current packet, hls muxer can split
the stream as a segment if the target duration is neither negative nor
zero, hls muxer cannot split the stream as a segment if the
target duration is either negative or zero then get the next packet
until the target duration is not negative or zero.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Suggested-by: Zhili Zhao <quinkblack@foxmail.com>
---
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Liu Oct. 20, 2020, 3:42 a.m. UTC | #1
Steven Liu <lq@chinaffmpeg.org> 于2020年8月18日周二 上午10:44写道:
>
> The target duration will be a negative value when there are
> some b frames after prevous frame, the pts after current packet
> is large than the pts of current packet, so the target duration
> will compute as 0.040000 - 0.080000, then the value of the target
> duration will be -0.040000. so hls muxer should check the pts after
> current packet minus the pts of current packet, hls muxer can split
> the stream as a segment if the target duration is neither negative nor
> zero, hls muxer cannot split the stream as a segment if the
> target duration is either negative or zero then get the next packet
> until the target duration is not negative or zero.
>
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> Suggested-by: Zhili Zhao <quinkblack@foxmail.com>
> ---
>  libavformat/hlsenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index cb31d6aed7..4471858222 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -2398,9 +2398,9 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
>                  vs->duration = (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den;
>              }
>          }
> -
>      }
>
> +    can_split = can_split && (pkt->pts - vs->end_pts > 0);
>      if (vs->packets_written && can_split && av_compare_ts(pkt->pts - vs->start_pts, st->time_base,
>                                                            end_pts, AV_TIME_BASE_Q) >= 0) {
>          int64_t new_start_pos;
> --
> 2.25.0
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

pushed


Thanks
Steven
diff mbox series

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cb31d6aed7..4471858222 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2398,9 +2398,9 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
                 vs->duration = (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den;
             }
         }
-
     }
 
+    can_split = can_split && (pkt->pts - vs->end_pts > 0);
     if (vs->packets_written && can_split && av_compare_ts(pkt->pts - vs->start_pts, st->time_base,
                                                           end_pts, AV_TIME_BASE_Q) >= 0) {
         int64_t new_start_pos;