mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-02 21:24:20 -04:00
Switch to -f hls
This commit is contained in:
parent
5bdc5d15bf
commit
3de97d2b1f
@ -255,23 +255,24 @@ func (ts *Stream) run(start int32) error {
|
|||||||
)
|
)
|
||||||
args = append(args, ts.handle.getTranscodeArgs(toSegmentStr(segments))...)
|
args = append(args, ts.handle.getTranscodeArgs(toSegmentStr(segments))...)
|
||||||
args = append(args,
|
args = append(args,
|
||||||
"-f", "segment",
|
"-f", "hls",
|
||||||
// needed for rounding issues when forcing keyframes
|
// we can't list cut times w/ hls but
|
||||||
// recommended value is 1/(2*frame_rate), which for a 24fps is ~0.021
|
// - -hls_time will be cut on the next key frame after the time has passed
|
||||||
// we take a little bit more than that to be extra safe but too much can be harmfull
|
// - we specify keyframes in transcode with -force_key_frames
|
||||||
// when segments are short (can make the video repeat itself)
|
// - we know keyframes time of the transmux stream
|
||||||
"-segment_time_delta", "0.05",
|
// to unsure we don't have issues, the keyframe retriver needs to ignore
|
||||||
"-segment_format", "mpegts",
|
// sequentials keyframes closer than OptimalFragmentDuration.
|
||||||
"-segment_times", toSegmentStr(Map(segments, func(seg float64, _ int) float64 {
|
//
|
||||||
// segment_times want durations, not timestamps so we must substract the -ss param
|
// audio is simpler since we always cut at OptimalFragmentDuration
|
||||||
// since we give a greater value to -ss to prevent wrong seeks but -segment_times
|
"-hls_time", fmt.Sprint(OptimalFragmentDuration),
|
||||||
// needs precise segments, we use the keyframe we want to seek to as a reference.
|
"-start_number", fmt.Sprint(start_segment),
|
||||||
return seg - ts.keyframes.Get(start_segment)
|
"-hls_segment_type", "mpegts",
|
||||||
})),
|
"-hls_segment_filename", fmt.Sprintf("%s/%s", outpath, fmt.Sprintf(SegmentNameFormat, encoder_id)),
|
||||||
"-segment_list_type", "flat",
|
// Make the playlist easier to parse in our program by only outputing 1 segment and no endlist marker
|
||||||
"-segment_list", "pipe:1",
|
// anyways this list is only read once and we generate our own.
|
||||||
"-segment_start_number", fmt.Sprint(start_segment),
|
"-hls_list_size", "1",
|
||||||
outpath,
|
"-hls_flags", "omit_endlist",
|
||||||
|
"-",
|
||||||
)
|
)
|
||||||
|
|
||||||
cmd := exec.Command("ffmpeg", args...)
|
cmd := exec.Command("ffmpeg", args...)
|
||||||
@ -298,8 +299,14 @@ func (ts *Stream) run(start int32) error {
|
|||||||
should_stop := false
|
should_stop := false
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
line := scanner.Text()
|
||||||
|
// ignore m3u8 infos, we only want to know when segments are ready.
|
||||||
|
if line[0] == '#' {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
var segment int32
|
var segment int32
|
||||||
_, _ = fmt.Sscanf(scanner.Text(), format, &segment)
|
_, _ = fmt.Sscanf(line, format, &segment)
|
||||||
|
|
||||||
if segment < start {
|
if segment < start {
|
||||||
// This happen because we use -f segments for accurate cutting (since -ss is not)
|
// This happen because we use -f segments for accurate cutting (since -ss is not)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user