fix: don't show incompatible encoding options for video encoders

This commit is contained in:
2024-12-19 11:51:06 +02:00
parent 039e30bacc
commit 7b03fa0d86
2 changed files with 29 additions and 1 deletions
-1
View File
@@ -1,3 +1,2 @@
## TODO: Don't show incompatible encoding options for encoders
## TODO: calculate total progress based on file sizes instead of counts of files for a more accurate progress percentage. ## TODO: calculate total progress based on file sizes instead of counts of files for a more accurate progress percentage.
## TODO: when passing in a directory, list all video files in that directory and have the user choose which ones they want encoded ## TODO: when passing in a directory, list all video files in that directory and have the user choose which ones they want encoded
+29
View File
@@ -224,10 +224,39 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd return m, cmd
} }
func parseConfig(cfg map[int]Config) ParsedConfig {
vEncoder := find(cfg, "Video Encoder")
aEncoder := find(cfg, "Audio Encoder")
preset := find(cfg, "Preset")
crf := find(cfg, "Constant Rate Factor (CRF)")
return ParsedConfig{
DeleteOldVideo: find(cfg, "Delete old video(s)?").FocusedOption != 0,
SkipEncodedVid: find(cfg, "What should we do about encoded videos?").FocusedOption == 0,
VideoEncoder: vEncoder.Opts[vEncoder.FocusedOption],
AudioEncoder: aEncoder.Opts[aEncoder.FocusedOption],
Preset: preset.Opts[preset.FocusedOption],
CRF: crf.Opts[crf.FocusedOption],
}
}
func CfgScreenView(m model) string { func CfgScreenView(m model) string {
view := "" view := ""
config := parseConfig(m.Config)
for i, cfg := range Configs { for i, cfg := range Configs {
switch config.VideoEncoder {
case "copy", "librav1e":
if cfg.Name == "Preset" || cfg.Name == "Constant Rate Factor (CRF)" {
continue
}
case "libvpx-vp9", "libsvtav1":
if cfg.Name == "Preset" {
continue
}
}
opts := "" opts := ""
for j, opt := range cfg.Opts { for j, opt := range cfg.Opts {