[FFmpeg-cvslog] hlsenc: Remove bogus check for if (vs->start_pos) for appending segments

Martin Storsjö git at videolan.org
Thu Jul 4 23:35:38 EEST 2024


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Jun 26 13:51:05 2024 +0300| [a50b8bb7cd92761043a62590958c9d570c756f30] | committer: Martin Storsjö

hlsenc: Remove bogus check for if (vs->start_pos) for appending segments

Previously, vs->start_pos was never 0 here, unless using the
-hls_segment_size option, which wasn't allowed for SEGMENT_TYPE_FMP4.
Therefore, this if statement was practically always taken anyway.

Remove this bogus if statement, to allow changing vs->start_pos
to reflect the right value when not using the -hls_segment_size
option.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a50b8bb7cd92761043a62590958c9d570c756f30
---

 libavformat/hlsenc.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0c72774e29..e9aff1d0f7 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2504,6 +2504,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
                                                           end_pts, AV_TIME_BASE_Q) >= 0) {
         int64_t new_start_pos;
         int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0);
+        double cur_duration;
 
         av_write_frame(oc, NULL); /* Flush any buffered data */
         new_start_pos = avio_tell(oc->pb);
@@ -2609,15 +2610,13 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
             return AVERROR(ENOMEM);
         }
 
-        if (vs->start_pos || hls->segment_type != SEGMENT_TYPE_FMP4) {
-            double cur_duration =  (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den;
-            ret = hls_append_segment(s, hls, vs, cur_duration, vs->start_pos, vs->size);
-            vs->end_pts = pkt->pts;
-            vs->duration = 0;
-            if (ret < 0) {
-                av_freep(&old_filename);
-                return ret;
-            }
+        cur_duration = (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den;
+        ret = hls_append_segment(s, hls, vs, cur_duration, vs->start_pos, vs->size);
+        vs->end_pts = pkt->pts;
+        vs->duration = 0;
+        if (ret < 0) {
+            av_freep(&old_filename);
+            return ret;
         }
 
         // if we're building a VOD playlist, skip writing the manifest multiple times, and just wait until the end



More information about the ffmpeg-cvslog mailing list