Compare commits
No commits in common. "850cbbaf7081d122f793ae98398cd2a55d502017" and "43d794373a341b7246e306c19c1438742859c583" have entirely different histories.
850cbbaf70
...
43d794373a
46
convertor/repository.go
Normal file
46
convertor/repository.go
Normal file
@ -0,0 +1,46 @@
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/setting"
|
||||
)
|
||||
|
||||
type RepositoryContract interface {
|
||||
GetPathFfmpeg() string
|
||||
SavePathFfmpeg(code string) setting.Setting
|
||||
GetPathFfprobe() string
|
||||
SavePathFfprobe(code string) setting.Setting
|
||||
GetPathFfplay() string
|
||||
SavePathFfplay(code string) setting.Setting
|
||||
}
|
||||
|
||||
type Repository struct {
|
||||
settingRepository setting.RepositoryContract
|
||||
}
|
||||
|
||||
func NewRepository(settingRepository setting.RepositoryContract) *Repository {
|
||||
return &Repository{settingRepository: settingRepository}
|
||||
}
|
||||
|
||||
func (r Repository) GetPathFfmpeg() string {
|
||||
return r.settingRepository.GetValue("ffmpeg")
|
||||
}
|
||||
|
||||
func (r Repository) SavePathFfmpeg(path string) setting.Setting {
|
||||
return r.settingRepository.CreateOrUpdate("ffmpeg", path)
|
||||
}
|
||||
|
||||
func (r Repository) GetPathFfprobe() string {
|
||||
return r.settingRepository.GetValue("ffprobe")
|
||||
}
|
||||
|
||||
func (r Repository) SavePathFfprobe(path string) setting.Setting {
|
||||
return r.settingRepository.CreateOrUpdate("ffprobe", path)
|
||||
}
|
||||
|
||||
func (r Repository) GetPathFfplay() string {
|
||||
return r.settingRepository.GetValue("ffplay")
|
||||
}
|
||||
|
||||
func (r Repository) SavePathFfplay(path string) setting.Setting {
|
||||
return r.settingRepository.CreateOrUpdate("ffplay", path)
|
||||
}
|
60
convertor/view.go
Normal file
60
convertor/view.go
Normal file
@ -0,0 +1,60 @@
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor/view"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
type ViewContract interface {
|
||||
Main(
|
||||
formConversion view.ConversionContract,
|
||||
)
|
||||
SelectFFPath(
|
||||
ffmpegPath string,
|
||||
ffprobePath string,
|
||||
ffplayPath string,
|
||||
save func(ffmpegPath string, ffprobePath string, ffplayPath string) error,
|
||||
cancel func(),
|
||||
donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error,
|
||||
)
|
||||
}
|
||||
|
||||
type View struct {
|
||||
app kernel.AppContract
|
||||
downloadFFmpeg *downloadFFmpeg
|
||||
}
|
||||
|
||||
type downloadFFmpeg struct {
|
||||
isDownloadFFmpeg bool
|
||||
blockDownloadFFmpegContainer *fyne.Container
|
||||
}
|
||||
|
||||
func NewView(app kernel.AppContract) *View {
|
||||
return &View{
|
||||
app: app,
|
||||
downloadFFmpeg: &downloadFFmpeg{
|
||||
blockDownloadFFmpegContainer: nil,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (v View) Main(formConversion view.ConversionContract) {
|
||||
converterVideoFilesTitle := v.app.GetLocalizerService().GetMessage("converterVideoFilesTitle")
|
||||
v.app.GetWindow().SetContent(widget.NewCard(converterVideoFilesTitle, "", container.NewVScroll(formConversion.GetContent())))
|
||||
formConversion.AfterViewContent()
|
||||
}
|
||||
|
||||
func setStringErrorStyle(text *canvas.Text) {
|
||||
text.Color = color.RGBA{R: 255, G: 0, B: 0, A: 255}
|
||||
text.Refresh()
|
||||
}
|
||||
|
||||
func setStringSuccessStyle(text *canvas.Text) {
|
||||
text.Color = color.RGBA{R: 49, G: 127, B: 114, A: 255}
|
||||
text.Refresh()
|
||||
}
|
515
convertor/view/conversion.go
Normal file
515
convertor/view/conversion.go
Normal file
@ -0,0 +1,515 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor/view/form_items"
|
||||
encoder2 "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/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/setting"
|
||||
"image/color"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type ConversionContract interface {
|
||||
GetContent() fyne.CanvasObject
|
||||
AfterViewContent()
|
||||
}
|
||||
|
||||
type Conversion struct {
|
||||
app kernel.AppContract
|
||||
form *form
|
||||
conversionMessage *canvas.Text
|
||||
fileForConversion *fileForConversion
|
||||
directoryForSaving *directoryForSaving
|
||||
overwriteOutputFiles *overwriteOutputFiles
|
||||
selectEncoder *selectEncoder
|
||||
runConvert func(setting HandleConvertSetting)
|
||||
itemsToConvertService kernel.ItemsToConvertContract
|
||||
}
|
||||
|
||||
type HandleConvertSetting struct {
|
||||
DirectoryForSave string
|
||||
OverwriteOutputFiles bool
|
||||
Format string
|
||||
Encoder encoder2.EncoderContract
|
||||
}
|
||||
|
||||
func NewConversion(app kernel.AppContract, formats encoder.ConvertorFormatsContract, runConvert func(setting HandleConvertSetting), settingDirectoryForSaving setting.DirectoryForSavingContract, itemsToConvertService kernel.ItemsToConvertContract) *Conversion {
|
||||
conversionMessage := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
conversionMessage.TextSize = 16
|
||||
conversionMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
|
||||
fileForConversion := newFileForConversion(app, itemsToConvertService)
|
||||
directoryForSaving := newDirectoryForSaving(app, settingDirectoryForSaving)
|
||||
overwriteOutputFiles := newOverwriteOutputFiles(app)
|
||||
selectEncoder := newSelectEncoder(app, formats)
|
||||
|
||||
items := []*widget.FormItem{
|
||||
{
|
||||
Text: app.GetLocalizerService().GetMessage("fileForConversionTitle"),
|
||||
Widget: fileForConversion.button,
|
||||
},
|
||||
{
|
||||
Widget: container.NewHScroll(fileForConversion.message),
|
||||
},
|
||||
{
|
||||
Text: app.GetLocalizerService().GetMessage("buttonForSelectedDirTitle"),
|
||||
Widget: directoryForSaving.button,
|
||||
},
|
||||
{
|
||||
Widget: container.NewHScroll(directoryForSaving.message),
|
||||
},
|
||||
{
|
||||
Widget: overwriteOutputFiles.checkbox,
|
||||
},
|
||||
{
|
||||
Widget: selectEncoder.SelectFileType,
|
||||
},
|
||||
{
|
||||
Text: app.GetLocalizerService().GetMessage("selectFormat"),
|
||||
Widget: selectEncoder.SelectFormat,
|
||||
},
|
||||
{
|
||||
Text: app.GetLocalizerService().GetMessage("selectEncoder"),
|
||||
Widget: selectEncoder.SelectEncoder,
|
||||
},
|
||||
}
|
||||
form := newForm(app, items)
|
||||
|
||||
return &Conversion{
|
||||
app: app,
|
||||
form: form,
|
||||
conversionMessage: conversionMessage,
|
||||
fileForConversion: fileForConversion,
|
||||
directoryForSaving: directoryForSaving,
|
||||
overwriteOutputFiles: overwriteOutputFiles,
|
||||
selectEncoder: selectEncoder,
|
||||
runConvert: runConvert,
|
||||
itemsToConvertService: itemsToConvertService,
|
||||
}
|
||||
}
|
||||
|
||||
func (c Conversion) GetContent() fyne.CanvasObject {
|
||||
c.form.form.OnSubmit = c.submit
|
||||
c.fileForConversion.AddChangeCallback(c.selectFileForConversion)
|
||||
c.selectEncoder.AddChangeCallback(c.changeEncoder)
|
||||
if c.selectEncoder.Encoder != nil {
|
||||
c.selectEncoder.SelectEncoder.SetSelectedIndex(c.selectEncoder.SelectEncoder.SelectedIndex())
|
||||
}
|
||||
|
||||
return container.NewVBox(
|
||||
c.form.form,
|
||||
c.conversionMessage,
|
||||
)
|
||||
}
|
||||
|
||||
func (c Conversion) changeEncoder(encoder encoder2.EncoderContract) {
|
||||
items := []*widget.FormItem{}
|
||||
|
||||
if form_items.Views[encoder.GetName()] != nil {
|
||||
items = form_items.Views[encoder.GetName()](encoder, c.app)
|
||||
}
|
||||
|
||||
c.form.ChangeItems(items)
|
||||
}
|
||||
|
||||
func (c Conversion) AfterViewContent() {
|
||||
if len(c.itemsToConvertService.GetItems()) == 0 {
|
||||
c.form.form.Disable()
|
||||
}
|
||||
}
|
||||
|
||||
func (c Conversion) selectFileForConversion(err error) {
|
||||
c.conversionMessage.Text = ""
|
||||
if len(c.itemsToConvertService.GetItems()) == 0 {
|
||||
if err != nil {
|
||||
c.form.form.Disable()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.form.form.Enable()
|
||||
}
|
||||
|
||||
func (c Conversion) submit() {
|
||||
if len(c.itemsToConvertService.GetItems()) == 0 {
|
||||
showConversionMessage(c.conversionMessage, errors.New(c.app.GetLocalizerService().GetMessage("errorNoFilesAddedForConversion")))
|
||||
c.enableFormConversion()
|
||||
return
|
||||
}
|
||||
|
||||
if len(c.directoryForSaving.path) == 0 {
|
||||
showConversionMessage(c.conversionMessage, errors.New(c.app.GetLocalizerService().GetMessage("errorSelectedFolderSave")))
|
||||
c.enableFormConversion()
|
||||
return
|
||||
}
|
||||
if len(c.selectEncoder.SelectFormat.Selected) == 0 {
|
||||
showConversionMessage(c.conversionMessage, errors.New(c.app.GetLocalizerService().GetMessage("errorSelectedFormat")))
|
||||
return
|
||||
}
|
||||
if c.selectEncoder.Encoder == nil {
|
||||
showConversionMessage(c.conversionMessage, errors.New(c.app.GetLocalizerService().GetMessage("errorSelectedEncoder")))
|
||||
return
|
||||
}
|
||||
c.conversionMessage.Text = ""
|
||||
|
||||
c.fileForConversion.button.Disable()
|
||||
c.directoryForSaving.button.Disable()
|
||||
c.form.form.Disable()
|
||||
|
||||
c.runConvert(HandleConvertSetting{
|
||||
DirectoryForSave: c.directoryForSaving.path,
|
||||
OverwriteOutputFiles: c.overwriteOutputFiles.IsChecked(),
|
||||
Format: c.selectEncoder.SelectFormat.Selected,
|
||||
Encoder: c.selectEncoder.Encoder,
|
||||
})
|
||||
c.enableFormConversion()
|
||||
|
||||
if len(c.itemsToConvertService.GetItems()) == 0 {
|
||||
c.form.form.Disable()
|
||||
}
|
||||
}
|
||||
|
||||
func (c Conversion) enableFormConversion() {
|
||||
c.fileForConversion.button.Enable()
|
||||
c.directoryForSaving.button.Enable()
|
||||
c.form.form.Enable()
|
||||
}
|
||||
|
||||
type fileForConversion struct {
|
||||
button *widget.Button
|
||||
message *canvas.Text
|
||||
file *kernel.File
|
||||
|
||||
changeCallbacks map[int]func(err error)
|
||||
}
|
||||
|
||||
func newFileForConversion(app kernel.AppContract, itemsToConvertService kernel.ItemsToConvertContract) *fileForConversion {
|
||||
message := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
fileForConversion := &fileForConversion{
|
||||
message: message,
|
||||
|
||||
changeCallbacks: map[int]func(err error){},
|
||||
}
|
||||
|
||||
buttonTitle := app.GetLocalizerService().GetMessage("choose") + "\n" +
|
||||
app.GetLocalizerService().GetMessage("or") + "\n" +
|
||||
app.GetLocalizerService().GetMessage("dragAndDropFiles")
|
||||
|
||||
var locationURI fyne.ListableURI
|
||||
|
||||
fileForConversion.button = widget.NewButton(buttonTitle, func() {
|
||||
app.GetWindow().NewFileOpen(func(r fyne.URIReadCloser, err error) {
|
||||
fyne.Do(func() {
|
||||
fileForConversion.message.Text = ""
|
||||
fileForConversion.message.Refresh()
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fyne.Do(func() {
|
||||
fileForConversion.message.Text = err.Error()
|
||||
fileForConversion.message.Refresh()
|
||||
})
|
||||
fileForConversion.eventSelectFile(err)
|
||||
return
|
||||
}
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
app.GetWindow().GetLayout().GetRightTabs().SelectAddedFilesTab()
|
||||
|
||||
itemsToConvertService.Add(&kernel.File{
|
||||
Path: r.URI().Path(),
|
||||
Name: r.URI().Name(),
|
||||
Ext: r.URI().Extension(),
|
||||
})
|
||||
|
||||
fileForConversion.eventSelectFile(nil)
|
||||
|
||||
listableURI := storage.NewFileURI(filepath.Dir(r.URI().Path()))
|
||||
locationURI, _ = storage.ListerForURI(listableURI)
|
||||
}, locationURI)
|
||||
})
|
||||
|
||||
app.GetWindow().SetOnDropped(func(position fyne.Position, uris []fyne.URI) {
|
||||
if len(uris) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
isError := false
|
||||
for _, uri := range uris {
|
||||
info, err := os.Stat(uri.Path())
|
||||
if err != nil {
|
||||
isError = true
|
||||
continue
|
||||
}
|
||||
if info.IsDir() {
|
||||
isError = true
|
||||
continue
|
||||
}
|
||||
|
||||
itemsToConvertService.Add(&kernel.File{
|
||||
Path: uri.Path(),
|
||||
Name: uri.Name(),
|
||||
Ext: uri.Extension(),
|
||||
})
|
||||
|
||||
fileForConversion.eventSelectFile(nil)
|
||||
|
||||
listableURI := storage.NewFileURI(filepath.Dir(uri.Path()))
|
||||
locationURI, _ = storage.ListerForURI(listableURI)
|
||||
}
|
||||
app.GetWindow().GetLayout().GetRightTabs().SelectAddedFilesTab()
|
||||
if isError {
|
||||
fileForConversion.message.Text = app.GetLocalizerService().GetMessage("errorDragAndDropFile")
|
||||
setStringErrorStyle(fileForConversion.message)
|
||||
fileForConversion.eventSelectFile(errors.New(fileForConversion.message.Text))
|
||||
} else {
|
||||
fyne.Do(func() {
|
||||
fileForConversion.message.Text = ""
|
||||
fileForConversion.message.Refresh()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return fileForConversion
|
||||
}
|
||||
|
||||
func (c fileForConversion) AddChangeCallback(callback func(err error)) {
|
||||
c.changeCallbacks[len(c.changeCallbacks)] = callback
|
||||
}
|
||||
|
||||
func (c fileForConversion) eventSelectFile(err error) {
|
||||
for _, changeCallback := range c.changeCallbacks {
|
||||
changeCallback(err)
|
||||
}
|
||||
}
|
||||
|
||||
type directoryForSaving struct {
|
||||
button *widget.Button
|
||||
message *canvas.Text
|
||||
path string
|
||||
}
|
||||
|
||||
func newDirectoryForSaving(app kernel.AppContract, settingDirectoryForSaving setting.DirectoryForSavingContract) *directoryForSaving {
|
||||
directoryForSaving := &directoryForSaving{
|
||||
path: "",
|
||||
}
|
||||
|
||||
directoryForSaving.message = canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
directoryForSaving.message.TextSize = 16
|
||||
directoryForSaving.message.TextStyle = fyne.TextStyle{Bold: true}
|
||||
|
||||
buttonTitle := app.GetLocalizerService().GetMessage("choose")
|
||||
|
||||
var locationURI fyne.ListableURI
|
||||
|
||||
location, err := getDirectoryForSaving(settingDirectoryForSaving)
|
||||
if err == nil {
|
||||
directoryForSaving.path = location.Path()
|
||||
directoryForSaving.message.Text = location.Path()
|
||||
setStringSuccessStyle(directoryForSaving.message)
|
||||
}
|
||||
|
||||
directoryForSaving.button = widget.NewButton(buttonTitle, func() {
|
||||
app.GetWindow().NewFolderOpen(func(r fyne.ListableURI, err error) {
|
||||
if err != nil {
|
||||
directoryForSaving.message.Text = err.Error()
|
||||
setStringErrorStyle(directoryForSaving.message)
|
||||
return
|
||||
}
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
|
||||
directoryForSaving.path = r.Path()
|
||||
|
||||
directoryForSaving.message.Text = r.Path()
|
||||
setStringSuccessStyle(directoryForSaving.message)
|
||||
locationURI, err = storage.ListerForURI(r)
|
||||
|
||||
if err == nil {
|
||||
_ = settingDirectoryForSaving.SaveDirectoryForSaving(locationURI.Path())
|
||||
}
|
||||
|
||||
}, locationURI)
|
||||
})
|
||||
|
||||
return directoryForSaving
|
||||
}
|
||||
|
||||
func getDirectoryForSaving(settingDirectoryForSaving setting.DirectoryForSavingContract) (fyne.ListableURI, error) {
|
||||
path := settingDirectoryForSaving.GetDirectoryForSaving()
|
||||
|
||||
if len(path) > 0 {
|
||||
path = "file://" + path
|
||||
}
|
||||
|
||||
uri, err := storage.ParseURI(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return storage.ListerForURI(uri)
|
||||
}
|
||||
|
||||
type overwriteOutputFiles struct {
|
||||
checkbox *widget.Check
|
||||
isChecked bool
|
||||
}
|
||||
|
||||
func newOverwriteOutputFiles(app kernel.AppContract) *overwriteOutputFiles {
|
||||
overwriteOutputFiles := &overwriteOutputFiles{
|
||||
isChecked: false,
|
||||
}
|
||||
checkboxOverwriteOutputFilesTitle := app.GetLocalizerService().GetMessage("checkboxOverwriteOutputFilesTitle")
|
||||
overwriteOutputFiles.checkbox = widget.NewCheck(checkboxOverwriteOutputFilesTitle, func(b bool) {
|
||||
overwriteOutputFiles.isChecked = b
|
||||
})
|
||||
|
||||
return overwriteOutputFiles
|
||||
}
|
||||
|
||||
func (receiver overwriteOutputFiles) IsChecked() bool {
|
||||
return receiver.isChecked
|
||||
}
|
||||
|
||||
type selectEncoder struct {
|
||||
SelectFileType *widget.RadioGroup
|
||||
SelectFormat *widget.Select
|
||||
SelectEncoder *widget.Select
|
||||
Encoder encoder2.EncoderContract
|
||||
|
||||
changeCallbacks map[int]func(encoder encoder2.EncoderContract)
|
||||
}
|
||||
|
||||
func newSelectEncoder(app kernel.AppContract, formats encoder.ConvertorFormatsContract) *selectEncoder {
|
||||
selectEncoder := &selectEncoder{
|
||||
changeCallbacks: map[int]func(encoder encoder2.EncoderContract){},
|
||||
}
|
||||
|
||||
encoders := map[int]encoder2.EncoderDataContract{}
|
||||
selectEncoder.SelectEncoder = widget.NewSelect([]string{}, func(s string) {
|
||||
if encoders[selectEncoder.SelectEncoder.SelectedIndex()] == nil {
|
||||
return
|
||||
}
|
||||
selectEncoderData := encoders[selectEncoder.SelectEncoder.SelectedIndex()]
|
||||
selectEncoder.ChangeEncoder(selectEncoderData.NewEncoder())
|
||||
})
|
||||
|
||||
formatSelected := ""
|
||||
selectEncoder.SelectFormat = widget.NewSelect([]string{}, func(s string) {
|
||||
if formatSelected == s {
|
||||
return
|
||||
}
|
||||
formatSelected = s
|
||||
format, err := formats.GetFormat(s)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
encoderOptions := []string{}
|
||||
encoders = map[int]encoder2.EncoderDataContract{}
|
||||
for _, e := range format.GetEncoders() {
|
||||
encoders[len(encoders)] = e
|
||||
encoderOptions = append(encoderOptions, app.GetLocalizerService().GetMessage("encoder_"+e.GetTitle()))
|
||||
}
|
||||
selectEncoder.SelectEncoder.SetOptions(encoderOptions)
|
||||
selectEncoder.SelectEncoder.SetSelectedIndex(0)
|
||||
})
|
||||
|
||||
fileTypeOptions := []string{}
|
||||
for _, fileType := range encoder2.GetListFileType() {
|
||||
fileTypeOptions = append(fileTypeOptions, fileType.Name())
|
||||
}
|
||||
|
||||
encoderGroupVideo := app.GetLocalizerService().GetMessage("encoderGroupVideo")
|
||||
encoderGroupAudio := app.GetLocalizerService().GetMessage("encoderGroupAudio")
|
||||
encoderGroupImage := app.GetLocalizerService().GetMessage("encoderGroupImage")
|
||||
encoderGroup := map[string]string{
|
||||
encoderGroupVideo: "video",
|
||||
encoderGroupAudio: "audio",
|
||||
encoderGroupImage: "image",
|
||||
}
|
||||
selectEncoder.SelectFileType = widget.NewRadioGroup([]string{encoderGroupVideo, encoderGroupAudio, encoderGroupImage}, func(s string) {
|
||||
groupCode := encoderGroup[s]
|
||||
|
||||
formatOptions := []string{}
|
||||
for _, f := range formats.GetFormats() {
|
||||
if groupCode != f.GetFileType().Name() {
|
||||
continue
|
||||
}
|
||||
formatOptions = append(formatOptions, f.GetTitle())
|
||||
}
|
||||
selectEncoder.SelectFormat.SetOptions(formatOptions)
|
||||
if groupCode == encoder2.FileType(encoder2.Video).Name() {
|
||||
selectEncoder.SelectFormat.SetSelected("mp4")
|
||||
} else {
|
||||
selectEncoder.SelectFormat.SetSelectedIndex(0)
|
||||
}
|
||||
})
|
||||
selectEncoder.SelectFileType.Horizontal = true
|
||||
selectEncoder.SelectFileType.Required = true
|
||||
selectEncoder.SelectFileType.SetSelected(encoderGroupVideo)
|
||||
|
||||
return selectEncoder
|
||||
}
|
||||
|
||||
func (e *selectEncoder) ChangeEncoder(encoder encoder2.EncoderContract) {
|
||||
e.Encoder = encoder
|
||||
e.eventSelectEncoder(e.Encoder)
|
||||
}
|
||||
|
||||
func (e *selectEncoder) AddChangeCallback(callback func(encoder encoder2.EncoderContract)) {
|
||||
e.changeCallbacks[len(e.changeCallbacks)] = callback
|
||||
}
|
||||
|
||||
func (e *selectEncoder) eventSelectEncoder(encoder encoder2.EncoderContract) {
|
||||
for _, changeCallback := range e.changeCallbacks {
|
||||
changeCallback(encoder)
|
||||
}
|
||||
}
|
||||
|
||||
func setStringErrorStyle(text *canvas.Text) {
|
||||
text.Color = color.RGBA{R: 255, G: 0, B: 0, A: 255}
|
||||
text.Refresh()
|
||||
}
|
||||
|
||||
func setStringSuccessStyle(text *canvas.Text) {
|
||||
text.Color = color.RGBA{R: 49, G: 127, B: 114, A: 255}
|
||||
text.Refresh()
|
||||
}
|
||||
|
||||
func showConversionMessage(conversionMessage *canvas.Text, err error) {
|
||||
conversionMessage.Text = err.Error()
|
||||
setStringErrorStyle(conversionMessage)
|
||||
}
|
||||
|
||||
type form struct {
|
||||
form *widget.Form
|
||||
items []*widget.FormItem
|
||||
}
|
||||
|
||||
func newForm(app kernel.AppContract, items []*widget.FormItem) *form {
|
||||
f := widget.NewForm()
|
||||
f.SubmitText = app.GetLocalizerService().GetMessage("converterVideoFilesSubmitTitle")
|
||||
f.Items = items
|
||||
|
||||
return &form{
|
||||
form: f,
|
||||
items: items,
|
||||
}
|
||||
}
|
||||
|
||||
func (f form) ChangeItems(items []*widget.FormItem) {
|
||||
f.form.Items = f.items
|
||||
f.form.Refresh()
|
||||
f.form.Items = append(f.form.Items, items...)
|
||||
f.form.Refresh()
|
||||
}
|
16
convertor/view/form_items/form.go
Normal file
16
convertor/view/form_items/form.go
Normal file
@ -0,0 +1,16 @@
|
||||
package form_items
|
||||
|
||||
import (
|
||||
"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/libx265"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
)
|
||||
|
||||
var Views = map[string]func(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem{
|
||||
"libx264": libx264.View,
|
||||
"h264_nvenc": h264_nvenc.View,
|
||||
"libx265": libx265.View,
|
||||
}
|
@ -2,21 +2,21 @@ package h264_nvenc
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/h264_nvenc"
|
||||
"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"
|
||||
)
|
||||
|
||||
func View(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
func View(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
|
||||
items := []*widget.FormItem{}
|
||||
|
||||
items = append(items, presetParameter(encoder)...)
|
||||
items = append(items, presetParameter(encoder, app)...)
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
func presetParameter(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
|
||||
parameter, err := encoder.GetParameter("preset")
|
||||
if err != nil {
|
||||
return nil
|
||||
@ -44,7 +44,7 @@ func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
elementSelect.SetSelected(presetDefault)
|
||||
elementSelect.Hide()
|
||||
|
||||
checkboxTitle := lang.L("parameterCheckbox")
|
||||
checkboxTitle := app.GetLocalizerService().GetMessage("parameterCheckbox")
|
||||
elementCheckbox := widget.NewCheck(checkboxTitle, func(b bool) {
|
||||
if b == true {
|
||||
parameter.SetEnable()
|
||||
@ -57,7 +57,7 @@ func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
|
||||
return []*widget.FormItem{
|
||||
{
|
||||
Text: lang.L("formPreset"),
|
||||
Text: app.GetLocalizerService().GetMessage("formPreset"),
|
||||
Widget: container.NewVBox(elementCheckbox, elementSelect),
|
||||
},
|
||||
}
|
@ -2,21 +2,21 @@ package libx264
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libx264"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder/libx264"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
)
|
||||
|
||||
func View(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
func View(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
|
||||
items := []*widget.FormItem{}
|
||||
|
||||
items = append(items, presetParameter(encoder)...)
|
||||
items = append(items, presetParameter(encoder, app)...)
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
func presetParameter(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
|
||||
parameter, err := encoder.GetParameter("preset")
|
||||
if err != nil {
|
||||
return nil
|
||||
@ -27,7 +27,7 @@ func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
presetDefault := ""
|
||||
|
||||
for _, name := range libx264.Presets {
|
||||
title := lang.L("preset_" + name)
|
||||
title := app.GetLocalizerService().GetMessage("preset_" + name)
|
||||
presetsForSelect = append(presetsForSelect, title)
|
||||
presets[title] = name
|
||||
if name == parameter.Get() {
|
||||
@ -44,7 +44,7 @@ func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
elementSelect.SetSelected(presetDefault)
|
||||
elementSelect.Hide()
|
||||
|
||||
checkboxTitle := lang.L("parameterCheckbox")
|
||||
checkboxTitle := app.GetLocalizerService().GetMessage("parameterCheckbox")
|
||||
elementCheckbox := widget.NewCheck(checkboxTitle, func(b bool) {
|
||||
if b == true {
|
||||
parameter.SetEnable()
|
||||
@ -57,7 +57,7 @@ func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
|
||||
return []*widget.FormItem{
|
||||
{
|
||||
Text: lang.L("formPreset"),
|
||||
Text: app.GetLocalizerService().GetMessage("formPreset"),
|
||||
Widget: container.NewVBox(elementCheckbox, elementSelect),
|
||||
},
|
||||
}
|
@ -2,21 +2,21 @@ package libx265
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libx265"
|
||||
"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"
|
||||
)
|
||||
|
||||
func View(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
func View(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
|
||||
items := []*widget.FormItem{}
|
||||
|
||||
items = append(items, presetParameter(encoder)...)
|
||||
items = append(items, presetParameter(encoder, app)...)
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
func presetParameter(encoder encoder.EncoderContract, app kernel.AppContract) []*widget.FormItem {
|
||||
parameter, err := encoder.GetParameter("preset")
|
||||
if err != nil {
|
||||
return nil
|
||||
@ -27,7 +27,7 @@ func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
presetDefault := ""
|
||||
|
||||
for _, name := range libx265.Presets {
|
||||
title := lang.L("preset_" + name)
|
||||
title := app.GetLocalizerService().GetMessage("preset_" + name)
|
||||
presetsForSelect = append(presetsForSelect, title)
|
||||
presets[title] = name
|
||||
if name == parameter.Get() {
|
||||
@ -44,7 +44,7 @@ func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
elementSelect.SetSelected(presetDefault)
|
||||
elementSelect.Hide()
|
||||
|
||||
checkboxTitle := lang.L("parameterCheckbox")
|
||||
checkboxTitle := app.GetLocalizerService().GetMessage("parameterCheckbox")
|
||||
elementCheckbox := widget.NewCheck(checkboxTitle, func(b bool) {
|
||||
if b == true {
|
||||
parameter.SetEnable()
|
||||
@ -57,7 +57,7 @@ func presetParameter(encoder encoder.EncoderContract) []*widget.FormItem {
|
||||
|
||||
return []*widget.FormItem{
|
||||
{
|
||||
Text: lang.L("formPreset"),
|
||||
Text: app.GetLocalizerService().GetMessage("formPreset"),
|
||||
Widget: container.NewVBox(elementCheckbox, elementSelect),
|
||||
},
|
||||
}
|
@ -1,74 +1,70 @@
|
||||
package view
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/window"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
"image/color"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func ConfiguringFFmpegUtilities(
|
||||
window window.WindowContract,
|
||||
currentPathFFmpeg string,
|
||||
currentPathFFprobe string,
|
||||
currentPathFFplay string,
|
||||
func (v View) SelectFFPath(
|
||||
currentPathFfmpeg string,
|
||||
currentPathFfprobe string,
|
||||
currentPathFfplay string,
|
||||
save func(ffmpegPath string, ffprobePath string, ffplayPath string) error,
|
||||
cancel func(),
|
||||
donwloadFFmpeg fyne.CanvasObject,
|
||||
) fyne.CanvasObject {
|
||||
donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error,
|
||||
) {
|
||||
errorMessage := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
errorMessage.TextSize = 16
|
||||
errorMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
|
||||
ffmpegPath, buttonFFmpeg, buttonFFmpegMessage := v.getButtonSelectFile(currentPathFfmpeg)
|
||||
ffprobePath, buttonFFprobe, buttonFFprobeMessage := v.getButtonSelectFile(currentPathFfprobe)
|
||||
ffplayPath, buttonFFplay, buttonFFplayMessage := v.getButtonSelectFile(currentPathFfplay)
|
||||
|
||||
link := widget.NewHyperlink("https://ffmpeg.org/download.html", &url.URL{
|
||||
Scheme: "https",
|
||||
Host: "ffmpeg.org",
|
||||
Path: "download.html",
|
||||
})
|
||||
|
||||
ffmpegPath, buttonFFmpeg, buttonFFmpegMessage := configuringFFmpegUtilitiesButtonSelectFile(window, currentPathFFmpeg)
|
||||
ffprobePath, buttonFFprobe, buttonFFprobeMessage := configuringFFmpegUtilitiesButtonSelectFile(window, currentPathFFprobe)
|
||||
ffplayPath, buttonFFplay, buttonFFplayMessage := configuringFFmpegUtilitiesButtonSelectFile(window, currentPathFFplay)
|
||||
|
||||
form := &widget.Form{
|
||||
Items: []*widget.FormItem{
|
||||
{
|
||||
Text: lang.L("titleDownloadLink"),
|
||||
Text: v.app.GetLocalizerService().GetMessage("titleDownloadLink"),
|
||||
Widget: link,
|
||||
},
|
||||
{
|
||||
Text: lang.L("pathToFfmpeg"),
|
||||
Text: v.app.GetLocalizerService().GetMessage("pathToFfmpeg"),
|
||||
Widget: buttonFFmpeg,
|
||||
},
|
||||
{
|
||||
Widget: container.NewHScroll(buttonFFmpegMessage),
|
||||
},
|
||||
{
|
||||
Text: lang.L("pathToFfprobe"),
|
||||
Text: v.app.GetLocalizerService().GetMessage("pathToFfprobe"),
|
||||
Widget: buttonFFprobe,
|
||||
},
|
||||
{
|
||||
Widget: container.NewHScroll(buttonFFprobeMessage),
|
||||
},
|
||||
{
|
||||
Text: lang.L("pathToFfplay"),
|
||||
Text: v.app.GetLocalizerService().GetMessage("pathToFfplay"),
|
||||
Widget: buttonFFplay,
|
||||
},
|
||||
{
|
||||
Widget: container.NewHScroll(buttonFFplayMessage),
|
||||
},
|
||||
{
|
||||
Widget: container.NewHScroll(errorMessage),
|
||||
Widget: errorMessage,
|
||||
},
|
||||
},
|
||||
SubmitText: lang.L("save"),
|
||||
SubmitText: v.app.GetLocalizerService().GetMessage("save"),
|
||||
OnSubmit: func() {
|
||||
err := save(*ffmpegPath, *ffprobePath, *ffplayPath)
|
||||
if err != nil {
|
||||
@ -78,25 +74,28 @@ func ConfiguringFFmpegUtilities(
|
||||
}
|
||||
if cancel != nil {
|
||||
form.OnCancel = cancel
|
||||
form.CancelText = lang.L("cancel")
|
||||
form.CancelText = v.app.GetLocalizerService().GetMessage("cancel")
|
||||
}
|
||||
selectFFPathTitle := v.app.GetLocalizerService().GetMessage("selectFFPathTitle")
|
||||
|
||||
if v.downloadFFmpeg.blockDownloadFFmpegContainer == nil {
|
||||
v.downloadFFmpeg.blockDownloadFFmpegContainer = v.blockDownloadFFmpeg(donwloadFFmpeg)
|
||||
}
|
||||
|
||||
selectFFPathTitle := lang.L("selectFFPathTitle")
|
||||
|
||||
return widget.NewCard(selectFFPathTitle, "", container.NewVBox(
|
||||
v.app.GetWindow().SetContent(widget.NewCard(selectFFPathTitle, "", container.NewVBox(
|
||||
form,
|
||||
donwloadFFmpeg,
|
||||
))
|
||||
v.downloadFFmpeg.blockDownloadFFmpegContainer,
|
||||
)))
|
||||
}
|
||||
|
||||
func configuringFFmpegUtilitiesButtonSelectFile(window window.WindowContract, path string) (filePath *string, button *widget.Button, buttonMessage *canvas.Text) {
|
||||
func (v View) getButtonSelectFile(path string) (filePath *string, button *widget.Button, buttonMessage *canvas.Text) {
|
||||
filePath = &path
|
||||
|
||||
buttonMessage = canvas.NewText(path, color.RGBA{R: 49, G: 127, B: 114, A: 255})
|
||||
buttonMessage.TextSize = 16
|
||||
buttonMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
|
||||
buttonTitle := lang.L("choose")
|
||||
buttonTitle := v.app.GetLocalizerService().GetMessage("choose")
|
||||
|
||||
var locationURI fyne.ListableURI
|
||||
if len(path) > 0 {
|
||||
@ -105,10 +104,10 @@ func configuringFFmpegUtilitiesButtonSelectFile(window window.WindowContract, pa
|
||||
}
|
||||
|
||||
button = widget.NewButton(buttonTitle, func() {
|
||||
window.NewFileOpen(func(r fyne.URIReadCloser, err error) {
|
||||
v.app.GetWindow().NewFileOpen(func(r fyne.URIReadCloser, err error) {
|
||||
if err != nil {
|
||||
buttonMessage.Text = err.Error()
|
||||
utils.SetStringErrorStyle(buttonMessage)
|
||||
setStringErrorStyle(buttonMessage)
|
||||
return
|
||||
}
|
||||
if r == nil {
|
||||
@ -118,12 +117,12 @@ func configuringFFmpegUtilitiesButtonSelectFile(window window.WindowContract, pa
|
||||
path = r.URI().Path()
|
||||
|
||||
buttonMessage.Text = r.URI().Path()
|
||||
utils.SetStringSuccessStyle(buttonMessage)
|
||||
setStringSuccessStyle(buttonMessage)
|
||||
|
||||
listableURI := storage.NewFileURI(filepath.Dir(r.URI().Path()))
|
||||
locationURI, _ = storage.ListerForURI(listableURI)
|
||||
}, locationURI)
|
||||
})
|
||||
|
||||
return filePath, button, buttonMessage
|
||||
return
|
||||
}
|
17
convertor/view_setting_button_download_ffmpeg_anyos.go
Normal file
17
convertor/view_setting_button_download_ffmpeg_anyos.go
Normal file
@ -0,0 +1,17 @@
|
||||
//go:build !windows && !linux
|
||||
// +build !windows,!linux
|
||||
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
func (v View) blockDownloadFFmpeg(
|
||||
donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error,
|
||||
) *fyne.Container {
|
||||
return container.NewVBox()
|
||||
}
|
@ -1,19 +1,21 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package gui
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"golang.org/x/image/colornames"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error) fyne.CanvasObject {
|
||||
func (v View) blockDownloadFFmpeg(
|
||||
donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error,
|
||||
) *fyne.Container {
|
||||
|
||||
errorDownloadFFmpegMessage := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
errorDownloadFFmpegMessage.TextSize = 16
|
||||
errorDownloadFFmpegMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
@ -26,7 +28,7 @@ func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progres
|
||||
|
||||
var buttonDownloadFFmpeg *widget.Button
|
||||
|
||||
buttonDownloadFFmpeg = widget.NewButton(lang.L("download"), func() {
|
||||
buttonDownloadFFmpeg = widget.NewButton(v.app.GetLocalizerService().GetMessage("download"), func() {
|
||||
fyne.Do(func() {
|
||||
buttonDownloadFFmpeg.Disable()
|
||||
})
|
||||
@ -42,16 +44,16 @@ func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progres
|
||||
|
||||
})
|
||||
|
||||
downloadFFmpegFromSiteMessage := lang.L("downloadFFmpegFromSite")
|
||||
downloadFFmpegFromSiteMessage := v.app.GetLocalizerService().GetMessage("downloadFFmpegFromSite")
|
||||
|
||||
return container.NewVBox(
|
||||
canvas.NewLine(colornames.Darkgreen),
|
||||
widget.NewCard(lang.L("buttonDownloadFFmpeg"), "", container.NewVBox(
|
||||
widget.NewCard(v.app.GetLocalizerService().GetMessage("buttonDownloadFFmpeg"), "", container.NewVBox(
|
||||
widget.NewRichTextFromMarkdown(
|
||||
downloadFFmpegFromSiteMessage+" [https://github.com/BtbN/FFmpeg-Builds/releases](https://github.com/BtbN/FFmpeg-Builds/releases)",
|
||||
),
|
||||
buttonDownloadFFmpeg,
|
||||
container.NewHScroll(errorDownloadFFmpegMessage),
|
||||
errorDownloadFFmpegMessage,
|
||||
progressDownloadFFmpegMessage,
|
||||
progressBar,
|
||||
)),
|
@ -1,19 +1,21 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package gui
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"golang.org/x/image/colornames"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error) fyne.CanvasObject {
|
||||
func (v View) blockDownloadFFmpeg(
|
||||
donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error,
|
||||
) *fyne.Container {
|
||||
|
||||
errorDownloadFFmpegMessage := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
errorDownloadFFmpegMessage.TextSize = 16
|
||||
errorDownloadFFmpegMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
@ -26,7 +28,7 @@ func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progres
|
||||
|
||||
var buttonDownloadFFmpeg *widget.Button
|
||||
|
||||
buttonDownloadFFmpeg = widget.NewButton(lang.L("download"), func() {
|
||||
buttonDownloadFFmpeg = widget.NewButton(v.app.GetLocalizerService().GetMessage("download"), func() {
|
||||
|
||||
go func() {
|
||||
fyne.Do(func() {
|
||||
@ -42,16 +44,16 @@ func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progres
|
||||
}()
|
||||
})
|
||||
|
||||
downloadFFmpegFromSiteMessage := lang.L("downloadFFmpegFromSite")
|
||||
downloadFFmpegFromSiteMessage := v.app.GetLocalizerService().GetMessage("downloadFFmpegFromSite")
|
||||
|
||||
return container.NewVBox(
|
||||
canvas.NewLine(colornames.Darkgreen),
|
||||
widget.NewCard(lang.L("buttonDownloadFFmpeg"), "", container.NewVBox(
|
||||
widget.NewCard(v.app.GetLocalizerService().GetMessage("buttonDownloadFFmpeg"), "", container.NewVBox(
|
||||
widget.NewRichTextFromMarkdown(
|
||||
downloadFFmpegFromSiteMessage+" [https://github.com/BtbN/FFmpeg-Builds/releases](https://github.com/BtbN/FFmpeg-Builds/releases)",
|
||||
),
|
||||
buttonDownloadFFmpeg,
|
||||
container.NewHScroll(errorDownloadFFmpegMessage),
|
||||
errorDownloadFFmpegMessage,
|
||||
progressDownloadFFmpegMessage,
|
||||
progressBar,
|
||||
)),
|
19
encoder/apng/encoder.go
Normal file
19
encoder/apng/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package apng
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "apng"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("apng", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "apng"
|
||||
formats := []string{"apng"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/bmp/encoder.go
Normal file
19
encoder/bmp/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package bmp
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "bmp"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("bmp", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "bmp"
|
||||
formats := []string{"bmp"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -24,15 +24,15 @@ type EncoderDataContract interface {
|
||||
NewEncoder() EncoderContract
|
||||
}
|
||||
|
||||
type data struct {
|
||||
type Data struct {
|
||||
title string
|
||||
formats []string
|
||||
fileType FileTypeContract
|
||||
encoder func() EncoderContract
|
||||
}
|
||||
|
||||
func NewData(title string, formats []string, fileType FileTypeContract, encoder func() EncoderContract) EncoderDataContract {
|
||||
return &data{
|
||||
func NewData(title string, formats []string, fileType FileTypeContract, encoder func() EncoderContract) *Data {
|
||||
return &Data{
|
||||
title: title,
|
||||
formats: formats,
|
||||
fileType: fileType,
|
||||
@ -40,19 +40,19 @@ func NewData(title string, formats []string, fileType FileTypeContract, encoder
|
||||
}
|
||||
}
|
||||
|
||||
func (data *data) GetTitle() string {
|
||||
func (data Data) GetTitle() string {
|
||||
return data.title
|
||||
}
|
||||
|
||||
func (data *data) GetFormats() []string {
|
||||
func (data Data) GetFormats() []string {
|
||||
return data.formats
|
||||
}
|
||||
|
||||
func (data *data) NewEncoder() EncoderContract {
|
||||
func (data Data) NewEncoder() EncoderContract {
|
||||
return data.encoder()
|
||||
}
|
||||
|
||||
func (data *data) GetFileType() FileTypeContract {
|
||||
func (data Data) GetFileType() FileTypeContract {
|
||||
return data.fileType
|
||||
}
|
||||
|
||||
@ -91,29 +91,29 @@ func GetListFileType() []FileTypeContract {
|
||||
}
|
||||
}
|
||||
|
||||
type encoder struct {
|
||||
type Encoder struct {
|
||||
name string
|
||||
parameters map[string]ParameterContract
|
||||
getParams func(parameters map[string]ParameterContract) []string
|
||||
}
|
||||
|
||||
func NewEncoder(name string, parameters map[string]ParameterContract, getParams func(parameters map[string]ParameterContract) []string) EncoderContract {
|
||||
return &encoder{
|
||||
func NewEncoder(name string, parameters map[string]ParameterContract, getParams func(parameters map[string]ParameterContract) []string) *Encoder {
|
||||
return &Encoder{
|
||||
name: name,
|
||||
parameters: parameters,
|
||||
getParams: getParams,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *encoder) GetName() string {
|
||||
func (e *Encoder) GetName() string {
|
||||
return e.name
|
||||
}
|
||||
|
||||
func (e *encoder) GetParams() []string {
|
||||
func (e *Encoder) GetParams() []string {
|
||||
return e.getParams(e.parameters)
|
||||
}
|
||||
|
||||
func (e *encoder) GetParameter(name string) (ParameterContract, error) {
|
||||
func (e *Encoder) GetParameter(name string) (ParameterContract, error) {
|
||||
if e.parameters[name] == nil {
|
||||
return nil, errors.New("parameter not found")
|
||||
}
|
||||
@ -121,15 +121,15 @@ func (e *encoder) GetParameter(name string) (ParameterContract, error) {
|
||||
return e.parameters[name], nil
|
||||
}
|
||||
|
||||
type parameter struct {
|
||||
type Parameter struct {
|
||||
name string
|
||||
isEnabled bool
|
||||
parameter string
|
||||
setParameter func(string) (string, error)
|
||||
}
|
||||
|
||||
func NewParameter(name string, isEnabled bool, defaultParameter string, setParameter func(string) (string, error)) ParameterContract {
|
||||
return ¶meter{
|
||||
func NewParameter(name string, isEnabled bool, defaultParameter string, setParameter func(string) (string, error)) *Parameter {
|
||||
return &Parameter{
|
||||
name: name,
|
||||
isEnabled: isEnabled,
|
||||
parameter: defaultParameter,
|
||||
@ -137,11 +137,11 @@ func NewParameter(name string, isEnabled bool, defaultParameter string, setParam
|
||||
}
|
||||
}
|
||||
|
||||
func (p *parameter) GetName() string {
|
||||
func (p *Parameter) GetName() string {
|
||||
return p.name
|
||||
}
|
||||
|
||||
func (p *parameter) Set(s string) (err error) {
|
||||
func (p *Parameter) Set(s string) (err error) {
|
||||
if p.setParameter != nil {
|
||||
s, err = p.setParameter(s)
|
||||
if err != nil {
|
||||
@ -152,18 +152,18 @@ func (p *parameter) Set(s string) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *parameter) Get() string {
|
||||
func (p *Parameter) Get() string {
|
||||
return p.parameter
|
||||
}
|
||||
|
||||
func (p *parameter) IsEnabled() bool {
|
||||
func (p *Parameter) IsEnabled() bool {
|
||||
return p.isEnabled
|
||||
}
|
||||
|
||||
func (p *parameter) SetEnable() {
|
||||
func (p *Parameter) SetEnable() {
|
||||
p.isEnabled = true
|
||||
}
|
||||
|
||||
func (p *parameter) SetDisable() {
|
||||
func (p *Parameter) SetDisable() {
|
||||
p.isEnabled = false
|
||||
}
|
19
encoder/flv/encoder.go
Normal file
19
encoder/flv/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package flv
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "flv"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("flv", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "flv"
|
||||
formats := []string{"flv"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/gif/encoder.go
Normal file
19
encoder/gif/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package gif
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "gif"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("gif", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "gif"
|
||||
formats := []string{"gif"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -2,7 +2,7 @@ package h264_nvenc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
@ -20,11 +20,11 @@ var Presets = []string{
|
||||
"losslesshp",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
params := []string{"-c:v", "h264_nvenc"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
@ -34,17 +34,17 @@ func NewEncoder() encoder.EncoderContract {
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("h264_nvenc", parameters, getParams)
|
||||
return encoder2.NewEncoder("h264_nvenc", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "h264_nvenc"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
func newParameterPreset() encoder2.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
@ -54,5 +54,5 @@ func newParameterPreset() encoder.ParameterContract {
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
return encoder.NewParameter("preset", false, "default", setParameter)
|
||||
return encoder2.NewParameter("preset", false, "default", setParameter)
|
||||
}
|
19
encoder/libmp3lame/encoder.go
Normal file
19
encoder/libmp3lame/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package libmp3lame
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:a", "libmp3lame"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libmp3lame", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libmp3lame"
|
||||
formats := []string{"mp3"}
|
||||
fileType := encoder2.FileType(encoder2.Audio)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/libshine/encoder.go
Normal file
19
encoder/libshine/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package libshine
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:a", "libshine"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libshine", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libshine"
|
||||
formats := []string{"mp3"}
|
||||
fileType := encoder2.FileType(encoder2.Audio)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/libtwolame/encoder.go
Normal file
19
encoder/libtwolame/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package libtwolame
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:a", "libtwolame"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libtwolame", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libtwolame"
|
||||
formats := []string{"mp2"}
|
||||
fileType := encoder2.FileType(encoder2.Audio)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/libvpx/encoder.go
Normal file
19
encoder/libvpx/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package libvpx
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "libvpx"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libvpx", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libvpx"
|
||||
formats := []string{"webm", "mkv"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/libvpx_vp9/encoder.go
Normal file
19
encoder/libvpx_vp9/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package libvpx_vp9
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "libvpx-vp9"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libvpx_vp9", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libvpx-vp9"
|
||||
formats := []string{"webm", "mkv"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/libwebp/encoder.go
Normal file
19
encoder/libwebp/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package libwebp
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "libwebp"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libwebp", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libwebp"
|
||||
formats := []string{"webp"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/libwebp_anim/encoder.go
Normal file
19
encoder/libwebp_anim/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package libwebp_anim
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "libwebp_anim"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libwebp_anim", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libwebp_anim"
|
||||
formats := []string{"webp"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -2,7 +2,7 @@ package libx264
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
@ -18,11 +18,11 @@ var Presets = []string{
|
||||
"placebo",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
params := []string{"-c:v", "libx264"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
@ -32,17 +32,17 @@ func NewEncoder() encoder.EncoderContract {
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libx264", parameters, getParams)
|
||||
return encoder2.NewEncoder("libx264", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libx264"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
func newParameterPreset() encoder2.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
@ -52,5 +52,5 @@ func newParameterPreset() encoder.ParameterContract {
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
return encoder.NewParameter("preset", false, "medium", setParameter)
|
||||
return encoder2.NewParameter("preset", false, "medium", setParameter)
|
||||
}
|
@ -2,7 +2,7 @@ package libx265
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
@ -18,11 +18,11 @@ var Presets = []string{
|
||||
"placebo",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
params := []string{"-c:v", "libx265"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
@ -32,17 +32,17 @@ func NewEncoder() encoder.EncoderContract {
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libx265", parameters, getParams)
|
||||
return encoder2.NewEncoder("libx265", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libx265"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
func newParameterPreset() encoder2.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
@ -52,5 +52,5 @@ func newParameterPreset() encoder.ParameterContract {
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
return encoder.NewParameter("preset", false, "medium", setParameter)
|
||||
return encoder2.NewParameter("preset", false, "medium", setParameter)
|
||||
}
|
19
encoder/libxvid/encoder.go
Normal file
19
encoder/libxvid/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package libxvid
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "libxvid"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libxvid", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "libxvid"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/mjpeg/encoder.go
Normal file
19
encoder/mjpeg/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package mjpeg
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "mjpeg"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("mjpeg", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "mjpeg"
|
||||
formats := []string{"jpg"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/mp2/encoder.go
Normal file
19
encoder/mp2/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package mp2
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:a", "mp2"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("mp2", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "mp2"
|
||||
formats := []string{"mp2"}
|
||||
fileType := encoder2.FileType(encoder2.Audio)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/mp2fixed/encoder.go
Normal file
19
encoder/mp2fixed/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package mp2fixed
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:a", "mp2fixed"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("mp2fixed", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "mp2fixed"
|
||||
formats := []string{"mp2"}
|
||||
fileType := encoder2.FileType(encoder2.Audio)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/mpeg1video/encoder.go
Normal file
19
encoder/mpeg1video/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package mpeg1video
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "mpeg1video"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("mpeg1video", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "mpeg1video"
|
||||
formats := []string{"mpg", "mpeg"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/mpeg2video/encoder.go
Normal file
19
encoder/mpeg2video/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package mpeg2video
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "mpeg2video"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("mpeg2video", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "mpeg2video"
|
||||
formats := []string{"mpg", "mpeg"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/mpeg4/encoder.go
Normal file
19
encoder/mpeg4/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package mpeg4
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "mpeg4"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("mpeg4", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "mpeg4"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/msmpeg4/encoder.go
Normal file
19
encoder/msmpeg4/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package msmpeg4
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "msmpeg4"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("msmpeg4", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "msmpeg4"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/msmpeg4v2/encoder.go
Normal file
19
encoder/msmpeg4v2/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package msmpeg4v2
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "msmpeg4v2"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("msmpeg4v2", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "msmpeg4v2"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/msvideo1/encoder.go
Normal file
19
encoder/msvideo1/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package msvideo1
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "msvideo1"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("msvideo1", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "msvideo1"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/png/encoder.go
Normal file
19
encoder/png/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package png
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "png"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("png", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "png"
|
||||
formats := []string{"png"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/qtrle/encoder.go
Normal file
19
encoder/qtrle/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package qtrle
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "qtrle"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("qtrle", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "qtrle"
|
||||
formats := []string{"mov"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/sgi/encoder.go
Normal file
19
encoder/sgi/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package sgi
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "sgi"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("sgi", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "sgi"
|
||||
formats := []string{"sgi"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/tiff/encoder.go
Normal file
19
encoder/tiff/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package tiff
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "tiff"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("tiff", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "tiff"
|
||||
formats := []string{"tiff"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/wmav1/encoder.go
Normal file
19
encoder/wmav1/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package wmav1
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:a", "wmav1"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("wmav1", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "wmav1"
|
||||
formats := []string{"wma"}
|
||||
fileType := encoder2.FileType(encoder2.Audio)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/wmav2/encoder.go
Normal file
19
encoder/wmav2/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package wmav2
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:a", "wmav2"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("wmav2", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "wmav2"
|
||||
formats := []string{"wma"}
|
||||
fileType := encoder2.FileType(encoder2.Audio)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/wmv1/encoder.go
Normal file
19
encoder/wmv1/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package wmv1
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "wmv1"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("wmv1", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "wmv1"
|
||||
formats := []string{"wmv"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/wmv2/encoder.go
Normal file
19
encoder/wmv2/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package wmv2
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "wmv2"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("wmv2", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "wmv2"
|
||||
formats := []string{"wmv"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
19
encoder/xbm/encoder.go
Normal file
19
encoder/xbm/encoder.go
Normal file
@ -0,0 +1,19 @@
|
||||
package xbm
|
||||
|
||||
import encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
return []string{"-c:v", "xbm"}
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("xbm", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
title := "xbm"
|
||||
formats := []string{"xbm"}
|
||||
fileType := encoder2.FileType(encoder2.Image)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
39
error/view.go
Normal file
39
error/view.go
Normal file
@ -0,0 +1,39 @@
|
||||
package error
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/localizer"
|
||||
)
|
||||
|
||||
type ViewContract interface {
|
||||
PanicError(err error)
|
||||
}
|
||||
|
||||
type View struct {
|
||||
app kernel.AppContract
|
||||
}
|
||||
|
||||
func NewView(app kernel.AppContract) *View {
|
||||
return &View{
|
||||
app: app,
|
||||
}
|
||||
}
|
||||
|
||||
func (v View) PanicError(err error) {
|
||||
messageHead := v.app.GetLocalizerService().GetMessage("error")
|
||||
|
||||
v.app.GetWindow().SetContent(container.NewBorder(
|
||||
container.NewVBox(
|
||||
widget.NewLabel(messageHead),
|
||||
widget.NewLabel(err.Error()),
|
||||
),
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
localizer.LanguageSelectionForm(v.app.GetLocalizerService(), func(lang kernel.Lang) {
|
||||
v.PanicError(err)
|
||||
}),
|
||||
))
|
||||
}
|
178
handler/convertor.go
Normal file
178
handler/convertor.go
Normal file
@ -0,0 +1,178 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor/view"
|
||||
error2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/error"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/helper"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/setting"
|
||||
)
|
||||
|
||||
type ConvertorHandlerContract interface {
|
||||
MainConvertor()
|
||||
FfPathSelection()
|
||||
GetFfmpegVersion() (string, error)
|
||||
GetFfprobeVersion() (string, error)
|
||||
GetFfplayVersion() (string, error)
|
||||
}
|
||||
|
||||
type ConvertorHandler struct {
|
||||
app kernel.AppContract
|
||||
convertorView convertor.ViewContract
|
||||
errorView error2.ViewContract
|
||||
convertorRepository convertor.RepositoryContract
|
||||
settingDirectoryForSaving setting.DirectoryForSavingContract
|
||||
itemsToConvertService kernel.ItemsToConvertContract
|
||||
}
|
||||
|
||||
func NewConvertorHandler(
|
||||
app kernel.AppContract,
|
||||
convertorView convertor.ViewContract,
|
||||
errorView error2.ViewContract,
|
||||
convertorRepository convertor.RepositoryContract,
|
||||
settingDirectoryForSaving setting.DirectoryForSavingContract,
|
||||
itemsToConvertService kernel.ItemsToConvertContract,
|
||||
) *ConvertorHandler {
|
||||
return &ConvertorHandler{
|
||||
app: app,
|
||||
convertorView: convertorView,
|
||||
errorView: errorView,
|
||||
convertorRepository: convertorRepository,
|
||||
settingDirectoryForSaving: settingDirectoryForSaving,
|
||||
itemsToConvertService: itemsToConvertService,
|
||||
}
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) MainConvertor() {
|
||||
if h.checkingFFPathUtilities() == true {
|
||||
formats, err := h.app.GetConvertorService().GetSupportFormats()
|
||||
if err != nil {
|
||||
h.errorView.PanicError(err)
|
||||
return
|
||||
}
|
||||
conversion := view.NewConversion(h.app, formats, h.runConvert, h.settingDirectoryForSaving, h.itemsToConvertService)
|
||||
h.convertorView.Main(conversion)
|
||||
return
|
||||
}
|
||||
h.convertorView.SelectFFPath("", "", "", h.saveSettingFFPath, nil, h.downloadFFmpeg)
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) FfPathSelection() {
|
||||
ffmpeg := h.convertorRepository.GetPathFfmpeg()
|
||||
ffprobe := h.convertorRepository.GetPathFfprobe()
|
||||
ffplay := h.convertorRepository.GetPathFfplay()
|
||||
h.convertorView.SelectFFPath(ffmpeg, ffprobe, ffplay, h.saveSettingFFPath, h.MainConvertor, h.downloadFFmpeg)
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) GetFfmpegVersion() (string, error) {
|
||||
return h.app.GetConvertorService().GetFFmpegVesrion()
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) GetFfprobeVersion() (string, error) {
|
||||
return h.app.GetConvertorService().GetFFprobeVersion()
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) GetFfplayVersion() (string, error) {
|
||||
return h.app.GetConvertorService().GetFFplayVersion()
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) runConvert(setting view.HandleConvertSetting) {
|
||||
h.app.GetWindow().GetLayout().GetRightTabs().SelectFileQueueTab()
|
||||
|
||||
for _, item := range h.itemsToConvertService.GetItems() {
|
||||
file := item.GetFile()
|
||||
if file == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
h.app.GetQueue().Add(&kernel.ConvertSetting{
|
||||
VideoFileInput: *file,
|
||||
VideoFileOut: kernel.File{
|
||||
Path: setting.DirectoryForSave + helper.PathSeparator() + file.Name + "." + setting.Format,
|
||||
Name: file.Name,
|
||||
Ext: "." + setting.Format,
|
||||
},
|
||||
OverwriteOutputFiles: setting.OverwriteOutputFiles,
|
||||
Encoder: setting.Encoder,
|
||||
})
|
||||
}
|
||||
h.itemsToConvertService.AfterAddingQueue()
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) checkingFFPathUtilities() bool {
|
||||
if h.checkingFFPath() == true {
|
||||
return true
|
||||
}
|
||||
|
||||
pathsToFF := getPathsToFF()
|
||||
for _, item := range pathsToFF {
|
||||
ffmpegChecking, _ := h.app.GetConvertorService().ChangeFFmpegPath(item.FFmpeg)
|
||||
if ffmpegChecking == false {
|
||||
continue
|
||||
}
|
||||
ffprobeChecking, _ := h.app.GetConvertorService().ChangeFFprobePath(item.FFprobe)
|
||||
if ffprobeChecking == false {
|
||||
continue
|
||||
}
|
||||
|
||||
ffplayChecking, _ := h.app.GetConvertorService().ChangeFFplayPath(item.FFplay)
|
||||
if ffplayChecking == false {
|
||||
continue
|
||||
}
|
||||
_ = h.convertorRepository.SavePathFfmpeg(item.FFmpeg)
|
||||
_ = h.convertorRepository.SavePathFfprobe(item.FFprobe)
|
||||
_ = h.convertorRepository.SavePathFfplay(item.FFplay)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) saveSettingFFPath(ffmpegPath string, ffprobePath string, ffplayPath string) error {
|
||||
ffmpegChecking, _ := h.app.GetConvertorService().ChangeFFmpegPath(ffmpegPath)
|
||||
if ffmpegChecking == false {
|
||||
errorText := h.app.GetLocalizerService().GetMessage("errorFFmpeg")
|
||||
return errors.New(errorText)
|
||||
}
|
||||
|
||||
ffprobeChecking, _ := h.app.GetConvertorService().ChangeFFprobePath(ffprobePath)
|
||||
if ffprobeChecking == false {
|
||||
errorText := h.app.GetLocalizerService().GetMessage("errorFFprobe")
|
||||
return errors.New(errorText)
|
||||
}
|
||||
|
||||
ffplayChecking, _ := h.app.GetConvertorService().ChangeFFplayPath(ffplayPath)
|
||||
if ffplayChecking == false {
|
||||
errorText := h.app.GetLocalizerService().GetMessage("errorFFplay")
|
||||
return errors.New(errorText)
|
||||
}
|
||||
|
||||
_ = h.convertorRepository.SavePathFfmpeg(ffmpegPath)
|
||||
_ = h.convertorRepository.SavePathFfprobe(ffprobePath)
|
||||
_ = h.convertorRepository.SavePathFfplay(ffplayPath)
|
||||
|
||||
h.MainConvertor()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) checkingFFPath() bool {
|
||||
_, err := h.app.GetConvertorService().GetFFmpegVesrion()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
_, err = h.app.GetConvertorService().GetFFprobeVersion()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
_, err = h.app.GetConvertorService().GetFFplayVersion()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
18
handler/convertor_anyos.go
Normal file
18
handler/convertor_anyos.go
Normal file
@ -0,0 +1,18 @@
|
||||
//go:build !windows && !linux
|
||||
// +build !windows,!linux
|
||||
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
)
|
||||
|
||||
func getPathsToFF() []kernel.FFPathUtilities {
|
||||
return []kernel.FFPathUtilities{{FFmpeg: "ffmpeg/bin/ffmpeg", FFprobe: "ffmpeg/bin/ffprobe", FFplay: "ffmpeg/bin/ffplay"}, {FFmpeg: "ffmpeg", FFprobe: "ffprobe", FFplay: "ffplay"}}
|
||||
}
|
||||
|
||||
func (h ConvertorHandler) downloadFFmpeg(progressBar *widget.ProgressBar, progressMessage *canvas.Text) (err error) {
|
||||
return nil
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package service
|
||||
package handler
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"errors"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
"github.com/ulikunitz/xz"
|
||||
"io"
|
||||
"net/http"
|
||||
@ -18,72 +17,59 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func startDownload(app application.AppContract, progressBar *widget.ProgressBar, progressMessage *canvas.Text, save func(ffmpegPath string, ffprobePath string, ffplayPath string) error) error {
|
||||
var err error
|
||||
func getPathsToFF() []kernel.FFPathUtilities {
|
||||
return []kernel.FFPathUtilities{{FFmpeg: "ffmpeg/bin/ffmpeg", FFprobe: "ffmpeg/bin/ffprobe", FFplay: "ffmpeg/bin/ffplay"}, {FFmpeg: "ffmpeg", FFprobe: "ffprobe", FFplay: "ffplay"}}
|
||||
}
|
||||
|
||||
dir, err := localSharePath()
|
||||
func (h ConvertorHandler) downloadFFmpeg(progressBar *widget.ProgressBar, progressMessage *canvas.Text) (err error) {
|
||||
isDirectoryFFmpeg := isDirectory("ffmpeg")
|
||||
if isDirectoryFFmpeg == false {
|
||||
err = os.Mkdir("ffmpeg", 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dir = filepath.Join(dir, "fyne", app.FyneApp().UniqueID())
|
||||
err = os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("downloadRun")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("downloadRun")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = downloadFile(dir+"/ffmpeg.tar.xz", "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz", progressBar)
|
||||
err = downloadFile("ffmpeg/ffmpeg.tar.xz", "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz", progressBar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("unzipRun")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("unzipRun")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = unTarXz(dir+"/ffmpeg.tar.xz", dir, progressBar)
|
||||
err = unTarXz("ffmpeg/ffmpeg.tar.xz", "ffmpeg", progressBar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = os.Remove(dir + "/ffmpeg.tar.xz")
|
||||
_ = os.Remove("ffmpeg/ffmpeg.tar.xz")
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("testFF")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("testFF")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
|
||||
err = save(
|
||||
dir+"/ffmpeg-master-latest-linux64-gpl/bin/ffmpeg",
|
||||
dir+"/ffmpeg-master-latest-linux64-gpl/bin/ffprobe",
|
||||
dir+"/ffmpeg-master-latest-linux64-gpl/bin/ffplay",
|
||||
err = h.saveSettingFFPath(
|
||||
"ffmpeg/ffmpeg-master-latest-linux64-gpl/bin/ffmpeg",
|
||||
"ffmpeg/ffmpeg-master-latest-linux64-gpl/bin/ffprobe",
|
||||
"ffmpeg/ffmpeg-master-latest-linux64-gpl/bin/ffplay",
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("completedQueue")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("completedQueue")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func localSharePath() (string, error) {
|
||||
xdgDataHome := os.Getenv("XDG_DATA_HOME")
|
||||
if xdgDataHome != "" {
|
||||
return xdgDataHome, nil
|
||||
}
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(homeDir, ".local", "share"), nil
|
||||
}
|
||||
|
||||
func downloadFile(filepath string, url string, progressBar *widget.ProgressBar) (err error) {
|
||||
progressBar.Value = 0
|
||||
progressBar.Max = 100
|
||||
@ -234,3 +220,12 @@ func unTarXz(fileTar string, directory string, progressBar *widget.ProgressBar)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func isDirectory(path string) bool {
|
||||
fileInfo, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return fileInfo.IsDir()
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package service
|
||||
package handler
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"errors"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -18,50 +17,52 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func startDownload(app application.AppContract, progressBar *widget.ProgressBar, progressMessage *canvas.Text, save func(ffmpegPath string, ffprobePath string, ffplayPath string) error) error {
|
||||
var err error
|
||||
func getPathsToFF() []kernel.FFPathUtilities {
|
||||
return []kernel.FFPathUtilities{{FFmpeg: "ffmpeg\\bin\\ffmpeg.exe", FFprobe: "ffmpeg\\bin\\ffprobe.exe", FFplay: "ffmpeg\\bin\\ffplay.exe"}}
|
||||
}
|
||||
|
||||
dir := os.Getenv("APPDATA")
|
||||
dir = filepath.Join(dir, "fyne", app.FyneApp().UniqueID())
|
||||
err = os.MkdirAll(dir, 0755)
|
||||
func (h ConvertorHandler) downloadFFmpeg(progressBar *widget.ProgressBar, progressMessage *canvas.Text) (err error) {
|
||||
isDirectoryFFmpeg := isDirectory("ffmpeg")
|
||||
if isDirectoryFFmpeg == false {
|
||||
err = os.Mkdir("ffmpeg", 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("downloadRun")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = downloadFile("ffmpeg/ffmpeg.zip", "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip", progressBar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("unzipRun")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("downloadRun")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = downloadFile(dir+"/ffmpeg.zip", "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip", progressBar)
|
||||
err = unZip("ffmpeg/ffmpeg.zip", "ffmpeg", progressBar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = os.Remove("ffmpeg/ffmpeg.zip")
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("testFF")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("unzipRun")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = unZip(dir+"/ffmpeg.zip", dir, progressBar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = os.Remove(dir + "/ffmpeg.zip")
|
||||
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("testFF")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = save(
|
||||
dir+"/ffmpeg-master-latest-win64-gpl/bin/ffmpeg.exe",
|
||||
dir+"/ffmpeg-master-latest-win64-gpl/bin/ffprobe.exe",
|
||||
dir+"/ffmpeg-master-latest-win64-gpl/bin/ffplay.exe",
|
||||
err = h.saveSettingFFPath(
|
||||
"ffmpeg/ffmpeg-master-latest-win64-gpl/bin/ffmpeg.exe",
|
||||
"ffmpeg/ffmpeg-master-latest-win64-gpl/bin/ffprobe.exe",
|
||||
"ffmpeg/ffmpeg-master-latest-win64-gpl/bin/ffplay.exe",
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("completedQueue")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("completedQueue")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
|
||||
@ -173,3 +174,12 @@ func unZip(fileZip string, directory string, progressBar *widget.ProgressBar) er
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func isDirectory(path string) bool {
|
||||
fileInfo, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return fileInfo.IsDir()
|
||||
}
|
32
handler/main.go
Normal file
32
handler/main.go
Normal file
@ -0,0 +1,32 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
)
|
||||
|
||||
type MainHandler struct {
|
||||
app kernel.AppContract
|
||||
convertorHandler ConvertorHandlerContract
|
||||
menuHandler MenuHandlerContract
|
||||
}
|
||||
|
||||
func NewMainHandler(
|
||||
app kernel.AppContract,
|
||||
convertorHandler ConvertorHandlerContract,
|
||||
menuHandler MenuHandlerContract,
|
||||
) *MainHandler {
|
||||
return &MainHandler{
|
||||
app: app,
|
||||
convertorHandler: convertorHandler,
|
||||
menuHandler: menuHandler,
|
||||
}
|
||||
}
|
||||
|
||||
func (h MainHandler) Start() {
|
||||
if h.app.GetLocalizerService().IsStartWithLanguageSelection() {
|
||||
h.menuHandler.LanguageSelection()
|
||||
return
|
||||
}
|
||||
|
||||
h.convertorHandler.MainConvertor()
|
||||
}
|
143
handler/menu.go
Normal file
143
handler/menu.go
Normal file
@ -0,0 +1,143 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/localizer"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/menu"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/theme"
|
||||
)
|
||||
|
||||
type MenuHandlerContract interface {
|
||||
GetMainMenu() *fyne.MainMenu
|
||||
LanguageSelection()
|
||||
}
|
||||
|
||||
type MenuHandler struct {
|
||||
app kernel.AppContract
|
||||
convertorHandler ConvertorHandlerContract
|
||||
menuView menu.ViewContract
|
||||
menuViewSetting menu.ViewSettingContract
|
||||
localizerView localizer.ViewContract
|
||||
themeService theme.ThemeContract
|
||||
}
|
||||
|
||||
func NewMenuHandler(
|
||||
app kernel.AppContract,
|
||||
convertorHandler ConvertorHandlerContract,
|
||||
menuView menu.ViewContract,
|
||||
menuViewSetting menu.ViewSettingContract,
|
||||
localizerView localizer.ViewContract,
|
||||
themeService theme.ThemeContract,
|
||||
) *MenuHandler {
|
||||
return &MenuHandler{
|
||||
app: app,
|
||||
convertorHandler: convertorHandler,
|
||||
menuView: menuView,
|
||||
menuViewSetting: menuViewSetting,
|
||||
localizerView: localizerView,
|
||||
themeService: themeService,
|
||||
}
|
||||
}
|
||||
|
||||
func (h MenuHandler) GetMainMenu() *fyne.MainMenu {
|
||||
settings := h.getMenuSettings()
|
||||
help := h.getMenuHelp()
|
||||
|
||||
return fyne.NewMainMenu(settings, help)
|
||||
}
|
||||
|
||||
func (h MenuHandler) getMenuSettings() *fyne.Menu {
|
||||
quit := fyne.NewMenuItem(h.app.GetLocalizerService().GetMessage("exit"), nil)
|
||||
quit.IsQuit = true
|
||||
h.app.GetLocalizerService().AddChangeCallback("exit", func(text string) {
|
||||
quit.Label = text
|
||||
})
|
||||
|
||||
settingsSelection := fyne.NewMenuItem(h.app.GetLocalizerService().GetMessage("settings"), h.settingsSelection)
|
||||
h.app.GetLocalizerService().AddChangeCallback("settings", func(text string) {
|
||||
settingsSelection.Label = text
|
||||
})
|
||||
|
||||
ffPathSelection := fyne.NewMenuItem(h.app.GetLocalizerService().GetMessage("changeFFPath"), h.convertorHandler.FfPathSelection)
|
||||
h.app.GetLocalizerService().AddChangeCallback("changeFFPath", func(text string) {
|
||||
ffPathSelection.Label = text
|
||||
})
|
||||
|
||||
settings := fyne.NewMenu(h.app.GetLocalizerService().GetMessage("settings"), settingsSelection, ffPathSelection, quit)
|
||||
h.app.GetLocalizerService().AddChangeCallback("settings", func(text string) {
|
||||
settings.Label = text
|
||||
settings.Refresh()
|
||||
})
|
||||
|
||||
return settings
|
||||
}
|
||||
|
||||
func (h MenuHandler) getMenuHelp() *fyne.Menu {
|
||||
about := fyne.NewMenuItem(h.app.GetLocalizerService().GetMessage("about"), h.openAbout)
|
||||
h.app.GetLocalizerService().AddChangeCallback("about", func(text string) {
|
||||
about.Label = text
|
||||
})
|
||||
|
||||
gratitude := fyne.NewMenuItem(h.app.GetLocalizerService().GetMessage("gratitude"), h.menuView.Gratitude)
|
||||
h.app.GetLocalizerService().AddChangeCallback("gratitude", func(text string) {
|
||||
gratitude.Label = text
|
||||
})
|
||||
|
||||
helpFFplay := fyne.NewMenuItem(h.app.GetLocalizerService().GetMessage("helpFFplay"), h.menuView.HelpFFplay)
|
||||
h.app.GetLocalizerService().AddChangeCallback("helpFFplay", func(text string) {
|
||||
helpFFplay.Label = text
|
||||
})
|
||||
|
||||
help := fyne.NewMenu(h.app.GetLocalizerService().GetMessage("help"), helpFFplay, about, gratitude)
|
||||
h.app.GetLocalizerService().AddChangeCallback("help", func(text string) {
|
||||
help.Label = text
|
||||
help.Refresh()
|
||||
})
|
||||
|
||||
return help
|
||||
}
|
||||
|
||||
func (h MenuHandler) openAbout() {
|
||||
ffmpeg, err := h.convertorHandler.GetFfmpegVersion()
|
||||
if err != nil {
|
||||
ffmpeg = h.app.GetLocalizerService().GetMessage("errorFFmpegVersion")
|
||||
}
|
||||
ffprobe, err := h.convertorHandler.GetFfprobeVersion()
|
||||
if err != nil {
|
||||
ffprobe = h.app.GetLocalizerService().GetMessage("errorFFprobeVersion")
|
||||
}
|
||||
ffplay, err := h.convertorHandler.GetFfplayVersion()
|
||||
if err != nil {
|
||||
ffplay = h.app.GetLocalizerService().GetMessage("errorFFplayVersion")
|
||||
}
|
||||
|
||||
h.menuView.About(ffmpeg, ffprobe, ffplay)
|
||||
}
|
||||
|
||||
func (h MenuHandler) LanguageSelection() {
|
||||
h.localizerView.LanguageSelection(func(lang kernel.Lang) {
|
||||
h.convertorHandler.MainConvertor()
|
||||
})
|
||||
}
|
||||
|
||||
func (h MenuHandler) settingsSelection() {
|
||||
save := func(setting *menu.SettingForm) error {
|
||||
err := h.app.GetLocalizerService().SetCurrentLanguage(setting.Language, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = h.themeService.SetCurrentTheme(setting.ThemeInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
h.convertorHandler.MainConvertor()
|
||||
return nil
|
||||
}
|
||||
cancel := func() {
|
||||
h.convertorHandler.MainConvertor()
|
||||
}
|
||||
h.menuViewSetting.Main(save, cancel)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package utils
|
||||
package helper
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
@ -1,7 +1,7 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package utils
|
||||
package helper
|
||||
|
||||
func PathSeparator() string {
|
||||
return "/"
|
@ -1,7 +1,7 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package utils
|
||||
package helper
|
||||
|
||||
func PathSeparator() string {
|
||||
return "\\"
|
@ -1,7 +1,7 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package utils
|
||||
package helper
|
||||
|
||||
import (
|
||||
"os/exec"
|
@ -1,7 +1,7 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package utils
|
||||
package helper
|
||||
|
||||
import (
|
||||
"os/exec"
|
@ -1,137 +0,0 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/convertor"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/setting"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AppContract interface {
|
||||
FyneApp() fyne.App
|
||||
GetSetting() setting.SettingContract
|
||||
GetProgressBarService() convertor.ProgressBarContract
|
||||
GetFFmpegService() ffmpeg.UtilitiesContract
|
||||
GetConvertorService() convertor.ConvertorContract
|
||||
GetItemsToConvert() convertor.ItemsToConvertContract
|
||||
GetQueueService() convertor.QueueListContract
|
||||
Run()
|
||||
AfterClosing()
|
||||
RunConvertor()
|
||||
}
|
||||
|
||||
type application struct {
|
||||
fyneApp fyne.App
|
||||
setting setting.SettingContract
|
||||
progressBarService convertor.ProgressBarContract
|
||||
ffmpegService ffmpeg.UtilitiesContract
|
||||
itemsToConvert convertor.ItemsToConvertContract
|
||||
queueService convertor.QueueListContract
|
||||
convertorService convertor.ConvertorContract
|
||||
}
|
||||
|
||||
func NewApp(
|
||||
fyneApp fyne.App,
|
||||
setting setting.SettingContract,
|
||||
progressBarService convertor.ProgressBarContract,
|
||||
ffmpegService ffmpeg.UtilitiesContract,
|
||||
itemsToConvert convertor.ItemsToConvertContract,
|
||||
queueService convertor.QueueListContract,
|
||||
convertorService convertor.ConvertorContract,
|
||||
) AppContract {
|
||||
return &application{
|
||||
fyneApp: fyneApp,
|
||||
setting: setting,
|
||||
progressBarService: progressBarService,
|
||||
ffmpegService: ffmpegService,
|
||||
itemsToConvert: itemsToConvert,
|
||||
queueService: queueService,
|
||||
convertorService: convertorService,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *application) FyneApp() fyne.App {
|
||||
return a.fyneApp
|
||||
}
|
||||
|
||||
func (a *application) GetSetting() setting.SettingContract {
|
||||
return a.setting
|
||||
}
|
||||
|
||||
func (a *application) GetProgressBarService() convertor.ProgressBarContract {
|
||||
return a.progressBarService
|
||||
}
|
||||
|
||||
func (a *application) GetFFmpegService() ffmpeg.UtilitiesContract {
|
||||
return a.ffmpegService
|
||||
}
|
||||
|
||||
func (a *application) GetItemsToConvert() convertor.ItemsToConvertContract {
|
||||
return a.itemsToConvert
|
||||
}
|
||||
|
||||
func (a *application) GetQueueService() convertor.QueueListContract {
|
||||
return a.queueService
|
||||
}
|
||||
|
||||
func (a *application) GetConvertorService() convertor.ConvertorContract {
|
||||
return a.convertorService
|
||||
}
|
||||
|
||||
func (a *application) Run() {
|
||||
a.fyneApp.Run()
|
||||
}
|
||||
|
||||
func (a *application) RunConvertor() {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(time.Millisecond * 3000)
|
||||
queueId, queue := a.queueService.Next()
|
||||
if queue == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
queue.Status = convertor.StatusType(convertor.InProgress)
|
||||
a.queueService.EventChangeQueue(queueId, queue)
|
||||
|
||||
if a.progressBarService.GetContainer().Hidden {
|
||||
a.progressBarService.GetContainer().Show()
|
||||
}
|
||||
|
||||
totalDuration := float64(0)
|
||||
ffprobe, err := a.ffmpegService.GetFFprobe()
|
||||
if err == nil {
|
||||
totalDuration, err = ffprobe.GetTotalDuration(&queue.Setting.FileInput)
|
||||
if err != nil {
|
||||
totalDuration = float64(0)
|
||||
}
|
||||
}
|
||||
|
||||
progress := a.progressBarService.GetProgressbar(
|
||||
totalDuration,
|
||||
queue.Setting.FileInput.Path,
|
||||
)
|
||||
|
||||
err = a.convertorService.RunConvert(*queue.Setting, progress)
|
||||
if err != nil {
|
||||
queue.Status = convertor.StatusType(convertor.Error)
|
||||
queue.Error = err
|
||||
a.queueService.EventChangeQueue(queueId, queue)
|
||||
a.progressBarService.ProcessEndedWithError(err.Error())
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
queue.Status = convertor.StatusType(convertor.Completed)
|
||||
a.queueService.EventChangeQueue(queueId, queue)
|
||||
a.progressBarService.ProcessEndedWithSuccess(&queue.Setting.FileOut)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (a *application) AfterClosing() {
|
||||
for _, cmd := range a.convertorService.GetRunningProcesses() {
|
||||
_ = cmd.Process.Kill()
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/convertor/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||
"io"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ConvertorContract interface {
|
||||
RunConvert(setting ffmpeg.ConvertSetting, progress ffmpeg.ProgressContract) error
|
||||
GetSupportFormats() (encoder.ConvertorFormatsContract, error)
|
||||
GetRunningProcesses() map[int]*exec.Cmd
|
||||
}
|
||||
|
||||
type runningProcesses struct {
|
||||
items map[int]*exec.Cmd
|
||||
numberOfStarts int
|
||||
}
|
||||
|
||||
type convertor struct {
|
||||
ffmpegService ffmpeg.UtilitiesContract
|
||||
runningProcesses *runningProcesses
|
||||
}
|
||||
|
||||
func NewConvertor(
|
||||
ffmpegService ffmpeg.UtilitiesContract,
|
||||
) ConvertorContract {
|
||||
return &convertor{
|
||||
ffmpegService: ffmpegService,
|
||||
runningProcesses: &runningProcesses{items: map[int]*exec.Cmd{}, numberOfStarts: 0},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *convertor) RunConvert(setting ffmpeg.ConvertSetting, progress ffmpeg.ProgressContract) error {
|
||||
ffmpegService, err := c.ffmpegService.GetFFmpeg()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
index := c.runningProcesses.numberOfStarts
|
||||
beforeWait := func(cmd *exec.Cmd) {
|
||||
c.runningProcesses.numberOfStarts++
|
||||
c.runningProcesses.items[index] = cmd
|
||||
}
|
||||
|
||||
afterWait := func(cmd *exec.Cmd) {
|
||||
delete(c.runningProcesses.items, index)
|
||||
}
|
||||
|
||||
return ffmpegService.RunConvert(setting, progress, beforeWait, afterWait)
|
||||
}
|
||||
|
||||
func (c *convertor) GetSupportFormats() (encoder.ConvertorFormatsContract, error) {
|
||||
var err error
|
||||
|
||||
formats := encoder.NewConvertorFormats()
|
||||
ffmpeg, err := c.ffmpegService.GetFFmpeg()
|
||||
if err != nil {
|
||||
return formats, err
|
||||
}
|
||||
err = ffmpeg.GetEncoders(func(scanner *bufio.Reader) {
|
||||
for {
|
||||
line, _, err := scanner.ReadLine()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
text := strings.Split(strings.TrimSpace(string(line)), " ")
|
||||
encoderType := string(text[0][0])
|
||||
if len(text) < 2 || (encoderType != "V" && encoderType != "A") {
|
||||
continue
|
||||
}
|
||||
formats.NewEncoder(text[1])
|
||||
}
|
||||
})
|
||||
|
||||
return formats, err
|
||||
}
|
||||
|
||||
func (c *convertor) GetRunningProcesses() map[int]*exec.Cmd {
|
||||
return c.runningProcesses.items
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package encoder
|
||||
|
||||
import (
|
||||
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/apng"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/bmp"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/flv"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/gif"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/h264_nvenc"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libmp3lame"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libshine"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libtwolame"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libvpx"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libvpx_vp9"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libwebp"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libwebp_anim"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libx264"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libx265"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/libxvid"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/mjpeg"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/mp2"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/mp2fixed"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/mpeg1video"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/mpeg2video"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/mpeg4"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/msmpeg4"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/msmpeg4v2"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/msvideo1"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/png"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/qtrle"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/sgi"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/tiff"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/wmav1"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/wmav2"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/wmv1"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/wmv2"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder/xbm"
|
||||
)
|
||||
|
||||
var supportEncoders = map[string]func() encoder2.EncoderDataContract{
|
||||
"libx264": libx264.NewData,
|
||||
"h264_nvenc": h264_nvenc.NewData,
|
||||
"libx265": libx265.NewData,
|
||||
"png": png.NewData,
|
||||
"gif": gif.NewData,
|
||||
"flv": flv.NewData,
|
||||
"apng": apng.NewData,
|
||||
"bmp": bmp.NewData,
|
||||
"mjpeg": mjpeg.NewData,
|
||||
"mpeg1video": mpeg1video.NewData,
|
||||
"mpeg2video": mpeg2video.NewData,
|
||||
"mpeg4": mpeg4.NewData,
|
||||
"libxvid": libxvid.NewData,
|
||||
"msmpeg4v2": msmpeg4v2.NewData,
|
||||
"msmpeg4": msmpeg4.NewData,
|
||||
"msvideo1": msvideo1.NewData,
|
||||
"qtrle": qtrle.NewData,
|
||||
"tiff": tiff.NewData,
|
||||
"sgi": sgi.NewData,
|
||||
"libvpx": libvpx.NewData,
|
||||
"libvpx-vp9": libvpx_vp9.NewData,
|
||||
"libwebp_anim": libwebp_anim.NewData,
|
||||
"libwebp": libwebp.NewData,
|
||||
"wmv1": wmv1.NewData,
|
||||
"wmv2": wmv2.NewData,
|
||||
"xbm": xbm.NewData,
|
||||
"mp2": mp2.NewData,
|
||||
"mp2fixed": mp2fixed.NewData,
|
||||
"libtwolame": libtwolame.NewData,
|
||||
"libmp3lame": libmp3lame.NewData,
|
||||
"libshine": libshine.NewData,
|
||||
"wmav1": wmav1.NewData,
|
||||
"wmav2": wmav2.NewData,
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||
)
|
||||
|
||||
type ItemsToConvertContract interface {
|
||||
Add(file *ffmpeg.File)
|
||||
Clear()
|
||||
GetItems() map[int]ItemToConvertContract
|
||||
GetItemsContainer() *fyne.Container
|
||||
AfterAddingQueue()
|
||||
GetIsAutoRemove() bool
|
||||
SetIsAutoRemove(isAutoRemove bool)
|
||||
}
|
||||
|
||||
type itemsToConvert struct {
|
||||
ffmpeg ffmpeg.UtilitiesContract
|
||||
nextId int
|
||||
items map[int]ItemToConvertContract
|
||||
itemsContainer *fyne.Container
|
||||
isAutoRemove bool
|
||||
}
|
||||
|
||||
func NewItemsToConvert(ffmpeg ffmpeg.UtilitiesContract) ItemsToConvertContract {
|
||||
return &itemsToConvert{
|
||||
ffmpeg: ffmpeg,
|
||||
nextId: 0,
|
||||
items: map[int]ItemToConvertContract{},
|
||||
itemsContainer: container.NewVBox(),
|
||||
isAutoRemove: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (items *itemsToConvert) GetItemsContainer() *fyne.Container {
|
||||
return items.itemsContainer
|
||||
}
|
||||
|
||||
func (items *itemsToConvert) Add(file *ffmpeg.File) {
|
||||
nextId := items.nextId
|
||||
var content *fyne.Container
|
||||
var buttonPlay *widget.Button
|
||||
|
||||
buttonPlay = widget.NewButtonWithIcon("", theme.Icon(theme.IconNameMediaPlay), func() {
|
||||
buttonPlay.Disable()
|
||||
go func() {
|
||||
ffplay, err := items.ffmpeg.GetFFplay()
|
||||
if err != nil {
|
||||
fyne.Do(func() {
|
||||
buttonPlay.Enable()
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
_ = ffplay.Play(file)
|
||||
fyne.Do(func() {
|
||||
buttonPlay.Enable()
|
||||
})
|
||||
}()
|
||||
})
|
||||
|
||||
buttonRemove := widget.NewButtonWithIcon("", theme.Icon(theme.IconNameDelete), func() {
|
||||
items.itemsContainer.Remove(content)
|
||||
items.itemsContainer.Refresh()
|
||||
delete(items.items, nextId)
|
||||
})
|
||||
buttonRemove.Importance = widget.DangerImportance
|
||||
|
||||
content = container.NewVBox(
|
||||
container.NewBorder(
|
||||
nil,
|
||||
nil,
|
||||
buttonPlay,
|
||||
buttonRemove,
|
||||
container.NewHScroll(widget.NewLabel(file.Name)),
|
||||
),
|
||||
container.NewHScroll(widget.NewLabel(file.Path)),
|
||||
container.NewPadded(),
|
||||
canvas.NewLine(theme.Color(theme.ColorNameFocus)),
|
||||
container.NewPadded(),
|
||||
)
|
||||
|
||||
items.itemsContainer.Add(content)
|
||||
items.items[nextId] = newItemToConvert(file, content)
|
||||
items.nextId++
|
||||
}
|
||||
|
||||
func (items *itemsToConvert) GetIsAutoRemove() bool {
|
||||
return items.isAutoRemove
|
||||
}
|
||||
|
||||
func (items *itemsToConvert) SetIsAutoRemove(isAutoRemove bool) {
|
||||
items.isAutoRemove = isAutoRemove
|
||||
}
|
||||
|
||||
func (items *itemsToConvert) GetItems() map[int]ItemToConvertContract {
|
||||
return items.items
|
||||
}
|
||||
|
||||
func (items *itemsToConvert) AfterAddingQueue() {
|
||||
if items.isAutoRemove {
|
||||
items.Clear()
|
||||
}
|
||||
}
|
||||
|
||||
func (items *itemsToConvert) Clear() {
|
||||
items.itemsContainer.RemoveAll()
|
||||
items.items = map[int]ItemToConvertContract{}
|
||||
}
|
||||
|
||||
type ItemToConvertContract interface {
|
||||
GetFile() *ffmpeg.File
|
||||
GetContent() *fyne.Container
|
||||
}
|
||||
|
||||
type itemToConvert struct {
|
||||
file *ffmpeg.File
|
||||
content *fyne.Container
|
||||
}
|
||||
|
||||
func newItemToConvert(file *ffmpeg.File, content *fyne.Container) ItemToConvertContract {
|
||||
return &itemToConvert{
|
||||
file: file,
|
||||
content: content,
|
||||
}
|
||||
}
|
||||
|
||||
func (item *itemToConvert) GetFile() *ffmpeg.File {
|
||||
return item.file
|
||||
}
|
||||
|
||||
func (item *itemToConvert) GetContent() *fyne.Container {
|
||||
return item.content
|
||||
}
|
@ -1,217 +0,0 @@
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||
"image/color"
|
||||
"io"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ProgressBarContract interface {
|
||||
GetContainer() *fyne.Container
|
||||
GetProgressbar(totalDuration float64, filePath string) ffmpeg.ProgressContract
|
||||
ProcessEndedWithError(errorText string)
|
||||
ProcessEndedWithSuccess(file *ffmpeg.File)
|
||||
}
|
||||
|
||||
type progressBar struct {
|
||||
container *fyne.Container
|
||||
label *widget.Label
|
||||
progressbar *widget.ProgressBar
|
||||
errorBlock *container.Scroll
|
||||
messageError *canvas.Text
|
||||
statusMessage *canvas.Text
|
||||
buttonPlay *widget.Button
|
||||
ffmpegService ffmpeg.UtilitiesContract
|
||||
}
|
||||
|
||||
func NewProgressBar(ffmpegService ffmpeg.UtilitiesContract) ProgressBarContract {
|
||||
label := widget.NewLabel("")
|
||||
progressbar := widget.NewProgressBar()
|
||||
|
||||
statusMessage := canvas.NewText("", theme.Color(theme.ColorNamePrimary))
|
||||
messageError := canvas.NewText("", theme.Color(theme.ColorNameError))
|
||||
buttonPlay := widget.NewButtonWithIcon("", theme.Icon(theme.IconNameMediaPlay), func() {
|
||||
|
||||
})
|
||||
buttonPlay.Hide()
|
||||
|
||||
errorBlock := container.NewHScroll(messageError)
|
||||
errorBlock.Hide()
|
||||
|
||||
content := container.NewVBox(
|
||||
container.NewHScroll(label),
|
||||
progressbar,
|
||||
container.NewHScroll(container.NewHBox(
|
||||
buttonPlay,
|
||||
statusMessage,
|
||||
)),
|
||||
errorBlock,
|
||||
)
|
||||
content.Hide()
|
||||
|
||||
return &progressBar{
|
||||
container: content,
|
||||
label: label,
|
||||
progressbar: progressbar,
|
||||
errorBlock: errorBlock,
|
||||
messageError: messageError,
|
||||
statusMessage: statusMessage,
|
||||
buttonPlay: buttonPlay,
|
||||
ffmpegService: ffmpegService,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *progressBar) GetContainer() *fyne.Container {
|
||||
return p.container
|
||||
}
|
||||
|
||||
func (p *progressBar) GetProgressbar(totalDuration float64, filePath string) ffmpeg.ProgressContract {
|
||||
p.label.Text = filePath
|
||||
p.statusMessage.Color = theme.Color(theme.ColorNamePrimary)
|
||||
p.statusMessage.Text = lang.L("inProgressQueue")
|
||||
p.messageError.Text = ""
|
||||
fyne.Do(func() {
|
||||
p.buttonPlay.Hide()
|
||||
if p.errorBlock.Visible() {
|
||||
p.errorBlock.Hide()
|
||||
}
|
||||
p.statusMessage.Refresh()
|
||||
p.container.Refresh()
|
||||
p.errorBlock.Refresh()
|
||||
})
|
||||
|
||||
p.progressbar.Value = 0
|
||||
return NewProgress(totalDuration, p.progressbar)
|
||||
}
|
||||
|
||||
func (p *progressBar) ProcessEndedWithError(errorText string) {
|
||||
fyne.Do(func() {
|
||||
p.statusMessage.Color = theme.Color(theme.ColorNameError)
|
||||
p.statusMessage.Text = lang.L("errorQueue")
|
||||
p.messageError.Text = errorText
|
||||
p.errorBlock.Show()
|
||||
})
|
||||
}
|
||||
|
||||
func (p *progressBar) ProcessEndedWithSuccess(file *ffmpeg.File) {
|
||||
fyne.Do(func() {
|
||||
p.statusMessage.Color = color.RGBA{R: 49, G: 127, B: 114, A: 255}
|
||||
p.statusMessage.Text = lang.L("completedQueue")
|
||||
p.buttonPlay.Show()
|
||||
p.buttonPlay.OnTapped = func() {
|
||||
p.buttonPlay.Disable()
|
||||
go func() {
|
||||
ffplay, err := p.ffmpegService.GetFFplay()
|
||||
if err == nil {
|
||||
_ = ffplay.Play(file)
|
||||
}
|
||||
|
||||
fyne.Do(func() {
|
||||
p.buttonPlay.Enable()
|
||||
})
|
||||
}()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type Progress struct {
|
||||
totalDuration float64
|
||||
progressbar *widget.ProgressBar
|
||||
protocol string
|
||||
}
|
||||
|
||||
func NewProgress(totalDuration float64, progressbar *widget.ProgressBar) ffmpeg.ProgressContract {
|
||||
return &Progress{
|
||||
totalDuration: totalDuration,
|
||||
progressbar: progressbar,
|
||||
protocol: "pipe:",
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Progress) GetProtocole() string {
|
||||
return p.protocol
|
||||
}
|
||||
|
||||
func (p *Progress) Run(stdOut io.ReadCloser, stdErr io.ReadCloser) error {
|
||||
isProcessCompleted := false
|
||||
var errorText string
|
||||
|
||||
p.progressbar.Value = 0
|
||||
p.progressbar.Max = p.totalDuration
|
||||
fyne.Do(func() {
|
||||
p.progressbar.Refresh()
|
||||
})
|
||||
progress := 0.0
|
||||
|
||||
go func() {
|
||||
scannerErr := bufio.NewReader(stdErr)
|
||||
for {
|
||||
line, _, err := scannerErr.ReadLine()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
data := strings.TrimSpace(string(line))
|
||||
errorText = data
|
||||
}
|
||||
}()
|
||||
|
||||
scannerOut := bufio.NewReader(stdOut)
|
||||
for {
|
||||
line, _, err := scannerOut.ReadLine()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
data := strings.TrimSpace(string(line))
|
||||
if strings.Contains(data, "progress=end") {
|
||||
p.progressbar.Value = p.totalDuration
|
||||
fyne.Do(func() {
|
||||
p.progressbar.Refresh()
|
||||
})
|
||||
isProcessCompleted = true
|
||||
break
|
||||
}
|
||||
|
||||
re := regexp.MustCompile(`frame=(\d+)`)
|
||||
a := re.FindAllStringSubmatch(data, -1)
|
||||
|
||||
if len(a) > 0 && len(a[len(a)-1]) > 0 {
|
||||
c, err := strconv.Atoi(a[len(a)-1][len(a[len(a)-1])-1])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
progress = float64(c)
|
||||
}
|
||||
if p.progressbar.Value != progress {
|
||||
p.progressbar.Value = progress
|
||||
fyne.Do(func() {
|
||||
p.progressbar.Refresh()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if isProcessCompleted == false {
|
||||
if len(errorText) == 0 {
|
||||
errorText = lang.L("errorConverter")
|
||||
}
|
||||
return errors.New(errorText)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||
)
|
||||
|
||||
type Queue struct {
|
||||
Setting *ffmpeg.ConvertSetting
|
||||
Status StatusContract
|
||||
Error error
|
||||
}
|
||||
|
||||
type StatusContract interface {
|
||||
Name() string
|
||||
Ordinal() int
|
||||
}
|
||||
|
||||
const (
|
||||
Waiting = iota
|
||||
InProgress
|
||||
Completed
|
||||
Error
|
||||
)
|
||||
|
||||
type StatusType uint
|
||||
|
||||
var statusTypeStrings = []string{
|
||||
"waiting",
|
||||
"inProgress",
|
||||
"completed",
|
||||
"error",
|
||||
}
|
||||
|
||||
func (status StatusType) Name() string {
|
||||
return statusTypeStrings[status]
|
||||
}
|
||||
|
||||
func (status StatusType) Ordinal() int {
|
||||
return int(status)
|
||||
}
|
||||
|
||||
type QueueListenerContract interface {
|
||||
AddQueue(key int, queue *Queue)
|
||||
ChangeQueue(key int, queue *Queue)
|
||||
RemoveQueue(key int, status StatusContract)
|
||||
}
|
||||
|
||||
type QueueListContract interface {
|
||||
AddListener(queueListener QueueListenerContract)
|
||||
GetItems() map[int]*Queue
|
||||
Add(setting *ffmpeg.ConvertSetting)
|
||||
EventChangeQueue(key int, queue *Queue)
|
||||
Remove(key int)
|
||||
GetItem(key int) (*Queue, error)
|
||||
Next() (key int, queue *Queue)
|
||||
}
|
||||
|
||||
type queueList struct {
|
||||
currentKey int
|
||||
items map[int]*Queue
|
||||
queue map[int]int
|
||||
queueListener map[int]QueueListenerContract
|
||||
}
|
||||
|
||||
func NewQueueList() QueueListContract {
|
||||
return &queueList{
|
||||
currentKey: 0,
|
||||
items: map[int]*Queue{},
|
||||
queue: map[int]int{},
|
||||
queueListener: map[int]QueueListenerContract{},
|
||||
}
|
||||
}
|
||||
|
||||
func (l *queueList) GetItems() map[int]*Queue {
|
||||
return l.items
|
||||
}
|
||||
|
||||
func (l *queueList) Add(setting *ffmpeg.ConvertSetting) {
|
||||
queue := Queue{
|
||||
Setting: setting,
|
||||
Status: StatusType(Waiting),
|
||||
}
|
||||
|
||||
l.currentKey += 1
|
||||
l.items[l.currentKey] = &queue
|
||||
l.queue[l.currentKey] = l.currentKey
|
||||
|
||||
l.eventAdd(l.currentKey, &queue)
|
||||
}
|
||||
|
||||
func (l *queueList) EventChangeQueue(key int, queue *Queue) {
|
||||
l.eventChange(key, queue)
|
||||
}
|
||||
|
||||
func (l *queueList) Remove(key int) {
|
||||
if _, ok := l.queue[key]; ok {
|
||||
delete(l.queue, key)
|
||||
}
|
||||
|
||||
if _, ok := l.items[key]; ok {
|
||||
status := l.items[key].Status
|
||||
l.eventRemove(key, status)
|
||||
delete(l.items, key)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *queueList) GetItem(key int) (*Queue, error) {
|
||||
if item, ok := l.items[key]; ok {
|
||||
return item, nil
|
||||
}
|
||||
|
||||
return nil, errors.New("key not found")
|
||||
}
|
||||
|
||||
func (l *queueList) AddListener(queueListener QueueListenerContract) {
|
||||
l.queueListener[len(l.queueListener)] = queueListener
|
||||
}
|
||||
|
||||
func (l *queueList) Next() (key int, queue *Queue) {
|
||||
statusWaiting := StatusType(Waiting)
|
||||
for key, queueId := range l.queue {
|
||||
if queue, ok := l.items[queueId]; ok {
|
||||
if queue.Status == statusWaiting {
|
||||
return queueId, queue
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := l.queue[key]; ok {
|
||||
delete(l.queue, key)
|
||||
}
|
||||
}
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
func (l *queueList) eventAdd(key int, queue *Queue) {
|
||||
for _, listener := range l.queueListener {
|
||||
listener.AddQueue(key, queue)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *queueList) eventChange(key int, queue *Queue) {
|
||||
for _, listener := range l.queueListener {
|
||||
listener.ChangeQueue(key, queue)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *queueList) eventRemove(key int, status StatusContract) {
|
||||
for _, listener := range l.queueListener {
|
||||
listener.RemoveQueue(key, status)
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package setting
|
||||
|
||||
func (s *setting) GetFFmpegPath() string {
|
||||
path := s.fyneApp.Preferences().String("ffmpegPath")
|
||||
if path == "" {
|
||||
return "ffmpeg"
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
func (s *setting) SetFFmpegPath(path string) {
|
||||
s.fyneApp.Preferences().SetString("ffmpegPath", path)
|
||||
}
|
||||
|
||||
func (s *setting) GetFFprobePath() string {
|
||||
path := s.fyneApp.Preferences().String("ffprobePath")
|
||||
if path == "" {
|
||||
return "ffprobe"
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
func (s *setting) SetFFprobePath(path string) {
|
||||
s.fyneApp.Preferences().SetString("ffprobePath", path)
|
||||
}
|
||||
|
||||
func (s *setting) GetFFplayPath() string {
|
||||
path := s.fyneApp.Preferences().String("ffplayPath")
|
||||
if path == "" {
|
||||
return "ffplay"
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
func (s *setting) SetFFplayPath(path string) {
|
||||
s.fyneApp.Preferences().SetString("ffplayPath", path)
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fyne.io/fyne/v2"
|
||||
fyneLang "fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/resources"
|
||||
)
|
||||
|
||||
var supportedLanguages = map[string]Lang{
|
||||
"ru": {Code: "ru", Title: "Русский"},
|
||||
"kk": {Code: "kk", Title: "Қазақ Тілі"},
|
||||
"en": {Code: "en", Title: "English"},
|
||||
}
|
||||
|
||||
type Lang struct {
|
||||
Code string
|
||||
Title string
|
||||
}
|
||||
|
||||
func ChangeLang(lang Lang) error {
|
||||
translationsData, err := getTranslations(lang)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name := fyneLang.SystemLocale().LanguageString()
|
||||
return fyneLang.AddTranslations(fyne.NewStaticResource(name+".json", translationsData))
|
||||
}
|
||||
|
||||
func defaultLang() Lang {
|
||||
return supportedLanguages["ru"]
|
||||
}
|
||||
|
||||
func getTranslations(language Lang) ([]byte, error) {
|
||||
translations := resources.GetTranslations()
|
||||
|
||||
baseJson, err := translations.ReadFile("translations/base." + language.Code + ".json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
appJson, err := translations.ReadFile("translations/app." + language.Code + ".json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mergeTranslations(baseJson, appJson)
|
||||
}
|
||||
|
||||
func mergeTranslations(baseJson []byte, appJson []byte) ([]byte, error) {
|
||||
base := map[string]interface{}{}
|
||||
custom := map[string]interface{}{}
|
||||
err := json.Unmarshal(baseJson, &base)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal(appJson, &custom)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for k, v := range custom {
|
||||
base[k] = v
|
||||
}
|
||||
return json.Marshal(base)
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
type SettingContract interface {
|
||||
GetLanguages() []Lang
|
||||
GetCurrentLangOrDefaultLang() (currentLang Lang, isDefault bool)
|
||||
SetLang(language Lang) error
|
||||
|
||||
GetDirectoryForSaving() string
|
||||
SetDirectoryForSaving(path string)
|
||||
|
||||
GetFFmpegPath() string
|
||||
SetFFmpegPath(path string)
|
||||
|
||||
GetFFprobePath() string
|
||||
SetFFprobePath(path string)
|
||||
|
||||
GetFFplayPath() string
|
||||
SetFFplayPath(path string)
|
||||
|
||||
ThemeInit()
|
||||
GetThemes() map[string]ThemeInfoContract
|
||||
GetTheme() ThemeInfoContract
|
||||
SetTheme(themeInfo ThemeInfoContract)
|
||||
}
|
||||
|
||||
type setting struct {
|
||||
fyneApp fyne.App
|
||||
}
|
||||
|
||||
func NewSetting(fyneApp fyne.App) SettingContract {
|
||||
return &setting{
|
||||
fyneApp: fyneApp,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *setting) GetLanguages() []Lang {
|
||||
items := []Lang{}
|
||||
for _, item := range supportedLanguages {
|
||||
items = append(items, item)
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func (s *setting) GetCurrentLangOrDefaultLang() (currentLang Lang, isDefault bool) {
|
||||
languageCode := s.fyneApp.Preferences().String("language")
|
||||
|
||||
if languageCode == "" {
|
||||
languageTag, err := language.Parse(lang.SystemLocale().LanguageString())
|
||||
if err != nil {
|
||||
return currentLang, true
|
||||
}
|
||||
base, _ := languageTag.Base()
|
||||
languageCode = base.String()
|
||||
}
|
||||
|
||||
if currentLang, ok := supportedLanguages[languageCode]; ok {
|
||||
return currentLang, false
|
||||
}
|
||||
|
||||
return defaultLang(), true
|
||||
}
|
||||
|
||||
func (s *setting) SetLang(language Lang) error {
|
||||
err := ChangeLang(language)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.fyneApp.Preferences().SetString("language", language.Code)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *setting) GetDirectoryForSaving() string {
|
||||
return s.fyneApp.Preferences().String("directoryForSaving")
|
||||
}
|
||||
|
||||
func (s *setting) SetDirectoryForSaving(path string) {
|
||||
s.fyneApp.Preferences().SetString("directoryForSaving", path)
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
func (s *setting) GetTheme() ThemeInfoContract {
|
||||
name := s.fyneApp.Preferences().String("theme")
|
||||
if name != "" {
|
||||
if _, ok := s.GetThemes()[name]; ok {
|
||||
return s.GetThemes()[name]
|
||||
}
|
||||
}
|
||||
|
||||
return s.GetThemes()["default"]
|
||||
}
|
||||
|
||||
func (s *setting) SetTheme(themeInfo ThemeInfoContract) {
|
||||
s.fyneApp.Preferences().SetString("theme", themeInfo.GetName())
|
||||
|
||||
if themeInfo.GetName() == "default" {
|
||||
s.fyneApp.Settings().SetTheme(theme.DefaultTheme())
|
||||
return
|
||||
}
|
||||
s.fyneApp.Settings().SetTheme(&forcedVariant{theme: theme.DefaultTheme(), variant: themeInfo.GetVariant()})
|
||||
}
|
||||
|
||||
func (s *setting) ThemeInit() {
|
||||
themeInfo := s.GetTheme()
|
||||
if themeInfo.GetName() == "default" {
|
||||
s.fyneApp.Settings().SetTheme(theme.DefaultTheme())
|
||||
return
|
||||
}
|
||||
s.fyneApp.Settings().SetTheme(&forcedVariant{theme: theme.DefaultTheme(), variant: themeInfo.GetVariant()})
|
||||
}
|
||||
|
||||
func (s *setting) GetThemes() map[string]ThemeInfoContract {
|
||||
themesNameDefault := &themeInfo{
|
||||
name: "default",
|
||||
title: lang.L("themesNameDefault"),
|
||||
}
|
||||
|
||||
themesNameLight := &themeInfo{
|
||||
name: "light",
|
||||
title: lang.L("themesNameLight"),
|
||||
variant: theme.VariantLight,
|
||||
}
|
||||
|
||||
themesNameDark := &themeInfo{
|
||||
name: "dark",
|
||||
title: lang.L("themesNameDark"),
|
||||
variant: theme.VariantDark,
|
||||
}
|
||||
|
||||
list := map[string]ThemeInfoContract{
|
||||
"default": themesNameDefault,
|
||||
"light": themesNameLight,
|
||||
"dark": themesNameDark,
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
type ThemeInfoContract interface {
|
||||
GetName() string
|
||||
GetTitle() string
|
||||
GetVariant() fyne.ThemeVariant
|
||||
}
|
||||
|
||||
type themeInfo struct {
|
||||
name string
|
||||
title string
|
||||
variant fyne.ThemeVariant
|
||||
}
|
||||
|
||||
func (inf *themeInfo) GetName() string {
|
||||
return inf.name
|
||||
}
|
||||
|
||||
func (inf *themeInfo) GetTitle() string {
|
||||
return inf.title
|
||||
}
|
||||
|
||||
func (inf *themeInfo) GetVariant() fyne.ThemeVariant {
|
||||
return inf.variant
|
||||
}
|
||||
|
||||
type forcedVariant struct {
|
||||
theme fyne.Theme
|
||||
variant fyne.ThemeVariant
|
||||
}
|
||||
|
||||
func (f *forcedVariant) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color {
|
||||
return f.theme.Color(name, f.variant)
|
||||
}
|
||||
|
||||
func (f *forcedVariant) Font(style fyne.TextStyle) fyne.Resource {
|
||||
return theme.DefaultTheme().Font(style)
|
||||
}
|
||||
|
||||
func (f *forcedVariant) Icon(name fyne.ThemeIconName) fyne.Resource {
|
||||
return theme.DefaultTheme().Icon(name)
|
||||
}
|
||||
|
||||
func (f *forcedVariant) Size(name fyne.ThemeSizeName) float32 {
|
||||
return theme.DefaultTheme().Size(name)
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/download/service"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
)
|
||||
|
||||
func (c *controller) convertor() {
|
||||
formats, err := c.app.GetConvertorService().GetSupportFormats()
|
||||
if err != nil {
|
||||
c.startWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
content := view.Convertor(
|
||||
c.window,
|
||||
c.addFileForConversion,
|
||||
c.app.GetSetting().GetDirectoryForSaving(),
|
||||
c.setDirectoryForSaving,
|
||||
formats,
|
||||
c.addToConversion,
|
||||
)
|
||||
c.window.SetContent(content)
|
||||
}
|
||||
|
||||
func (c *controller) addFileForConversion(file ffmpeg.File) {
|
||||
c.app.GetItemsToConvert().Add(&file)
|
||||
c.window.GetLayout().GetRContainer().SelectAddedFilesTab()
|
||||
}
|
||||
|
||||
func (c *controller) setDirectoryForSaving(path string) {
|
||||
c.app.GetSetting().SetDirectoryForSaving(path)
|
||||
}
|
||||
|
||||
func (c *controller) addToConversion(convertSetting view.ConvertSetting) error {
|
||||
if len(c.app.GetItemsToConvert().GetItems()) == 0 {
|
||||
return errors.New(lang.L("errorNoFilesAddedForConversion"))
|
||||
}
|
||||
c.window.GetLayout().GetRContainer().SelectFileQueueTab()
|
||||
for _, item := range c.app.GetItemsToConvert().GetItems() {
|
||||
file := item.GetFile()
|
||||
if file == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
c.app.GetQueueService().Add(&ffmpeg.ConvertSetting{
|
||||
FileInput: *file,
|
||||
FileOut: ffmpeg.File{
|
||||
Path: convertSetting.DirectoryForSave + utils.PathSeparator() + file.Name + "." + convertSetting.Format,
|
||||
Name: file.Name,
|
||||
Ext: "." + convertSetting.Format,
|
||||
},
|
||||
OverwriteOutputFiles: convertSetting.OverwriteOutputFiles,
|
||||
Encoder: convertSetting.Encoder,
|
||||
})
|
||||
}
|
||||
c.app.GetItemsToConvert().AfterAddingQueue()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *controller) settingConvertor(isAllowCancellation bool) {
|
||||
ffmpegPath := c.app.GetFFmpegService().GetFFmpegPath()
|
||||
ffprobePath := c.app.GetFFmpegService().GetFFprobePath()
|
||||
ffplayPath := c.app.GetFFmpegService().GetFFplayPath()
|
||||
|
||||
var cancel func()
|
||||
cancel = nil
|
||||
if isAllowCancellation {
|
||||
cancel = func() {
|
||||
c.convertor()
|
||||
}
|
||||
}
|
||||
|
||||
content := view.ConfiguringFFmpegUtilities(
|
||||
c.window,
|
||||
ffmpegPath,
|
||||
ffprobePath,
|
||||
ffplayPath,
|
||||
c.saveSettingConvertor,
|
||||
cancel,
|
||||
service.DownloadFFmpeg(c.app, c.saveSettingConvertor),
|
||||
)
|
||||
c.window.SetContent(content)
|
||||
}
|
||||
|
||||
func (c *controller) saveSettingConvertor(ffmpegPath string, ffprobePath string, ffplayPath string) error {
|
||||
var err error
|
||||
|
||||
err = c.app.GetFFmpegService().ChangeFFmpeg(ffmpegPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.app.GetFFmpegService().ChangeFFprobe(ffprobePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.app.GetFFmpegService().ChangeFFplay(ffplayPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.convertor()
|
||||
return nil
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/setting"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view"
|
||||
)
|
||||
|
||||
func (c *controller) startWithError(err error) {
|
||||
languages := c.app.GetSetting().GetLanguages()
|
||||
|
||||
content := view.StartWithError(err, languages, func(lang setting.Lang) {
|
||||
_ = setting.ChangeLang(lang)
|
||||
c.startWithError(err)
|
||||
})
|
||||
c.window.SetContent(content)
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/setting"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/menu"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/window"
|
||||
)
|
||||
|
||||
type ControllerContract interface {
|
||||
Start()
|
||||
}
|
||||
|
||||
type controller struct {
|
||||
app application.AppContract
|
||||
window window.WindowContract
|
||||
}
|
||||
|
||||
func NewController(app application.AppContract) ControllerContract {
|
||||
fyneWindow := app.FyneApp().NewWindow(app.FyneApp().Metadata().Name)
|
||||
fyneWindow.SetMaster()
|
||||
queueLayout := window.NewQueueLayout(app.GetFFmpegService())
|
||||
app.GetQueueService().AddListener(queueLayout)
|
||||
|
||||
return &controller{
|
||||
app: app,
|
||||
window: window.NewMainWindow(
|
||||
fyneWindow,
|
||||
app.GetProgressBarService(),
|
||||
app.GetItemsToConvert(),
|
||||
queueLayout,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *controller) Start() {
|
||||
isDefault, err := c.initLanguage()
|
||||
if err != nil {
|
||||
c.startWithError(err)
|
||||
c.window.Show()
|
||||
return
|
||||
}
|
||||
|
||||
c.app.GetSetting().ThemeInit()
|
||||
|
||||
if isDefault {
|
||||
languages := c.app.GetSetting().GetLanguages()
|
||||
content := view.StartWithoutSupportLang(languages, func(lang setting.Lang) {
|
||||
err = c.app.GetSetting().SetLang(lang)
|
||||
if err != nil {
|
||||
c.startWithError(err)
|
||||
return
|
||||
}
|
||||
c.initLayout()
|
||||
c.verificareaFFmpeg()
|
||||
})
|
||||
c.window.SetContent(content)
|
||||
c.window.Show()
|
||||
return
|
||||
}
|
||||
|
||||
c.initLayout()
|
||||
c.verificareaFFmpeg()
|
||||
c.window.Show()
|
||||
}
|
||||
|
||||
func (c *controller) verificareaFFmpeg() {
|
||||
if !c.app.GetFFmpegService().UtilityCheck() {
|
||||
c.settingConvertor(false)
|
||||
return
|
||||
}
|
||||
|
||||
c.convertor()
|
||||
}
|
||||
|
||||
func (c *controller) initLanguage() (isDefault bool, err error) {
|
||||
lang, isDefault := c.app.GetSetting().GetCurrentLangOrDefaultLang()
|
||||
err = setting.ChangeLang(lang)
|
||||
return isDefault, err
|
||||
}
|
||||
|
||||
func (c *controller) initLayout() {
|
||||
c.window.SetMainMenu(fyne.NewMainMenu(
|
||||
menu.MainMenuSettings(
|
||||
c.actionMainSettings,
|
||||
c.actionSettingConvertor,
|
||||
),
|
||||
menu.MainMenuHelp(
|
||||
c.actionAbout,
|
||||
c.actionHelpFFplay,
|
||||
),
|
||||
))
|
||||
c.window.InitLayout()
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view"
|
||||
)
|
||||
|
||||
func (c *controller) actionSettingConvertor() {
|
||||
c.settingConvertor(true)
|
||||
}
|
||||
|
||||
func (c *controller) actionMainSettings() {
|
||||
currentLang, _ := c.app.GetSetting().GetCurrentLangOrDefaultLang()
|
||||
content := view.MainSettings(
|
||||
currentLang,
|
||||
c.app.GetSetting().GetLanguages(),
|
||||
|
||||
c.app.GetSetting().GetTheme(),
|
||||
c.app.GetSetting().GetThemes(),
|
||||
|
||||
c.actionMainSettingsSave,
|
||||
c.convertor,
|
||||
)
|
||||
c.window.SetContent(content)
|
||||
}
|
||||
|
||||
func (c *controller) actionMainSettingsSave(setting *view.MainSettingForm) error {
|
||||
err := c.app.GetSetting().SetLang(setting.Language)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.app.GetSetting().SetTheme(setting.ThemeInfo)
|
||||
c.initLayout()
|
||||
|
||||
c.convertor()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *controller) actionAbout() {
|
||||
ffmpegVersion := c.app.GetFFmpegService().GetFFmpegVersion()
|
||||
ffprobeVersion := c.app.GetFFmpegService().GetFFprobeVersion()
|
||||
ffplayVersion := c.app.GetFFmpegService().GetFFplayVersion()
|
||||
appVersion := c.app.FyneApp().Metadata().Version
|
||||
|
||||
window := c.app.FyneApp().NewWindow(lang.L("about"))
|
||||
window.Resize(fyne.Size{Width: 793, Height: 550})
|
||||
window.SetFixedSize(true)
|
||||
|
||||
content := view.About(appVersion, ffmpegVersion, ffprobeVersion, ffplayVersion)
|
||||
|
||||
window.SetContent(content)
|
||||
window.CenterOnScreen()
|
||||
window.Show()
|
||||
}
|
||||
|
||||
func (c *controller) actionHelpFFplay() {
|
||||
window := c.app.FyneApp().NewWindow(lang.L("helpFFplay"))
|
||||
window.Resize(fyne.Size{Width: 800, Height: 550})
|
||||
window.SetFixedSize(true)
|
||||
|
||||
content := view.HelpFFplay()
|
||||
|
||||
window.SetContent(content)
|
||||
window.CenterOnScreen()
|
||||
window.Show()
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
//go:build !windows && !linux
|
||||
// +build !windows,!linux
|
||||
|
||||
package gui
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error) fyne.CanvasObject {
|
||||
return container.NewVBox()
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/download/gui"
|
||||
)
|
||||
|
||||
func DownloadFFmpeg(app application.AppContract, save func(ffmpegPath string, ffprobePath string, ffplayPath string) error) fyne.CanvasObject {
|
||||
return gui.DownloadFFmpeg(func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error {
|
||||
var err error
|
||||
err = startDownload(app, progressBar, progressMessage, save)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
//go:build !windows && !linux
|
||||
// +build !windows,!linux
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||
)
|
||||
|
||||
func startDownload(app application.AppContract, progressBar *widget.ProgressBar, progressMessage *canvas.Text, save func(ffmpegPath string, ffprobePath string, ffplayPath string) error) error {
|
||||
return nil
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package apng
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "apng"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("apng", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "apng"
|
||||
formats := []string{"apng"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package bmp
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "bmp"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("bmp", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "bmp"
|
||||
formats := []string{"bmp"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package flv
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "flv"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("flv", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "flv"
|
||||
formats := []string{"flv"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package gif
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "gif"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("gif", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "gif"
|
||||
formats := []string{"gif"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package libmp3lame
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:a", "libmp3lame"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libmp3lame", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libmp3lame"
|
||||
formats := []string{"mp3"}
|
||||
fileType := encoder.FileType(encoder.Audio)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package libshine
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:a", "libshine"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libshine", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libshine"
|
||||
formats := []string{"mp3"}
|
||||
fileType := encoder.FileType(encoder.Audio)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package libtwolame
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:a", "libtwolame"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libtwolame", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libtwolame"
|
||||
formats := []string{"mp2"}
|
||||
fileType := encoder.FileType(encoder.Audio)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package libvpx
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "libvpx"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libvpx", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libvpx"
|
||||
formats := []string{"webm", "mkv"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package libvpx_vp9
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "libvpx-vp9"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libvpx_vp9", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libvpx-vp9"
|
||||
formats := []string{"webm", "mkv"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package libwebp
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "libwebp"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libwebp", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libwebp"
|
||||
formats := []string{"webp"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package libwebp_anim
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "libwebp_anim"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libwebp_anim", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libwebp_anim"
|
||||
formats := []string{"webp"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package libxvid
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "libxvid"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libxvid", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libxvid"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package mjpeg
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "mjpeg"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("mjpeg", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "mjpeg"
|
||||
formats := []string{"jpg"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package mp2
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:a", "mp2"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("mp2", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "mp2"
|
||||
formats := []string{"mp2"}
|
||||
fileType := encoder.FileType(encoder.Audio)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package mp2fixed
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:a", "mp2fixed"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("mp2fixed", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "mp2fixed"
|
||||
formats := []string{"mp2"}
|
||||
fileType := encoder.FileType(encoder.Audio)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package mpeg1video
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "mpeg1video"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("mpeg1video", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "mpeg1video"
|
||||
formats := []string{"mpg", "mpeg"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package mpeg2video
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "mpeg2video"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("mpeg2video", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "mpeg2video"
|
||||
formats := []string{"mpg", "mpeg"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package mpeg4
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "mpeg4"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("mpeg4", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "mpeg4"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package msmpeg4
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "msmpeg4"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("msmpeg4", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "msmpeg4"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package msmpeg4v2
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "msmpeg4v2"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("msmpeg4v2", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "msmpeg4v2"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package msvideo1
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "msvideo1"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("msvideo1", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "msvideo1"
|
||||
formats := []string{"avi"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package png
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "png"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("png", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "png"
|
||||
formats := []string{"png"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package qtrle
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "qtrle"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("qtrle", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "qtrle"
|
||||
formats := []string{"mov"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package sgi
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "sgi"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("sgi", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "sgi"
|
||||
formats := []string{"sgi"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package tiff
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:v", "tiff"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("tiff", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "tiff"
|
||||
formats := []string{"tiff"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package wmav1
|
||||
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
return []string{"-c:a", "wmav1"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("wmav1", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "wmav1"
|
||||
formats := []string{"wma"}
|
||||
fileType := encoder.FileType(encoder.Audio)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user