diff --git a/transcoder/src/stream.go b/transcoder/src/stream.go index 962fd6ff..0b9d1fd6 100644 --- a/transcoder/src/stream.go +++ b/transcoder/src/stream.go @@ -207,6 +207,12 @@ func (ts *Stream) run(start int32) error { "-start_at_zero", // for hls streams, -copyts is mandatory "-copyts", + // this makes output file start at 0s instead of a random delay + the -ss value + // this also cancel -start_at_zero weird delay. + // this is not always respected but generally it gives better results. + // even when this is not respected, it does not result in a bugged experience but this is something + // to keep in mind when debugging + "-muxdelay", "0", ) args = append(args, ts.handle.getTranscodeArgs(toSegmentStr(segments))...) args = append(args, diff --git a/transcoder/src/videostream.go b/transcoder/src/videostream.go index 7f7ddd6e..0ba323e4 100644 --- a/transcoder/src/videostream.go +++ b/transcoder/src/videostream.go @@ -63,7 +63,11 @@ func (vs *VideoStream) getTranscodeArgs(segments string) []string { "-b:v", fmt.Sprint(vs.quality.AverageBitrate()), "-maxrate", fmt.Sprint(vs.quality.MaxBitrate()), // Force segments to be split exactly on keyframes (only works when transcoding) + // forced-idr is needed to force keyframes to be an idr-frame (by default it can be any i frames) + // without this option, some hardware encoders uses others i-frames and the -f segment can't cut at them. + "-forced-idr", "1", "-force_key_frames", segments, + // make ffmpeg globaly less buggy "-strict", "-2", ) return args