Compare commits

..

No commits in common. "40848a70a5a9046886a0f48d3b86c716c4f2852f" and "f17104595d0cc51b04f7e7a5086be997b317d492" have entirely different histories.

6 changed files with 7 additions and 215 deletions

View File

@ -2,15 +2,11 @@ package form_items
import ( import (
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor/view/form_items/h264_nvenc"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor/view/form_items/libx264" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor/view/form_items/libx264"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor/view/form_items/libx265"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
) )
var Views = map[string]func(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem{ var Views = map[string]func(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem{
"libx264": libx264.View, "libx264": libx264.View,
"h264_nvenc": h264_nvenc.View,
"libx265": libx265.View,
} }

View File

@ -1,65 +0,0 @@
package h264_nvenc
import (
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder/h264_nvenc"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
"github.com/nicksnyder/go-i18n/v2/i18n"
)
func View(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
items := []*widget.FormItem{}
items = append(items, presetParameter(encoder, app)...)
return items
}
func presetParameter(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
parameter, err := encoder.GetParameter("preset")
if err != nil {
return nil
}
presets := map[string]string{}
presetsForSelect := []string{}
presetDefault := ""
for _, name := range h264_nvenc.Presets {
title := name
presetsForSelect = append(presetsForSelect, name)
presets[title] = name
if name == parameter.Get() {
presetDefault = title
}
}
elementSelect := widget.NewSelect(presetsForSelect, func(s string) {
if presets[s] == "" {
return
}
parameter.Set(presets[s])
})
elementSelect.SetSelected(presetDefault)
elementSelect.Hide()
checkboxTitle := app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{MessageID: "parameterCheckbox"})
elementCheckbox := widget.NewCheck(checkboxTitle, func(b bool) {
if b == true {
parameter.SetEnable()
elementSelect.Show()
return
}
parameter.SetDisable()
elementSelect.Hide()
})
return []*widget.FormItem{
{
Text: app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{MessageID: "formPreset"}),
Widget: container.NewVBox(elementCheckbox, elementSelect),
},
}
}

View File

@ -1,65 +0,0 @@
package libx265
import (
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder/libx265"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
"github.com/nicksnyder/go-i18n/v2/i18n"
)
func View(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
items := []*widget.FormItem{}
items = append(items, presetParameter(encoder, app)...)
return items
}
func presetParameter(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
parameter, err := encoder.GetParameter("preset")
if err != nil {
return nil
}
presets := map[string]string{}
presetsForSelect := []string{}
presetDefault := ""
for _, name := range libx265.Presets {
title := app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{MessageID: "preset_" + name})
presetsForSelect = append(presetsForSelect, title)
presets[title] = name
if name == parameter.Get() {
presetDefault = title
}
}
elementSelect := widget.NewSelect(presetsForSelect, func(s string) {
if presets[s] == "" {
return
}
parameter.Set(presets[s])
})
elementSelect.SetSelected(presetDefault)
elementSelect.Hide()
checkboxTitle := app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{MessageID: "parameterCheckbox"})
elementCheckbox := widget.NewCheck(checkboxTitle, func(b bool) {
if b == true {
parameter.SetEnable()
elementSelect.Show()
return
}
parameter.SetDisable()
elementSelect.Hide()
})
return []*widget.FormItem{
{
Text: app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{MessageID: "formPreset"}),
Widget: container.NewVBox(elementCheckbox, elementSelect),
},
}
}

View File

@ -1,37 +1,13 @@
package h264_nvenc package h264_nvenc
import ( import (
"errors"
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder" encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
) )
var Presets = []string{
"default",
"slow",
"medium",
"fast",
"hp",
"hq",
"bd",
"ll",
"llhq",
"llhp",
"lossless",
"losslesshp",
}
func NewEncoder() encoder2.EncoderContract { func NewEncoder() encoder2.EncoderContract {
parameters := map[string]encoder2.ParameterContract{ parameters := map[string]encoder2.ParameterContract{}
"preset": newParameterPreset(),
}
getParams := func(parameters map[string]encoder2.ParameterContract) []string { getParams := func(parameters map[string]encoder2.ParameterContract) []string {
params := []string{"-c:v", "h264_nvenc"} return []string{"-c:v", "h264_nvenc"}
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
params = append(params, "-preset", parameters["preset"].Get())
}
return params
} }
return encoder2.NewEncoder("h264_nvenc", parameters, getParams) return encoder2.NewEncoder("h264_nvenc", parameters, getParams)
@ -43,16 +19,3 @@ func NewData() encoder2.EncoderDataContract {
fileType := encoder2.FileType(encoder2.Video) fileType := encoder2.FileType(encoder2.Video)
return encoder2.NewData(title, formats, fileType, NewEncoder) return encoder2.NewData(title, formats, fileType, NewEncoder)
} }
func newParameterPreset() encoder2.ParameterContract {
setParameter := func(s string) (string, error) {
for _, value := range Presets {
if value == s {
return value, nil
}
}
return "", errors.New("preset not found")
}
return encoder2.NewParameter("preset", false, "default", setParameter)
}

View File

@ -1,35 +1,11 @@
package libx265 package libx265
import ( import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
"errors"
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
)
var Presets = []string{
"ultrafast",
"superfast",
"veryfast",
"faster",
"fast",
"medium",
"slow",
"slower",
"veryslow",
"placebo",
}
func NewEncoder() encoder2.EncoderContract { func NewEncoder() encoder2.EncoderContract {
parameters := map[string]encoder2.ParameterContract{ parameters := map[string]encoder2.ParameterContract{}
"preset": newParameterPreset(),
}
getParams := func(parameters map[string]encoder2.ParameterContract) []string { getParams := func(parameters map[string]encoder2.ParameterContract) []string {
params := []string{"-c:v", "libx265"} return []string{"-c:v", "libx265"}
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
params = append(params, "-preset", parameters["preset"].Get())
}
return params
} }
return encoder2.NewEncoder("libx265", parameters, getParams) return encoder2.NewEncoder("libx265", parameters, getParams)
@ -41,16 +17,3 @@ func NewData() encoder2.EncoderDataContract {
fileType := encoder2.FileType(encoder2.Video) fileType := encoder2.FileType(encoder2.Video)
return encoder2.NewData(title, formats, fileType, NewEncoder) return encoder2.NewData(title, formats, fileType, NewEncoder)
} }
func newParameterPreset() encoder2.ParameterContract {
setParameter := func(s string) (string, error) {
for _, value := range Presets {
if value == s {
return value, nil
}
}
return "", errors.New("preset not found")
}
return encoder2.NewParameter("preset", false, "medium", setParameter)
}

View File

@ -26,7 +26,7 @@ func init() {
appMetadata := &fyne.AppMetadata{ appMetadata := &fyne.AppMetadata{
ID: "net.kor-elf.projects.gui-for-ffmpeg", ID: "net.kor-elf.projects.gui-for-ffmpeg",
Name: "GUI for FFmpeg", Name: "GUI for FFmpeg",
Version: "0.7.0", Version: "0.6.0",
Icon: iconResource, Icon: iconResource,
} }