From 048dfecbaea7f20f88d24d9ce6b1e5c844b20ed7 Mon Sep 17 00:00:00 2001 From: nite07 Date: Fri, 25 Oct 2024 12:51:49 +0800 Subject: [PATCH] refactor: Streamer breaking change: change PlayConfig.CustomArgs type --- README.md | 2 +- config/config.go | 24 +-- main.go | 4 +- server/static/index.html | 24 ++- streamer/helper.go | 45 ++++ streamer/message.go | 43 ++++ streamer/streamer.go | 446 ++++++++++++++++++++------------------- 7 files changed, 358 insertions(+), 230 deletions(-) create mode 100644 streamer/helper.go create mode 100644 streamer/message.go diff --git a/README.md b/README.md index 192f339..c0098a5 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ "audio_bitrate": "128k", "audio_sample_rate": 44100, "output_format": "flv", - "custom_args": "" + "custom_args": [] }, "output": { "rtmp_server": "rtmp://live-push.example.com/live", diff --git a/config/config.go b/config/config.go index f742af1..7b7a32a 100644 --- a/config/config.go +++ b/config/config.go @@ -24,18 +24,18 @@ type InputItem struct { } type PlayConfig struct { - VideoCodec string `json:"video_codec"` - Preset string `json:"preset"` - CRF int `json:"crf"` - MaxRate string `json:"max_rate"` - BufSize string `json:"buf_size"` - Scale string `json:"scale"` - FrameRate int `json:"frame_rate"` - AudioCodec string `json:"audio_codec"` - AudioBitrate string `json:"audio_bitrate"` - AudioSampleRate int `json:"audio_sample_rate"` - OutputFormat string `json:"output_format"` - CustomArgs string `json:"custom_args"` + VideoCodec string `json:"video_codec"` + Preset string `json:"preset"` + CRF int `json:"crf"` + MaxRate string `json:"max_rate"` + BufSize string `json:"buf_size"` + Scale string `json:"scale"` + FrameRate int `json:"frame_rate"` + AudioCodec string `json:"audio_codec"` + AudioBitrate string `json:"audio_bitrate"` + AudioSampleRate int `json:"audio_sample_rate"` + OutputFormat string `json:"output_format"` + CustomArgs []string `json:"custom_args"` } type LogConfig struct { diff --git a/main.go b/main.go index 6819764..d461b53 100644 --- a/main.go +++ b/main.go @@ -28,8 +28,8 @@ func main() { GlobalStreamer = streamer.NewStreamer(config.GlobalConfig.VideoList) go startWatcher() go input() - GlobalStreamer.Stream() - GlobalStreamer.Close() + GlobalStreamer.Start() + select {} } func input() { diff --git a/server/static/index.html b/server/static/index.html index 3c28ea8..7b6b98f 100644 --- a/server/static/index.html +++ b/server/static/index.html @@ -367,6 +367,7 @@