Rearchitected transcoding to treat codecs and encoders as separate concepts.
ActivityPub Tests / federation-test (push) Failing after 4s
ActivityPub Tests / chat-sanitization-test (push) Failing after 3s
ActivityPub Tests / follower-validation-test (push) Failing after 4s
Extract Default Translations / extract-and-commit (push) Successful in 4m21s
Automated API tests / test (push) Has been cancelled
Browser Tests / cypress-run (push) Has been cancelled
Chromatic / chromatic-deployment (push) Has been cancelled
CSS Lint and Formatting / css-lint (push) Has been cancelled
javascript-packages / Generate API Documentation (push) Has been cancelled
Lint / Go linter (push) Has been cancelled
Go Tests / test (push) Has been cancelled
Go Tests / test-bsds (map[name:freebsd version:12.2]) (push) Has been cancelled
Go Tests / test-bsds (map[name:openbsd version:6.8]) (push) Has been cancelled
HLS tests / tests (push) Has been cancelled
ActivityPub Tests / federation-test (push) Failing after 4s
ActivityPub Tests / chat-sanitization-test (push) Failing after 3s
ActivityPub Tests / follower-validation-test (push) Failing after 4s
Extract Default Translations / extract-and-commit (push) Successful in 4m21s
Automated API tests / test (push) Has been cancelled
Browser Tests / cypress-run (push) Has been cancelled
Chromatic / chromatic-deployment (push) Has been cancelled
CSS Lint and Formatting / css-lint (push) Has been cancelled
javascript-packages / Generate API Documentation (push) Has been cancelled
Lint / Go linter (push) Has been cancelled
Go Tests / test (push) Has been cancelled
Go Tests / test-bsds (map[name:freebsd version:12.2]) (push) Has been cancelled
Go Tests / test-bsds (map[name:openbsd version:6.8]) (push) Has been cancelled
HLS tests / tests (push) Has been cancelled
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
datastoreValuesVersion = 4
|
||||
datastoreValuesVersion = 5
|
||||
datastoreValueVersionKey = "DATA_STORE_VERSION"
|
||||
)
|
||||
|
||||
@@ -30,6 +30,8 @@ func migrateDatastoreValues(datastore *data.Datastore, configRepository ConfigRe
|
||||
migrateToDatastoreValues3ServingEndpoint3(configRepository)
|
||||
case 3:
|
||||
migrateToDatastoreValues4(datastore, configRepository)
|
||||
case 4:
|
||||
migrateToDatastoreValues5(datastore, configRepository)
|
||||
default:
|
||||
log.Fatalln("missing datastore values migration step")
|
||||
}
|
||||
@@ -86,3 +88,44 @@ func migrateToDatastoreValues4(datastore *data.Datastore, configRepository Confi
|
||||
log.Fatalln("error migrating admin password:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func migrateToDatastoreValues5(datastore *data.Datastore, configRepository ConfigRepository) {
|
||||
// Migrate the old video_codec value (which was really an encoder name like "libx264",
|
||||
// "h264_nvenc") to the new video_encoder key with the encoder type ("software", "nvenc").
|
||||
// Inlined from transcoder.OldCodecNameToEncoderType to avoid an import cycle
|
||||
// (core/transcoder imports persistence/configrepository).
|
||||
oldCodecToEncoderType := map[string]string{
|
||||
"libx264": "software",
|
||||
"h264_nvenc": "nvenc",
|
||||
"h264_vaapi": "vaapi",
|
||||
"h264_qsv": "qsv",
|
||||
"h264_omx": "omx",
|
||||
"h264_v4l2m2m": "v4l2m2m",
|
||||
"h264_videotoolbox": "videotoolbox",
|
||||
}
|
||||
|
||||
oldCodecValue, _ := datastore.GetString("video_codec")
|
||||
if oldCodecValue != "" {
|
||||
encoderType, ok := oldCodecToEncoderType[oldCodecValue]
|
||||
if !ok {
|
||||
encoderType = "software"
|
||||
}
|
||||
if err := configRepository.SetVideoEncoder(encoderType); err != nil {
|
||||
log.Errorln("error migrating video encoder setting:", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Add default video and audio codec values to existing stream output variants.
|
||||
variants := configRepository.GetStreamOutputVariants()
|
||||
for i := range variants {
|
||||
if variants[i].VideoCodec == "" {
|
||||
variants[i].VideoCodec = "h264"
|
||||
}
|
||||
if variants[i].AudioCodec == "" {
|
||||
variants[i].AudioCodec = "aac"
|
||||
}
|
||||
}
|
||||
if err := configRepository.SetStreamOutputVariants(variants); err != nil {
|
||||
log.Errorln("error migrating stream output variants with codec defaults:", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ const (
|
||||
externalActionsKey = "external_actions"
|
||||
customStylesKey = "custom_styles"
|
||||
customJavascriptKey = "custom_javascript"
|
||||
videoCodecKey = "video_codec"
|
||||
videoEncoderKey = "video_encoder"
|
||||
blockedUsernamesKey = "blocked_usernames"
|
||||
publicKeyKey = "public_key"
|
||||
privateKeyKey = "private_key"
|
||||
|
||||
@@ -75,8 +75,8 @@ type ConfigRepository interface {
|
||||
GetCustomStyles() string
|
||||
SetCustomJavascript(styles string) error
|
||||
GetCustomJavascript() string
|
||||
SetVideoCodec(codec string) error
|
||||
GetVideoCodec() string
|
||||
SetVideoEncoder(encoder string) error
|
||||
GetVideoEncoder() string
|
||||
VerifySettings() error
|
||||
FindHighestVideoQualityIndex(qualities []models.StreamOutputVariant) (int, bool)
|
||||
GetForbiddenUsernameList() []string
|
||||
|
||||
@@ -623,19 +623,19 @@ func (r *SqlConfigRepository) GetCustomJavascript() string {
|
||||
return style
|
||||
}
|
||||
|
||||
// SetVideoCodec will set the codec used for video encoding.
|
||||
func (r *SqlConfigRepository) SetVideoCodec(codec string) error {
|
||||
return r.datastore.SetString(videoCodecKey, codec)
|
||||
// SetVideoEncoder will set the encoder used for video encoding.
|
||||
func (r *SqlConfigRepository) SetVideoEncoder(encoder string) error {
|
||||
return r.datastore.SetString(videoEncoderKey, encoder)
|
||||
}
|
||||
|
||||
// GetVideoCodec returns the codec to use for transcoding video.
|
||||
func (r *SqlConfigRepository) GetVideoCodec() string {
|
||||
codec, err := r.datastore.GetString(videoCodecKey)
|
||||
if codec == "" || err != nil {
|
||||
return "libx264" // Default value
|
||||
// GetVideoEncoder returns the encoder to use for transcoding video.
|
||||
func (r *SqlConfigRepository) GetVideoEncoder() string {
|
||||
encoder, err := r.datastore.GetString(videoEncoderKey)
|
||||
if encoder == "" || err != nil {
|
||||
return "software"
|
||||
}
|
||||
|
||||
return codec
|
||||
return encoder
|
||||
}
|
||||
|
||||
// VerifySettings will perform a sanity check for specific settings values.
|
||||
|
||||
Reference in New Issue
Block a user