Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Add support for custom encoder presets

Gabe Kangasc4b6478b7b2d
diff --git a/config.go b/config.go
index abcc9bfc24..6c7262c48d 100644
--- a/config.go
+++ b/config.go
@@ -23,6 +23,7 @@ type Config struct {
type VideoSettings struct {
ChunkLengthInSeconds int `yaml:"chunkLengthInSeconds"`
StreamingKey string `yaml:"streamingKey"`
+ EncoderPreset string `yaml:"encoderPreset"`
StreamQualities []StreamQuality `yaml:"streamQualities"`
}
@@ -85,4 +86,12 @@ func checkConfig(config Config) {
if !fileExists(config.FFMpegPath) {
panic(fmt.Sprintf("ffmpeg does not exist at %s.", config.FFMpegPath))
}
+
+ if config.VideoSettings.EncoderPreset == "" {
+ panic("A video encoder preset is required to be set in the config file.")
+ }
+
+ if len(config.VideoSettings.StreamQualities) < 1 {
+ panic("At least one stream quality must be set in the config file.")
+ }
}
diff --git a/config/config-example.yaml b/config/config-example.yaml
index e982cf2a5a..426d0747a8 100644
--- a/config/config-example.yaml
+++ b/config/config-example.yaml
@@ -6,6 +6,7 @@ webServerPort: 8080
videoSettings:
chunkLengthInSeconds: 4
streamingKey: abc123
+ encoderPreset: superfast # https://trac.ffmpeg.org/wiki/Encode/H.264
streamQualities:
- bitrate: 6000k
diff --git a/ffmpeg.go b/ffmpeg.go
index df29dcc76f..1ea39064f0 100644
--- a/ffmpeg.go
+++ b/ffmpeg.go
@@ -48,7 +48,7 @@ func startFfmpeg(configuration Config) {
"-master_pl_name stream.m3u8",
"-g 48",
"-keyint_min 48",
- "-preset superfast",
+ "-preset " + configuration.VideoSettings.EncoderPreset,
"-sc_threshold 0",
"-profile:v high",
"-f hls",