aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/hlsenc.c
diff options
context:
space:
mode:
authorSteven Liu <lq@chinaffmpeg.org>2020-06-15 20:37:40 +0800
committerSteven Liu <lq@chinaffmpeg.org>2020-07-07 14:32:00 +0800
commit73fe0cbb94532aba3a0925c2fc39a4caeee2400e (patch)
tree5f887c5017140ad7c4cdb9dc90353a8c53d0e39f /libavformat/hlsenc.c
parent855d51bf481dddf425f9a82e4d1aa2cdc93c22f8 (diff)
downloadffmpeg-73fe0cbb94532aba3a0925c2fc39a4caeee2400e.tar.gz
avformat/hlsenc: check fragment size plus start_pos large than hls_segment_size
if vs->size + vs->start_pos > hls->max_seg_size, should split segment. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r--libavformat/hlsenc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 3398f0e732..df84e6487d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2390,7 +2390,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
&& (hls->flags & HLS_TEMP_FILE);
}
- if ((hls->max_seg_size > 0 && (vs->size >= hls->max_seg_size)) || !byterange_mode) {
+ if ((hls->max_seg_size > 0 && (vs->size + vs->start_pos >= hls->max_seg_size)) || !byterange_mode) {
AVDictionary *options = NULL;
char *filename = NULL;
if (hls->key_info_file || hls->encrypt) {
@@ -2485,14 +2485,15 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
if (hls->flags & HLS_SINGLE_FILE) {
vs->start_pos += vs->size;
} else if (hls->max_seg_size > 0) {
- vs->start_pos = new_start_pos;
- if (vs->size >= hls->max_seg_size) {
+ if (vs->size + vs->start_pos >= hls->max_seg_size) {
vs->sequence++;
sls_flag_file_rename(hls, vs, old_filename);
ret = hls_start(s, vs);
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, */
+ } else {
+ vs->start_pos = new_start_pos;
}
} else {
vs->start_pos = new_start_pos;