Compare commits
27 Commits
43d794373a
...
850cbbaf70
Author | SHA1 | Date | |
---|---|---|---|
850cbbaf70 | |||
f4604f94c6 | |||
077d7a82a9 | |||
e6db590937 | |||
d7428683e4 | |||
a9c59137af | |||
c8619cdc7f | |||
c49957e583 | |||
39080cac14 | |||
cae996a141 | |||
fc4e585620 | |||
690f84e2c8 | |||
568d8f0897 | |||
2909ef7cea | |||
1b1cdd5c22 | |||
eb43669ae7 | |||
29ca392880 | |||
df8095fb16 | |||
e48f363de0 | |||
9bb835beaf | |||
9cdfa18fc8 | |||
6c0abac1c5 | |||
394824ce88 | |||
6e8b148c81 | |||
57637606c0 | |||
c60b9f7b0c | |||
b24155caf6 |
@ -1,46 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
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()
|
||||
}
|
@ -1,515 +0,0 @@
|
||||
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()
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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,
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
//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 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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)
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
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)
|
||||
}),
|
||||
))
|
||||
}
|
@ -1,178 +0,0 @@
|
||||
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
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
//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,32 +0,0 @@
|
||||
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
143
handler/menu.go
@ -1,143 +0,0 @@
|
||||
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)
|
||||
}
|
137
internal/application/app.go
Normal file
137
internal/application/app.go
Normal file
@ -0,0 +1,137 @@
|
||||
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()
|
||||
}
|
||||
}
|
87
internal/application/convertor/convertor.go
Normal file
87
internal/application/convertor/convertor.go
Normal file
@ -0,0 +1,87 @@
|
||||
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
|
||||
}
|
@ -2,7 +2,7 @@ package encoder
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
type ConvertorFormatContract interface {
|
||||
@ -18,7 +18,7 @@ type ConvertorFormat struct {
|
||||
encoders map[int]encoder.EncoderDataContract
|
||||
}
|
||||
|
||||
func NewConvertorFormat(title string, fileType encoder.FileTypeContract) *ConvertorFormat {
|
||||
func NewConvertorFormat(title string, fileType encoder.FileTypeContract) ConvertorFormatContract {
|
||||
return &ConvertorFormat{
|
||||
title: title,
|
||||
fileType: fileType,
|
||||
@ -26,19 +26,19 @@ func NewConvertorFormat(title string, fileType encoder.FileTypeContract) *Conver
|
||||
}
|
||||
}
|
||||
|
||||
func (f ConvertorFormat) GetTitle() string {
|
||||
func (f *ConvertorFormat) GetTitle() string {
|
||||
return f.title
|
||||
}
|
||||
|
||||
func (f ConvertorFormat) AddEncoder(encoder encoder.EncoderDataContract) {
|
||||
func (f *ConvertorFormat) AddEncoder(encoder encoder.EncoderDataContract) {
|
||||
f.encoders[len(f.encoders)] = encoder
|
||||
}
|
||||
|
||||
func (f ConvertorFormat) GetEncoders() map[int]encoder.EncoderDataContract {
|
||||
func (f *ConvertorFormat) GetEncoders() map[int]encoder.EncoderDataContract {
|
||||
return f.encoders
|
||||
}
|
||||
|
||||
func (f ConvertorFormat) GetFileType() encoder.FileTypeContract {
|
||||
func (f *ConvertorFormat) GetFileType() encoder.FileTypeContract {
|
||||
return f.fileType
|
||||
}
|
||||
|
||||
@ -52,13 +52,13 @@ type ConvertorFormats struct {
|
||||
formats map[string]ConvertorFormatContract
|
||||
}
|
||||
|
||||
func NewConvertorFormats() *ConvertorFormats {
|
||||
func NewConvertorFormats() ConvertorFormatsContract {
|
||||
return &ConvertorFormats{
|
||||
formats: map[string]ConvertorFormatContract{},
|
||||
}
|
||||
}
|
||||
|
||||
func (f ConvertorFormats) NewEncoder(encoderName string) bool {
|
||||
func (f *ConvertorFormats) NewEncoder(encoderName string) bool {
|
||||
if supportEncoders[encoderName] == nil {
|
||||
return false
|
||||
}
|
||||
@ -72,13 +72,13 @@ func (f ConvertorFormats) NewEncoder(encoderName string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (f ConvertorFormats) GetFormats() map[string]ConvertorFormatContract {
|
||||
func (f *ConvertorFormats) GetFormats() map[string]ConvertorFormatContract {
|
||||
return f.formats
|
||||
}
|
||||
|
||||
func (f ConvertorFormats) GetFormat(format string) (ConvertorFormatContract, error) {
|
||||
func (f *ConvertorFormats) GetFormat(format string) (ConvertorFormatContract, error) {
|
||||
if f.formats[format] == nil {
|
||||
return ConvertorFormat{}, errors.New("not found ConvertorFormat")
|
||||
return &ConvertorFormat{}, errors.New("not found ConvertorFormat")
|
||||
}
|
||||
return f.formats[format], nil
|
||||
}
|
74
internal/application/convertor/encoder/encoders.go
Normal file
74
internal/application/convertor/encoder/encoders.go
Normal file
@ -0,0 +1,74 @@
|
||||
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,
|
||||
}
|
139
internal/application/convertor/items_to_convert.go
Normal file
139
internal/application/convertor/items_to_convert.go
Normal file
@ -0,0 +1,139 @@
|
||||
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
|
||||
}
|
217
internal/application/convertor/progressbar.go
Normal file
217
internal/application/convertor/progressbar.go
Normal file
@ -0,0 +1,217 @@
|
||||
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
|
||||
}
|
152
internal/application/convertor/queue.go
Normal file
152
internal/application/convertor/queue.go
Normal file
@ -0,0 +1,152 @@
|
||||
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)
|
||||
}
|
||||
}
|
40
internal/application/setting/ffmpeg.go
Normal file
40
internal/application/setting/ffmpeg.go
Normal file
@ -0,0 +1,40 @@
|
||||
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)
|
||||
}
|
66
internal/application/setting/lang.go
Normal file
66
internal/application/setting/lang.go
Normal file
@ -0,0 +1,66 @@
|
||||
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)
|
||||
}
|
84
internal/application/setting/setting.go
Normal file
84
internal/application/setting/setting.go
Normal file
@ -0,0 +1,84 @@
|
||||
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)
|
||||
}
|
110
internal/application/setting/theme.go
Normal file
110
internal/application/setting/theme.go
Normal file
@ -0,0 +1,110 @@
|
||||
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)
|
||||
}
|
111
internal/controller/convertor.go
Normal file
111
internal/controller/convertor.go
Normal file
@ -0,0 +1,111 @@
|
||||
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
|
||||
}
|
16
internal/controller/error.go
Normal file
16
internal/controller/error.go
Normal file
@ -0,0 +1,16 @@
|
||||
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)
|
||||
}
|
96
internal/controller/main.go
Normal file
96
internal/controller/main.go
Normal file
@ -0,0 +1,96 @@
|
||||
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()
|
||||
}
|
67
internal/controller/menu.go
Normal file
67
internal/controller/menu.go
Normal file
@ -0,0 +1,67 @@
|
||||
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()
|
||||
}
|
14
internal/ffmpeg/download/gui/download_anyos.go
Normal file
14
internal/ffmpeg/download/gui/download_anyos.go
Normal file
@ -0,0 +1,14 @@
|
||||
//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 +1,19 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package convertor
|
||||
package gui
|
||||
|
||||
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 (v View) blockDownloadFFmpeg(
|
||||
donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error,
|
||||
) *fyne.Container {
|
||||
|
||||
func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error) fyne.CanvasObject {
|
||||
errorDownloadFFmpegMessage := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
errorDownloadFFmpegMessage.TextSize = 16
|
||||
errorDownloadFFmpegMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
@ -28,7 +26,7 @@ func (v View) blockDownloadFFmpeg(
|
||||
|
||||
var buttonDownloadFFmpeg *widget.Button
|
||||
|
||||
buttonDownloadFFmpeg = widget.NewButton(v.app.GetLocalizerService().GetMessage("download"), func() {
|
||||
buttonDownloadFFmpeg = widget.NewButton(lang.L("download"), func() {
|
||||
fyne.Do(func() {
|
||||
buttonDownloadFFmpeg.Disable()
|
||||
})
|
||||
@ -44,16 +42,16 @@ func (v View) blockDownloadFFmpeg(
|
||||
|
||||
})
|
||||
|
||||
downloadFFmpegFromSiteMessage := v.app.GetLocalizerService().GetMessage("downloadFFmpegFromSite")
|
||||
downloadFFmpegFromSiteMessage := lang.L("downloadFFmpegFromSite")
|
||||
|
||||
return container.NewVBox(
|
||||
canvas.NewLine(colornames.Darkgreen),
|
||||
widget.NewCard(v.app.GetLocalizerService().GetMessage("buttonDownloadFFmpeg"), "", container.NewVBox(
|
||||
widget.NewCard(lang.L("buttonDownloadFFmpeg"), "", container.NewVBox(
|
||||
widget.NewRichTextFromMarkdown(
|
||||
downloadFFmpegFromSiteMessage+" [https://github.com/BtbN/FFmpeg-Builds/releases](https://github.com/BtbN/FFmpeg-Builds/releases)",
|
||||
),
|
||||
buttonDownloadFFmpeg,
|
||||
errorDownloadFFmpegMessage,
|
||||
container.NewHScroll(errorDownloadFFmpegMessage),
|
||||
progressDownloadFFmpegMessage,
|
||||
progressBar,
|
||||
)),
|
@ -1,21 +1,19 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package convertor
|
||||
package gui
|
||||
|
||||
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 (v View) blockDownloadFFmpeg(
|
||||
donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error,
|
||||
) *fyne.Container {
|
||||
|
||||
func DownloadFFmpeg(donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error) fyne.CanvasObject {
|
||||
errorDownloadFFmpegMessage := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||
errorDownloadFFmpegMessage.TextSize = 16
|
||||
errorDownloadFFmpegMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
@ -28,7 +26,7 @@ func (v View) blockDownloadFFmpeg(
|
||||
|
||||
var buttonDownloadFFmpeg *widget.Button
|
||||
|
||||
buttonDownloadFFmpeg = widget.NewButton(v.app.GetLocalizerService().GetMessage("download"), func() {
|
||||
buttonDownloadFFmpeg = widget.NewButton(lang.L("download"), func() {
|
||||
|
||||
go func() {
|
||||
fyne.Do(func() {
|
||||
@ -44,16 +42,16 @@ func (v View) blockDownloadFFmpeg(
|
||||
}()
|
||||
})
|
||||
|
||||
downloadFFmpegFromSiteMessage := v.app.GetLocalizerService().GetMessage("downloadFFmpegFromSite")
|
||||
downloadFFmpegFromSiteMessage := lang.L("downloadFFmpegFromSite")
|
||||
|
||||
return container.NewVBox(
|
||||
canvas.NewLine(colornames.Darkgreen),
|
||||
widget.NewCard(v.app.GetLocalizerService().GetMessage("buttonDownloadFFmpeg"), "", container.NewVBox(
|
||||
widget.NewCard(lang.L("buttonDownloadFFmpeg"), "", container.NewVBox(
|
||||
widget.NewRichTextFromMarkdown(
|
||||
downloadFFmpegFromSiteMessage+" [https://github.com/BtbN/FFmpeg-Builds/releases](https://github.com/BtbN/FFmpeg-Builds/releases)",
|
||||
),
|
||||
buttonDownloadFFmpeg,
|
||||
errorDownloadFFmpegMessage,
|
||||
container.NewHScroll(errorDownloadFFmpegMessage),
|
||||
progressDownloadFFmpegMessage,
|
||||
progressBar,
|
||||
)),
|
21
internal/ffmpeg/download/service/download.go
Normal file
21
internal/ffmpeg/download/service/download.go
Normal file
@ -0,0 +1,21 @@
|
||||
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
|
||||
})
|
||||
}
|
15
internal/ffmpeg/download/service/download_anyos.go
Normal file
15
internal/ffmpeg/download/service/download_anyos.go
Normal file
@ -0,0 +1,15 @@
|
||||
//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,15 +1,16 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package handler
|
||||
package service
|
||||
|
||||
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/kernel"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||
"github.com/ulikunitz/xz"
|
||||
"io"
|
||||
"net/http"
|
||||
@ -17,59 +18,72 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
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 startDownload(app application.AppContract, progressBar *widget.ProgressBar, progressMessage *canvas.Text, save func(ffmpegPath string, ffprobePath string, ffplayPath string) error) error {
|
||||
var err error
|
||||
|
||||
func (h ConvertorHandler) downloadFFmpeg(progressBar *widget.ProgressBar, progressMessage *canvas.Text) (err error) {
|
||||
isDirectoryFFmpeg := isDirectory("ffmpeg")
|
||||
if isDirectoryFFmpeg == false {
|
||||
err = os.Mkdir("ffmpeg", 0777)
|
||||
dir, err := localSharePath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("downloadRun")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = downloadFile("ffmpeg/ffmpeg.tar.xz", "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz", progressBar)
|
||||
dir = filepath.Join(dir, "fyne", app.FyneApp().UniqueID())
|
||||
err = os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("unzipRun")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("downloadRun")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = unTarXz("ffmpeg/ffmpeg.tar.xz", "ffmpeg", progressBar)
|
||||
err = downloadFile(dir+"/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
|
||||
}
|
||||
_ = os.Remove("ffmpeg/ffmpeg.tar.xz")
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("testFF")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("unzipRun")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = unTarXz(dir+"/ffmpeg.tar.xz", dir, progressBar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = os.Remove(dir + "/ffmpeg.tar.xz")
|
||||
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("testFF")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
|
||||
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",
|
||||
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",
|
||||
)
|
||||
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
|
||||
@ -220,12 +234,3 @@ 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,15 +1,16 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package handler
|
||||
package service
|
||||
|
||||
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/kernel"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -17,52 +18,50 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func getPathsToFF() []kernel.FFPathUtilities {
|
||||
return []kernel.FFPathUtilities{{FFmpeg: "ffmpeg\\bin\\ffmpeg.exe", FFprobe: "ffmpeg\\bin\\ffprobe.exe", FFplay: "ffmpeg\\bin\\ffplay.exe"}}
|
||||
}
|
||||
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 (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)
|
||||
dir := os.Getenv("APPDATA")
|
||||
dir = filepath.Join(dir, "fyne", app.FyneApp().UniqueID())
|
||||
err = os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("unzipRun")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("downloadRun")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
err = unZip("ffmpeg/ffmpeg.zip", "ffmpeg", progressBar)
|
||||
err = downloadFile(dir+"/ffmpeg.zip", "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip", 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 = 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",
|
||||
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",
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
progressMessage.Text = h.app.GetLocalizerService().GetMessage("completedQueue")
|
||||
fyne.Do(func() {
|
||||
progressMessage.Text = lang.L("completedQueue")
|
||||
progressMessage.Refresh()
|
||||
})
|
||||
|
||||
@ -174,12 +173,3 @@ 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()
|
||||
}
|
21
internal/ffmpeg/encoder/apng/encoder.go
Normal file
21
internal/ffmpeg/encoder/apng/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/bmp/encoder.go
Normal file
21
internal/ffmpeg/encoder/bmp/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
@ -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) *Data {
|
||||
return &Data{
|
||||
func NewData(title string, formats []string, fileType FileTypeContract, encoder func() EncoderContract) EncoderDataContract {
|
||||
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) *Encoder {
|
||||
return &Encoder{
|
||||
func NewEncoder(name string, parameters map[string]ParameterContract, getParams func(parameters map[string]ParameterContract) []string) EncoderContract {
|
||||
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)) *Parameter {
|
||||
return &Parameter{
|
||||
func NewParameter(name string, isEnabled bool, defaultParameter string, setParameter func(string) (string, error)) ParameterContract {
|
||||
return ¶meter{
|
||||
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
|
||||
}
|
21
internal/ffmpeg/encoder/flv/encoder.go
Normal file
21
internal/ffmpeg/encoder/flv/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/gif/encoder.go
Normal file
21
internal/ffmpeg/encoder/gif/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
@ -2,7 +2,7 @@ package h264_nvenc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
@ -20,11 +20,11 @@ var Presets = []string{
|
||||
"losslesshp",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
params := []string{"-c:v", "h264_nvenc"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
@ -34,17 +34,17 @@ func NewEncoder() encoder2.EncoderContract {
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("h264_nvenc", parameters, getParams)
|
||||
return encoder.NewEncoder("h264_nvenc", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "h264_nvenc"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder2.ParameterContract {
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
@ -54,5 +54,5 @@ func newParameterPreset() encoder2.ParameterContract {
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
return encoder2.NewParameter("preset", false, "default", setParameter)
|
||||
return encoder.NewParameter("preset", false, "default", setParameter)
|
||||
}
|
21
internal/ffmpeg/encoder/libmp3lame/encoder.go
Normal file
21
internal/ffmpeg/encoder/libmp3lame/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/libshine/encoder.go
Normal file
21
internal/ffmpeg/encoder/libshine/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/libtwolame/encoder.go
Normal file
21
internal/ffmpeg/encoder/libtwolame/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/libvpx/encoder.go
Normal file
21
internal/ffmpeg/encoder/libvpx/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/libvpx_vp9/encoder.go
Normal file
21
internal/ffmpeg/encoder/libvpx_vp9/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/libwebp/encoder.go
Normal file
21
internal/ffmpeg/encoder/libwebp/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/libwebp_anim/encoder.go
Normal file
21
internal/ffmpeg/encoder/libwebp_anim/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
@ -2,7 +2,7 @@ package libx264
|
||||
|
||||
import (
|
||||
"errors"
|
||||
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
@ -18,11 +18,11 @@ var Presets = []string{
|
||||
"placebo",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
params := []string{"-c:v", "libx264"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
@ -32,17 +32,17 @@ func NewEncoder() encoder2.EncoderContract {
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libx264", parameters, getParams)
|
||||
return encoder.NewEncoder("libx264", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libx264"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder2.ParameterContract {
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
@ -52,5 +52,5 @@ func newParameterPreset() encoder2.ParameterContract {
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
return encoder2.NewParameter("preset", false, "medium", setParameter)
|
||||
return encoder.NewParameter("preset", false, "medium", setParameter)
|
||||
}
|
@ -2,7 +2,7 @@ package libx265
|
||||
|
||||
import (
|
||||
"errors"
|
||||
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
@ -18,11 +18,11 @@ var Presets = []string{
|
||||
"placebo",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder2.EncoderContract {
|
||||
parameters := map[string]encoder2.ParameterContract{
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder2.ParameterContract) []string {
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
params := []string{"-c:v", "libx265"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
@ -32,17 +32,17 @@ func NewEncoder() encoder2.EncoderContract {
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder2.NewEncoder("libx265", parameters, getParams)
|
||||
return encoder.NewEncoder("libx265", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder2.EncoderDataContract {
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libx265"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder2.FileType(encoder2.Video)
|
||||
return encoder2.NewData(title, formats, fileType, NewEncoder)
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder2.ParameterContract {
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
@ -52,5 +52,5 @@ func newParameterPreset() encoder2.ParameterContract {
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
return encoder2.NewParameter("preset", false, "medium", setParameter)
|
||||
return encoder.NewParameter("preset", false, "medium", setParameter)
|
||||
}
|
21
internal/ffmpeg/encoder/libxvid/encoder.go
Normal file
21
internal/ffmpeg/encoder/libxvid/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/mjpeg/encoder.go
Normal file
21
internal/ffmpeg/encoder/mjpeg/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/mp2/encoder.go
Normal file
21
internal/ffmpeg/encoder/mp2/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/mp2fixed/encoder.go
Normal file
21
internal/ffmpeg/encoder/mp2fixed/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/mpeg1video/encoder.go
Normal file
21
internal/ffmpeg/encoder/mpeg1video/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/mpeg2video/encoder.go
Normal file
21
internal/ffmpeg/encoder/mpeg2video/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/mpeg4/encoder.go
Normal file
21
internal/ffmpeg/encoder/mpeg4/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/msmpeg4/encoder.go
Normal file
21
internal/ffmpeg/encoder/msmpeg4/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/msmpeg4v2/encoder.go
Normal file
21
internal/ffmpeg/encoder/msmpeg4v2/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/msvideo1/encoder.go
Normal file
21
internal/ffmpeg/encoder/msvideo1/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/png/encoder.go
Normal file
21
internal/ffmpeg/encoder/png/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/qtrle/encoder.go
Normal file
21
internal/ffmpeg/encoder/qtrle/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/sgi/encoder.go
Normal file
21
internal/ffmpeg/encoder/sgi/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/tiff/encoder.go
Normal file
21
internal/ffmpeg/encoder/tiff/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/wmav1/encoder.go
Normal file
21
internal/ffmpeg/encoder/wmav1/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
21
internal/ffmpeg/encoder/wmav2/encoder.go
Normal file
21
internal/ffmpeg/encoder/wmav2/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
package wmav2
|
||||
|
||||
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", "wmav2"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("wmav2", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "wmav2"
|
||||
formats := []string{"wma"}
|
||||
fileType := encoder.FileType(encoder.Audio)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
21
internal/ffmpeg/encoder/wmv1/encoder.go
Normal file
21
internal/ffmpeg/encoder/wmv1/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
package wmv1
|
||||
|
||||
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", "wmv1"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("wmv1", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "wmv1"
|
||||
formats := []string{"wmv"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
21
internal/ffmpeg/encoder/wmv2/encoder.go
Normal file
21
internal/ffmpeg/encoder/wmv2/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
package wmv2
|
||||
|
||||
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", "wmv2"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("wmv2", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "wmv2"
|
||||
formats := []string{"wmv"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
21
internal/ffmpeg/encoder/xbm/encoder.go
Normal file
21
internal/ffmpeg/encoder/xbm/encoder.go
Normal file
@ -0,0 +1,21 @@
|
||||
package xbm
|
||||
|
||||
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", "xbm"}
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("xbm", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "xbm"
|
||||
formats := []string{"xbm"}
|
||||
fileType := encoder.FileType(encoder.Image)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
139
internal/ffmpeg/ffmpeg.go
Normal file
139
internal/ffmpeg/ffmpeg.go
Normal file
@ -0,0 +1,139 @@
|
||||
package ffmpeg
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
"io"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ProgressContract interface {
|
||||
GetProtocole() string
|
||||
Run(stdOut io.ReadCloser, stdErr io.ReadCloser) error
|
||||
}
|
||||
|
||||
type FFmpegContract interface {
|
||||
GetPath() string
|
||||
GetVersion() (string, error)
|
||||
GetEncoders(scanner func(scanner *bufio.Reader)) error
|
||||
RunConvert(setting ConvertSetting, progress ProgressContract, beforeWait func(cmd *exec.Cmd), afterWait func(cmd *exec.Cmd)) error
|
||||
}
|
||||
|
||||
type ffmpeg struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func newFFmpeg(path string) (FFmpegContract, error) {
|
||||
if path == "" {
|
||||
return nil, errors.New(lang.L("errorFFmpeg"))
|
||||
}
|
||||
|
||||
isCheck, err := checkFFmpegPath(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if isCheck == false {
|
||||
return nil, errors.New(lang.L("errorFFmpeg"))
|
||||
}
|
||||
|
||||
return &ffmpeg{
|
||||
path: path,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (f *ffmpeg) GetPath() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
func (f *ffmpeg) GetVersion() (string, error) {
|
||||
cmd := exec.Command(f.path, "-version")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
text := regexp.MustCompile("\r?\n").Split(strings.TrimSpace(string(out)), -1)
|
||||
return text[0], nil
|
||||
}
|
||||
|
||||
func (f *ffmpeg) RunConvert(setting ConvertSetting, progress ProgressContract, beforeWait func(cmd *exec.Cmd), afterWait func(cmd *exec.Cmd)) error {
|
||||
overwriteOutputFiles := "-n"
|
||||
if setting.OverwriteOutputFiles == true {
|
||||
overwriteOutputFiles = "-y"
|
||||
}
|
||||
args := []string{overwriteOutputFiles, "-i", setting.FileInput.Path}
|
||||
args = append(args, setting.Encoder.GetParams()...)
|
||||
args = append(args, "-progress", progress.GetProtocole(), setting.FileOut.Path)
|
||||
cmd := exec.Command(f.path, args...)
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
|
||||
stdOut, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stdErr, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if beforeWait != nil {
|
||||
beforeWait(cmd)
|
||||
}
|
||||
|
||||
errProgress := progress.Run(stdOut, stdErr)
|
||||
|
||||
err = cmd.Wait()
|
||||
if afterWait != nil {
|
||||
afterWait(cmd)
|
||||
}
|
||||
if errProgress != nil {
|
||||
return errProgress
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *ffmpeg) GetEncoders(scanner func(scanner *bufio.Reader)) error {
|
||||
cmd := exec.Command(f.path, "-encoders")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
|
||||
stdOut, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
scannerErr := bufio.NewReader(stdOut)
|
||||
scanner(scannerErr)
|
||||
|
||||
return cmd.Wait()
|
||||
}
|
||||
|
||||
func checkFFmpegPath(path string) (bool, error) {
|
||||
cmd := exec.Command(path, "-version")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if strings.Contains(strings.TrimSpace(string(out)), "ffmpeg") == false {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
73
internal/ffmpeg/ffplay.go
Normal file
73
internal/ffmpeg/ffplay.go
Normal file
@ -0,0 +1,73 @@
|
||||
package ffmpeg
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FFplayContract interface {
|
||||
GetPath() string
|
||||
GetVersion() (string, error)
|
||||
Play(file *File) error
|
||||
}
|
||||
|
||||
type ffplay struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func newFFplay(path string) (FFplayContract, error) {
|
||||
if path == "" {
|
||||
return nil, errors.New(lang.L("errorFFplay"))
|
||||
}
|
||||
|
||||
isCheck, err := checkFFplayPath(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if isCheck == false {
|
||||
return nil, errors.New(lang.L("errorFFplay"))
|
||||
}
|
||||
|
||||
return &ffplay{
|
||||
path: path,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (f *ffplay) GetPath() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
func (f *ffplay) GetVersion() (string, error) {
|
||||
cmd := exec.Command(f.path, "-version")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
text := regexp.MustCompile("\r?\n").Split(strings.TrimSpace(string(out)), -1)
|
||||
return text[0], nil
|
||||
}
|
||||
|
||||
func (f *ffplay) Play(file *File) error {
|
||||
args := []string{file.Path}
|
||||
cmd := exec.Command(f.GetPath(), args...)
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func checkFFplayPath(path string) (bool, error) {
|
||||
cmd := exec.Command(path, "-version")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if strings.Contains(strings.TrimSpace(string(out)), "ffplay") == false {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
124
internal/ffmpeg/ffprobe.go
Normal file
124
internal/ffmpeg/ffprobe.go
Normal file
@ -0,0 +1,124 @@
|
||||
package ffmpeg
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
type FFprobeContract interface {
|
||||
GetPath() string
|
||||
GetVersion() (string, error)
|
||||
GetTotalDuration(file *File) (float64, error)
|
||||
}
|
||||
|
||||
type ffprobe struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func newFFprobe(path string) (FFprobeContract, error) {
|
||||
if path == "" {
|
||||
return nil, errors.New(lang.L("errorFFprobe"))
|
||||
}
|
||||
|
||||
isCheck, err := checkFFprobePath(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if isCheck == false {
|
||||
return nil, errors.New(lang.L("errorFFprobe"))
|
||||
}
|
||||
|
||||
return &ffprobe{
|
||||
path: path,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (f *ffprobe) GetPath() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
func (f *ffprobe) GetVersion() (string, error) {
|
||||
cmd := exec.Command(f.path, "-version")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
text := regexp.MustCompile("\r?\n").Split(strings.TrimSpace(string(out)), -1)
|
||||
return text[0], nil
|
||||
}
|
||||
|
||||
func (f *ffprobe) GetTotalDuration(file *File) (duration float64, err error) {
|
||||
args := []string{"-v", "error", "-select_streams", "v:0", "-count_packets", "-show_entries", "stream=nb_read_packets", "-of", "csv=p=0", file.Path}
|
||||
cmd := exec.Command(f.path, args...)
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
errString := strings.TrimSpace(string(out))
|
||||
if len(errString) > 1 {
|
||||
return 0, errors.New(errString)
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
frames := strings.TrimSpace(string(out))
|
||||
if len(frames) == 0 {
|
||||
return f.getAlternativeTotalDuration(file)
|
||||
}
|
||||
|
||||
duration, err = strconv.ParseFloat(frames, 64)
|
||||
if err != nil {
|
||||
// fix .mts duration
|
||||
return strconv.ParseFloat(getFirstDigits(frames), 64)
|
||||
}
|
||||
return duration, err
|
||||
}
|
||||
|
||||
func (f *ffprobe) getAlternativeTotalDuration(file *File) (duration float64, err error) {
|
||||
args := []string{"-v", "error", "-select_streams", "a:0", "-count_packets", "-show_entries", "stream=nb_read_packets", "-of", "csv=p=0", file.Path}
|
||||
cmd := exec.Command(f.path, args...)
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
errString := strings.TrimSpace(string(out))
|
||||
if len(errString) > 1 {
|
||||
return 0, errors.New(errString)
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
frames := strings.TrimSpace(string(out))
|
||||
if len(frames) == 0 {
|
||||
return 0, errors.New("error getting number of frames")
|
||||
}
|
||||
return strconv.ParseFloat(frames, 64)
|
||||
}
|
||||
|
||||
func checkFFprobePath(path string) (bool, error) {
|
||||
cmd := exec.Command(path, "-version")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if strings.Contains(strings.TrimSpace(string(out)), "ffprobe") == false {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func getFirstDigits(s string) string {
|
||||
result := ""
|
||||
for _, r := range s {
|
||||
if unicode.IsDigit(r) {
|
||||
result += string(r)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
221
internal/ffmpeg/utilities.go
Normal file
221
internal/ffmpeg/utilities.go
Normal file
@ -0,0 +1,221 @@
|
||||
package ffmpeg
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/setting"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
type File struct {
|
||||
Path string
|
||||
Name string
|
||||
Ext string
|
||||
}
|
||||
|
||||
type ConvertSetting struct {
|
||||
FileInput File
|
||||
FileOut File
|
||||
OverwriteOutputFiles bool
|
||||
Encoder encoder.EncoderContract
|
||||
}
|
||||
|
||||
type UtilitiesContract interface {
|
||||
UtilityCheck() bool
|
||||
|
||||
GetFFmpeg() (FFmpegContract, error)
|
||||
GetFFmpegVersion() string
|
||||
GetFFmpegPath() string
|
||||
ChangeFFmpeg(path string) error
|
||||
|
||||
GetFFprobe() (FFprobeContract, error)
|
||||
GetFFprobeVersion() string
|
||||
GetFFprobePath() string
|
||||
ChangeFFprobe(path string) error
|
||||
|
||||
GetFFplay() (FFplayContract, error)
|
||||
GetFFplayVersion() string
|
||||
GetFFplayPath() string
|
||||
ChangeFFplay(path string) error
|
||||
}
|
||||
|
||||
type utilities struct {
|
||||
setting setting.SettingContract
|
||||
ffmpeg FFmpegContract
|
||||
ffprobe FFprobeContract
|
||||
ffplay FFplayContract
|
||||
}
|
||||
|
||||
func NewUtilities(setting setting.SettingContract) UtilitiesContract {
|
||||
return &utilities{
|
||||
setting: setting,
|
||||
}
|
||||
}
|
||||
|
||||
func (u *utilities) UtilityCheck() bool {
|
||||
var err error
|
||||
|
||||
_, err = u.GetFFmpeg()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
_, err = u.GetFFprobe()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
_, err = u.GetFFplay()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFmpeg() (FFmpegContract, error) {
|
||||
if u.ffmpeg == nil {
|
||||
createFFmpeg, err := newFFmpeg(u.setting.GetFFmpegPath())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
u.ffmpeg = createFFmpeg
|
||||
}
|
||||
|
||||
return u.ffmpeg, nil
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFmpegVersion() string {
|
||||
ffmpegService, err := u.GetFFmpeg()
|
||||
if err != nil {
|
||||
return lang.L("errorFFmpegVersion")
|
||||
}
|
||||
|
||||
version, err := ffmpegService.GetVersion()
|
||||
if err != nil {
|
||||
return lang.L("errorFFmpegVersion")
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFmpegPath() string {
|
||||
ffmpegService, err := u.GetFFmpeg()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return ffmpegService.GetPath()
|
||||
}
|
||||
|
||||
func (u *utilities) ChangeFFmpeg(path string) error {
|
||||
if path == "" {
|
||||
return errors.New(lang.L("errorFFmpeg"))
|
||||
}
|
||||
|
||||
createFFmpeg, err := newFFmpeg(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
u.ffmpeg = createFFmpeg
|
||||
u.setting.SetFFmpegPath(path)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFprobe() (FFprobeContract, error) {
|
||||
if u.ffprobe == nil {
|
||||
createFFprobe, err := newFFprobe(u.setting.GetFFprobePath())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
u.ffprobe = createFFprobe
|
||||
}
|
||||
|
||||
return u.ffprobe, nil
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFprobeVersion() string {
|
||||
ffprobeService, err := u.GetFFprobe()
|
||||
if err != nil {
|
||||
return lang.L("errorFFprobeVersion")
|
||||
}
|
||||
|
||||
ffprobeVersion, err := ffprobeService.GetVersion()
|
||||
if err != nil {
|
||||
return lang.L("errorFFprobeVersion")
|
||||
}
|
||||
return ffprobeVersion
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFprobePath() string {
|
||||
ffprobeService, err := u.GetFFprobe()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return ffprobeService.GetPath()
|
||||
}
|
||||
|
||||
func (u *utilities) ChangeFFprobe(path string) error {
|
||||
if path == "" {
|
||||
return errors.New(lang.L("errorFFprobe"))
|
||||
}
|
||||
|
||||
createFFprobe, err := newFFprobe(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
u.ffprobe = createFFprobe
|
||||
u.setting.SetFFprobePath(path)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFplay() (FFplayContract, error) {
|
||||
if u.ffplay == nil {
|
||||
createFFplay, err := newFFplay(u.setting.GetFFplayPath())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
u.ffplay = createFFplay
|
||||
}
|
||||
|
||||
return u.ffplay, nil
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFplayVersion() string {
|
||||
ffplayService, err := u.GetFFplay()
|
||||
if err != nil {
|
||||
return lang.L("errorFFplayVersion")
|
||||
}
|
||||
|
||||
ffplayVersion, err := ffplayService.GetVersion()
|
||||
if err != nil {
|
||||
return lang.L("errorFFplayVersion")
|
||||
}
|
||||
return ffplayVersion
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFplayPath() string {
|
||||
ffplayService, err := u.GetFFplay()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return ffplayService.GetPath()
|
||||
}
|
||||
|
||||
func (u *utilities) ChangeFFplay(path string) error {
|
||||
if path == "" {
|
||||
return errors.New(lang.L("errorFFplay"))
|
||||
}
|
||||
|
||||
createFFplay, err := newFFplay(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
u.ffplay = createFFplay
|
||||
u.setting.SetFFplayPath(path)
|
||||
|
||||
return nil
|
||||
}
|
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