[FFmpeg-devel] [PATCH 1/3] avformat/hlsenc: move number out of hls_start

Steven Liu lq at chinaffmpeg.org
Fri May 8 13:33:57 EEST 2020


Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/hlsenc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a1eddade7b..bcc67b1159 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1679,7 +1679,6 @@ static int hls_start(AVFormatContext *s, VariantStream *vs)
             ff_format_set_url(vtt_oc, filename);
        }
     }
-    vs->number++;
 
     proto = avio_find_protocol_name(oc->url);
     use_temp_file = proto && !strcmp(proto, "file") && (c->flags & HLS_TEMP_FILE);
@@ -2515,7 +2514,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
 
         if (hls->flags & HLS_SINGLE_FILE) {
-            vs->number++;
             vs->start_pos += vs->size;
         } else if (hls->max_seg_size > 0) {
             vs->start_pos = new_start_pos;
@@ -2526,14 +2524,13 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
                 vs->start_pos = 0;
                 /* When split segment by byte, the duration is short than hls_time,
                  * so it is not enough one segment duration as hls_time, */
-                vs->number--;
             }
-            vs->number++;
         } else {
             vs->start_pos = new_start_pos;
             sls_flag_file_rename(hls, vs, old_filename);
             ret = hls_start(s, vs);
         }
+        vs->number++;
         av_freep(&old_filename);
 
         if (ret < 0) {
@@ -3028,6 +3025,7 @@ static int hls_init(AVFormatContext *s)
 
         if ((ret = hls_start(s, vs)) < 0)
             goto fail;
+        vs->number++;
     }
 
 fail:
-- 
2.25.0





More information about the ffmpeg-devel mailing list