Fix keyframes i-frame type on hardware transcode

This commit is contained in:
Zoe Roux 2024-02-24 13:55:21 +00:00
parent 71fe10efaf
commit 9531795066
2 changed files with 10 additions and 0 deletions

View File

@ -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,

View File

@ -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