From 00831fdb612dab9bd98f64573a9d442e0eef2125 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 24 Feb 2024 15:05:00 +0000 Subject: [PATCH] Use precise durations for segment splits (needed in hardware transcode mode) --- transcoder/src/stream.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/transcoder/src/stream.go b/transcoder/src/stream.go index 3965c0d0..2561a033 100644 --- a/transcoder/src/stream.go +++ b/transcoder/src/stream.go @@ -218,9 +218,10 @@ func (ts *Stream) run(start int32) error { "-segment_time_delta", "0.2", "-segment_format", "mpegts", "-segment_times", toSegmentStr(Map(segments, func(seg float64, _ int) float64 { - // for a strange reason, -segment-times does not respects -copyts so we must - // remove the start_ref (-ss param) - return seg - start_ref + // segment_times want durations, not timestamps so we must substract the -ss param + // since we give a greater value to -ss to prevent wrong seeks but -segment_times + // needs precise segments, we use the keyframe we want to seek to as a reference. + return seg - ts.file.Keyframes[start] })), "-segment_list_type", "flat", "-segment_list", "pipe:1",