Archived
2
0

custom RTMP pipeline

This commit is contained in:
m1k1o 2020-09-27 12:09:45 +02:00
parent de04cac28e
commit d02617329b
3 changed files with 16 additions and 22 deletions

View File

@ -36,6 +36,7 @@ func (manager *BroadcastManager) Start() {
manager.pipeline, err = gst.CreateRTMPPipeline(
manager.remote.Device,
manager.remote.Display,
manager.config.Pipeline,
manager.url,
)

View File

@ -65,11 +65,18 @@ func init() {
}
// CreateRTMPPipeline creates a GStreamer Pipeline
func CreateRTMPPipeline(pipelineDevice string, pipelineDisplay string, pipelineRTMP string) (*Pipeline, error) {
func CreateRTMPPipeline(pipelineDevice string, pipelineDisplay string, pipelineSrc string, pipelineRTMP string) (*Pipeline, error) {
video := fmt.Sprintf(videoSrc, pipelineDisplay)
audio := fmt.Sprintf(audioSrc, pipelineDevice)
return CreatePipeline(fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s voaacenc ! mux. %s x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", pipelineRTMP, audio, video), "", 0)
var pipelineStr string
if pipelineSrc != "" {
pipelineStr = fmt.Sprintf(pipelineSrc, pipelineRTMP, pipelineDevice, pipelineDisplay)
} else {
pipelineStr = fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s ! voaacenc ! mux. %s x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", pipelineRTMP, audio, video)
}
return CreatePipeline(pipelineStr, "", 0)
}
// CreateAppPipeline creates a GStreamer Pipeline

View File

@ -6,32 +6,18 @@ import (
)
type Broadcast struct {
// Enabled bool
// AudioParams string
// VideoParams string
Pipeline string
}
func (Broadcast) Init(cmd *cobra.Command) error {
// cmd.PersistentFlags().Bool("broadcast", false, "enable boradcasting")
// if err := viper.BindPFlag("broadcast", cmd.PersistentFlags().Lookup("broadcast")); err != nil {
// return err
// }
// cmd.PersistentFlags().String("cast_audio", "", "audio codec parameters to use for broadcasting")
// if err := viper.BindPFlag("cast_audio", cmd.PersistentFlags().Lookup("cast_audio")); err != nil {
// return err
// }
// cmd.PersistentFlags().String("cast_video", "", "video codec parameters to use for broadcasting")
// if err := viper.BindPFlag("cast_video", cmd.PersistentFlags().Lookup("cast_video")); err != nil {
// return err
// }
cmd.PersistentFlags().String("broadcast_pipeline", "", "audio codec parameters to use for broadcasting")
if err := viper.BindPFlag("broadcast_pipeline", cmd.PersistentFlags().Lookup("broadcast_pipeline")); err != nil {
return err
}
return nil
}
func (s *Broadcast) Set() {
// s.Enabled = viper.GetBool("broadcast")
// s.AudioParams = viper.GetString("cast_audio")
// s.VideoParams = viper.GetString("cast_video")
s.Pipeline = viper.GetString("broadcast_pipeline")
}