diff mbox

[FFmpeg-devel] Fixed corrupt segment video files when using hls_init_time option.

Message ID 20190328234851.2223-1-atomantinator@gmail.com
State New
Headers show

Commit Message

atomantinator@gmail.com March 28, 2019, 11:48 p.m. UTC
The problem is an integer overflow on "after_init_list_dur" variable.
It happens about 30-40 minutes after starts hls streaming but strongly depends on other options like "start_number" or "hls_list_size".
VOD or EVENT hls playlist types are not affected by this bug.

(P.S. I hope this text will be the body and not the subject :) )
---
 libavformat/hlsenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Moritz Barsnick March 29, 2019, 9:59 a.m. UTC | #1
On Thu, Mar 28, 2019 at 16:48:51 -0700, Laszlo Kovacs wrote:
> (P.S. I hope this text will be the body and not the subject :) )
> ---
>  libavformat/hlsenc.c | 5 +++--

This time, the text is in the correct position. ;-) (Yes, you need an
empty line between what lands in the subject and what lands in the
body.

But your P.S. remark belongs below the "---" line, and not into the
commit message.

Cheers,
Moritz
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 5f9a200c6e..2e8bcab571 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2195,8 +2195,9 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
 
     if (vs->sequence - vs->nb_entries > hls->start_sequence && hls->init_time > 0) {
         /* reset end_pts, hls->recording_time at end of the init hls list */
-        int init_list_dur = hls->init_time * vs->nb_entries * AV_TIME_BASE;
-        int after_init_list_dur = (vs->sequence - hls->start_sequence - vs->nb_entries ) * (hls->time * AV_TIME_BASE);
+        int64_t init_list_dur = hls->init_time * vs->nb_entries * AV_TIME_BASE;
+        int64_t after_init_list_dur = hls->time * AV_TIME_BASE;
+        after_init_list_dur *= vs->sequence - hls->start_sequence - vs->nb_entries;
         hls->recording_time = hls->time * AV_TIME_BASE;
         end_pts = init_list_dur + after_init_list_dur ;
     }