Skip to content

Commit 66b2f07

Browse files
committed
Make it work with discontinuities.
1 parent 2a95c68 commit 66b2f07

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/outputs/hls_output.ml

+9-5
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ type stream = {
158158
codecs : string Lazy.t; (** codecs (see RFC 6381) *)
159159
extname : string;
160160
mutable init_state : init_state;
161+
mutable init_position : int;
161162
mutable position : int;
162163
mutable current_segment : segment option;
163164
mutable discontinuity_count : int;
@@ -346,7 +347,8 @@ class hls_output p =
346347
video_size;
347348
extname;
348349
init_state = `Todo;
349-
position = 0;
350+
init_position = 0;
351+
position = 1;
350352
current_segment = None;
351353
discontinuity_count = 0;
352354
}
@@ -607,19 +609,21 @@ class hls_output p =
607609
(fun stream (name, pos, discontinuity_count) ->
608610
assert (name = stream.name);
609611
stream.discontinuity_count <- discontinuity_count;
610-
stream.position <- pos)
612+
stream.init_position <- pos;
613+
stream.position <- pos + 1)
611614
streams p;
612615
segments <- s
613616

614-
method private process_init ~init ({ extname; name; position } as s) =
617+
method private process_init ~init ({ extname; name; init_position } as s) =
615618
match init with
616619
| None -> s.init_state <- `No_init
617620
| Some data ->
618-
let init_filename = segment_name ~position ~extname name in
621+
let init_filename =
622+
segment_name ~position:init_position ~extname name
623+
in
619624
let oc = self#open_out init_filename in
620625
Strings.iter (output_substring oc) data;
621626
self#close_out ~filename:init_filename oc;
622-
s.position <- s.position + 1;
623627
s.init_state <- `Has_init init_filename
624628

625629
method encode frame ofs len =

0 commit comments

Comments
 (0)