mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 00:11:48 -06:00
add hostname to broadcast variables. (#576)
This commit is contained in:
@@ -298,7 +298,7 @@ func (Capture) InitV2(cmd *cobra.Command) error {
|
||||
// broadcast
|
||||
//
|
||||
|
||||
cmd.PersistentFlags().String("broadcast_pipeline", "", "V2: custom gst pipeline used for broadcasting, strings {url} {device} {display} will be replaced")
|
||||
cmd.PersistentFlags().String("broadcast_pipeline", "", "V2: custom gst pipeline used for broadcasting, strings {hostname} {url} {device} {display} will be replaced")
|
||||
if err := viper.BindPFlag("broadcast_pipeline", cmd.PersistentFlags().Lookup("broadcast_pipeline")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/m1k1o/neko/server/pkg/gst"
|
||||
@@ -40,12 +41,17 @@ func NewBroadcastPipeline(device string, display string, pipelineSrc string, url
|
||||
|
||||
var pipelineStr string
|
||||
if pipelineSrc != "" {
|
||||
pipelineStr = pipelineSrc
|
||||
// replace {hostname} with valid hostname
|
||||
if hostname, err := os.Hostname(); err == nil {
|
||||
pipelineStr = strings.ReplaceAll(pipelineStr, "{hostname}", hostname)
|
||||
}
|
||||
// replace RTMP url
|
||||
pipelineStr = strings.Replace(pipelineSrc, "{url}", url, -1)
|
||||
pipelineStr = strings.ReplaceAll(pipelineStr, "{url}", url)
|
||||
// replace audio device
|
||||
pipelineStr = strings.Replace(pipelineStr, "{device}", device, -1)
|
||||
pipelineStr = strings.ReplaceAll(pipelineStr, "{device}", device)
|
||||
// replace display
|
||||
pipelineStr = strings.Replace(pipelineStr, "{display}", display, -1)
|
||||
pipelineStr = strings.ReplaceAll(pipelineStr, "{display}", display)
|
||||
} else {
|
||||
pipelineStr = fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. %s x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", url, audio, video)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user