Add getter for stream variant encoder preset w/ test
This commit is contained in:
parent
19e86b8c04
commit
34fe55b5a3
@ -218,6 +218,15 @@ func (q *StreamQuality) GetFramerate() int {
|
||||
return _default.VideoSettings.StreamQualities[0].Framerate
|
||||
}
|
||||
|
||||
// GetEncoderPreset returns the preset or default
|
||||
func (q *StreamQuality) GetEncoderPreset() string {
|
||||
if q.EncoderPreset != "" {
|
||||
return q.EncoderPreset
|
||||
}
|
||||
|
||||
return _default.VideoSettings.StreamQualities[0].EncoderPreset
|
||||
}
|
||||
|
||||
//Load tries to load the configuration file
|
||||
func Load(filePath string, versionInfo string) error {
|
||||
Config = new(config)
|
||||
|
19
config/config_test.go
Normal file
19
config/config_test.go
Normal file
@ -0,0 +1,19 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDefaults(t *testing.T) {
|
||||
_default = getDefaults()
|
||||
|
||||
encoderPreset := "veryfast"
|
||||
framerate := 24
|
||||
|
||||
quality := StreamQuality{}
|
||||
if quality.GetEncoderPreset() != encoderPreset {
|
||||
t.Errorf("default encoder preset does not match expected. Got %s, want: %s", quality.GetEncoderPreset(), encoderPreset)
|
||||
}
|
||||
|
||||
if quality.GetFramerate() != framerate {
|
||||
t.Errorf("default framerate does not match expected. Got %d, want: %d", quality.GetFramerate(), framerate)
|
||||
}
|
||||
}
|
@ -187,11 +187,7 @@ func getVariantFromConfigQuality(quality config.StreamQuality, index int) HLSVar
|
||||
// Set a default, reasonable preset if one is not provided.
|
||||
// "superfast" and "ultrafast" are generally not recommended since they look bad.
|
||||
// https://trac.ffmpeg.org/wiki/Encode/H.264
|
||||
if quality.EncoderPreset != "" {
|
||||
variant.encoderPreset = quality.EncoderPreset
|
||||
} else {
|
||||
variant.encoderPreset = "veryfast"
|
||||
}
|
||||
variant.encoderPreset = quality.GetEncoderPreset()
|
||||
|
||||
variant.SetVideoBitrate(quality.VideoBitrate)
|
||||
variant.SetAudioBitrate(strconv.Itoa(quality.AudioBitrate) + "k")
|
||||
|
Loading…
x
Reference in New Issue
Block a user