Change default transcodings to a proper typed struct

This commit is contained in:
Deluan 2024-05-08 17:39:25 -04:00
parent 62cc8a2d4b
commit eb93136b3f
2 changed files with 19 additions and 14 deletions

View file

@ -88,24 +88,29 @@ const (
var ( var (
DefaultDownsamplingFormat = "opus" DefaultDownsamplingFormat = "opus"
DefaultTranscodings = []map[string]interface{}{ DefaultTranscodings = []struct {
Name string
TargetFormat string
DefaultBitRate int
Command string
}{
{ {
"name": "mp3 audio", Name: "mp3 audio",
"targetFormat": "mp3", TargetFormat: "mp3",
"defaultBitRate": 192, DefaultBitRate: 192,
"command": "ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -f mp3 -", Command: "ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -f mp3 -",
}, },
{ {
"name": "opus audio", Name: "opus audio",
"targetFormat": "opus", TargetFormat: "opus",
"defaultBitRate": 128, DefaultBitRate: 128,
"command": "ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -c:a libopus -f opus -", Command: "ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -c:a libopus -f opus -",
}, },
{ {
"name": "aac audio", Name: "aac audio",
"targetFormat": "aac", TargetFormat: "aac",
"defaultBitRate": 256, DefaultBitRate: 256,
"command": "ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -c:a aac -f adts -", Command: "ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -c:a aac -f adts -",
}, },
} }

View file

@ -30,7 +30,7 @@ func upAddDefaultTranscodings(_ context.Context, tx *sql.Tx) error {
} }
for _, t := range consts.DefaultTranscodings { for _, t := range consts.DefaultTranscodings {
_, err := stmt.Exec(uuid.NewString(), t["name"], t["targetFormat"], t["defaultBitRate"], t["command"]) _, err := stmt.Exec(uuid.NewString(), t.Name, t.TargetFormat, t.DefaultBitRate, t.Command)
if err != nil { if err != nil {
return err return err
} }