Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into benjamin/image_output
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben committed Sep 29, 2023
2 parents b41807b + 2885c36 commit 48c15e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
8 changes: 8 additions & 0 deletions pkg/config/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 1 addition & 13 deletions pkg/config/output_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions pkg/config/output_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 48c15e3

Please sign in to comment.