Add support for custom encoder presets
This commit is contained in:
@@ -23,6 +23,7 @@ type Config struct {
|
|||||||
type VideoSettings struct {
|
type VideoSettings struct {
|
||||||
ChunkLengthInSeconds int `yaml:"chunkLengthInSeconds"`
|
ChunkLengthInSeconds int `yaml:"chunkLengthInSeconds"`
|
||||||
StreamingKey string `yaml:"streamingKey"`
|
StreamingKey string `yaml:"streamingKey"`
|
||||||
|
EncoderPreset string `yaml:"encoderPreset"`
|
||||||
StreamQualities []StreamQuality `yaml:"streamQualities"`
|
StreamQualities []StreamQuality `yaml:"streamQualities"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,4 +86,12 @@ func checkConfig(config Config) {
|
|||||||
if !fileExists(config.FFMpegPath) {
|
if !fileExists(config.FFMpegPath) {
|
||||||
panic(fmt.Sprintf("ffmpeg does not exist at %s.", 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.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ webServerPort: 8080
|
|||||||
videoSettings:
|
videoSettings:
|
||||||
chunkLengthInSeconds: 4
|
chunkLengthInSeconds: 4
|
||||||
streamingKey: abc123
|
streamingKey: abc123
|
||||||
|
encoderPreset: superfast # https://trac.ffmpeg.org/wiki/Encode/H.264
|
||||||
|
|
||||||
streamQualities:
|
streamQualities:
|
||||||
- bitrate: 6000k
|
- bitrate: 6000k
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func startFfmpeg(configuration Config) {
|
|||||||
"-master_pl_name stream.m3u8",
|
"-master_pl_name stream.m3u8",
|
||||||
"-g 48",
|
"-g 48",
|
||||||
"-keyint_min 48",
|
"-keyint_min 48",
|
||||||
"-preset superfast",
|
"-preset " + configuration.VideoSettings.EncoderPreset,
|
||||||
"-sc_threshold 0",
|
"-sc_threshold 0",
|
||||||
"-profile:v high",
|
"-profile:v high",
|
||||||
"-f hls",
|
"-f hls",
|
||||||
|
|||||||
Reference in New Issue
Block a user