diff --git a/pkg/config/output.go b/pkg/config/output.go index f2262c79..d6ce31c4 100644 --- a/pkg/config/output.go +++ b/pkg/config/output.go @@ -162,6 +162,14 @@ func (p *PipelineConfig) updateEncodedOutputs(req EncodedOutput) error { } } + if segmentConf := p.Outputs[types.EgressTypeSegments]; segmentConf != nil && len(segmentConf) > 0 { + // double the segment length + p.KeyFrameInterval = float64(2 * segmentConf[0].(*SegmentConfig).SegmentDuration) + } else if p.KeyFrameInterval == 0 && p.Outputs[types.EgressTypeStream] != nil { + // default 4s for streams + p.KeyFrameInterval = 4 + } + err := p.updateImageOutputs(req) if err != nil { return err diff --git a/pkg/config/output_segment.go b/pkg/config/output_segment.go index fb4fb689..ef173470 100644 --- a/pkg/config/output_segment.go +++ b/pkg/config/output_segment.go @@ -64,19 +64,7 @@ func (p *PipelineConfig) getSegmentConfig(segments *livekit.SegmentedFileOutput) } if conf.SegmentDuration == 0 { - if p.KeyFrameInterval >= 1 { - conf.SegmentDuration = int(p.KeyFrameInterval) - } else { - conf.SegmentDuration = 4 - } - } - - if p.KeyFrameInterval == 0 { - // The splitMuxSink should request key frames from the encoder at expected frame boundaries. - // Set the key frame interval to twice the segment duration as a failsafe - p.KeyFrameInterval = 2 * float64(conf.SegmentDuration) - } else if p.KeyFrameInterval < float64(conf.SegmentDuration) && p.KeyFrameInterval >= 1 { - conf.SegmentDuration = int(p.KeyFrameInterval) + conf.SegmentDuration = 4 } switch segments.Protocol { diff --git a/pkg/config/output_stream.go b/pkg/config/output_stream.go index 74f5f3e0..29e8dfc5 100644 --- a/pkg/config/output_stream.go +++ b/pkg/config/output_stream.go @@ -71,10 +71,5 @@ func (p *PipelineConfig) getStreamConfig(outputType types.OutputType, urls []str p.AudioOutCodec = types.MimeTypeRawAudio } - // Use a 4s default key frame interval for streaming - if p.KeyFrameInterval == 0 { - p.KeyFrameInterval = 4 - } - return conf, nil }