From 774c6cd9cfa948320a2dbd6ac9435e04db161a29 Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Fri, 15 Sep 2023 12:20:00 -0700 Subject: [PATCH] Fix output bin for audio only segmented output --- pkg/pipeline/builder/segment.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pkg/pipeline/builder/segment.go b/pkg/pipeline/builder/segment.go index db1e3997..8370a7a8 100644 --- a/pkg/pipeline/builder/segment.go +++ b/pkg/pipeline/builder/segment.go @@ -36,9 +36,17 @@ func BuildSegmentBin(pipeline *gstreamer.Pipeline, p *config.PipelineConfig) (*g b := pipeline.NewBin("segment") o := p.GetSegmentConfig() - h264parse, err := gst.NewElement("h264parse") - if err != nil { - return nil, err + var h264parse *gst.Element + var err error + if p.VideoEnabled { + h264parse, err = gst.NewElement("h264parse") + if err != nil { + return nil, err + } + + if err = b.AddElements(h264parse); err != nil { + return nil, errors.ErrGstPipelineError(err) + } } sink, err := gst.NewElement("splitmuxsink") @@ -91,15 +99,18 @@ func BuildSegmentBin(pipeline *gstreamer.Pipeline, p *config.PipelineConfig) (*g return nil, errors.ErrGstPipelineError(err) } - if err = b.AddElements(h264parse, sink); err != nil { + if err = b.AddElements(sink); err != nil { return nil, errors.ErrGstPipelineError(err) } b.SetGetSrcPad(func(name string) *gst.Pad { if name == "audio" { return sink.GetRequestPad("audio_%u") - } else { + } else if h264parse != nil { return h264parse.GetStaticPad("sink") + } else { + // Should never happen + return nil } })