Версия 1.0.0 #11
@ -10,8 +10,9 @@ import (
|
||||
type AppContract interface {
|
||||
FyneApp() fyne.App
|
||||
GetSetting() setting.SettingContract
|
||||
GetProgressBarService() ProgressBarContract
|
||||
GetProgressBarService() convertor.ProgressBarContract
|
||||
GetFFmpegService() ffmpeg.UtilitiesContract
|
||||
GetConvertorService() convertor.ConvertorContract
|
||||
GetItemsToConvert() convertor.ItemsToConvertContract
|
||||
GetQueueService() convertor.QueueListContract
|
||||
Run()
|
||||
@ -20,19 +21,21 @@ type AppContract interface {
|
||||
type application struct {
|
||||
fyneApp fyne.App
|
||||
setting setting.SettingContract
|
||||
progressBarService ProgressBarContract
|
||||
progressBarService convertor.ProgressBarContract
|
||||
ffmpegService ffmpeg.UtilitiesContract
|
||||
itemsToConvert convertor.ItemsToConvertContract
|
||||
queueService convertor.QueueListContract
|
||||
convertorService convertor.ConvertorContract
|
||||
}
|
||||
|
||||
func NewApp(
|
||||
fyneApp fyne.App,
|
||||
setting setting.SettingContract,
|
||||
progressBarService ProgressBarContract,
|
||||
progressBarService convertor.ProgressBarContract,
|
||||
ffmpegService ffmpeg.UtilitiesContract,
|
||||
itemsToConvert convertor.ItemsToConvertContract,
|
||||
queueService convertor.QueueListContract,
|
||||
convertorService convertor.ConvertorContract,
|
||||
) AppContract {
|
||||
return &application{
|
||||
fyneApp: fyneApp,
|
||||
@ -41,6 +44,7 @@ func NewApp(
|
||||
ffmpegService: ffmpegService,
|
||||
itemsToConvert: itemsToConvert,
|
||||
queueService: queueService,
|
||||
convertorService: convertorService,
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +56,7 @@ func (a *application) GetSetting() setting.SettingContract {
|
||||
return a.setting
|
||||
}
|
||||
|
||||
func (a *application) GetProgressBarService() ProgressBarContract {
|
||||
func (a *application) GetProgressBarService() convertor.ProgressBarContract {
|
||||
return a.progressBarService
|
||||
}
|
||||
|
||||
@ -68,6 +72,10 @@ 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()
|
||||
}
|
||||
|
54
internal/application/convertor/convertor.go
Normal file
54
internal/application/convertor/convertor.go
Normal file
@ -0,0 +1,54 @@
|
||||
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"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ConvertorContract interface {
|
||||
GetSupportFormats() (encoder.ConvertorFormatsContract, error)
|
||||
}
|
||||
|
||||
type convertor struct {
|
||||
ffmpegService ffmpeg.UtilitiesContract
|
||||
}
|
||||
|
||||
func NewConvertor(
|
||||
ffmpegService ffmpeg.UtilitiesContract,
|
||||
) ConvertorContract {
|
||||
return &convertor{
|
||||
ffmpegService: ffmpegService,
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
84
internal/application/convertor/encoder/encoder.go
Normal file
84
internal/application/convertor/encoder/encoder.go
Normal file
@ -0,0 +1,84 @@
|
||||
package encoder
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
type ConvertorFormatContract interface {
|
||||
GetTitle() string
|
||||
AddEncoder(encoder encoder.EncoderDataContract)
|
||||
GetFileType() encoder.FileTypeContract
|
||||
GetEncoders() map[int]encoder.EncoderDataContract
|
||||
}
|
||||
|
||||
type ConvertorFormat struct {
|
||||
title string
|
||||
fileType encoder.FileTypeContract
|
||||
encoders map[int]encoder.EncoderDataContract
|
||||
}
|
||||
|
||||
func NewConvertorFormat(title string, fileType encoder.FileTypeContract) ConvertorFormatContract {
|
||||
return &ConvertorFormat{
|
||||
title: title,
|
||||
fileType: fileType,
|
||||
encoders: map[int]encoder.EncoderDataContract{},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *ConvertorFormat) GetTitle() string {
|
||||
return f.title
|
||||
}
|
||||
|
||||
func (f *ConvertorFormat) AddEncoder(encoder encoder.EncoderDataContract) {
|
||||
f.encoders[len(f.encoders)] = encoder
|
||||
}
|
||||
|
||||
func (f *ConvertorFormat) GetEncoders() map[int]encoder.EncoderDataContract {
|
||||
return f.encoders
|
||||
}
|
||||
|
||||
func (f *ConvertorFormat) GetFileType() encoder.FileTypeContract {
|
||||
return f.fileType
|
||||
}
|
||||
|
||||
type ConvertorFormatsContract interface {
|
||||
NewEncoder(encoderName string) bool
|
||||
GetFormats() map[string]ConvertorFormatContract
|
||||
GetFormat(format string) (ConvertorFormatContract, error)
|
||||
}
|
||||
|
||||
type ConvertorFormats struct {
|
||||
formats map[string]ConvertorFormatContract
|
||||
}
|
||||
|
||||
func NewConvertorFormats() ConvertorFormatsContract {
|
||||
return &ConvertorFormats{
|
||||
formats: map[string]ConvertorFormatContract{},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *ConvertorFormats) NewEncoder(encoderName string) bool {
|
||||
if supportEncoders[encoderName] == nil {
|
||||
return false
|
||||
}
|
||||
data := supportEncoders[encoderName]()
|
||||
for _, format := range data.GetFormats() {
|
||||
if f.formats[format] == nil {
|
||||
f.formats[format] = NewConvertorFormat(format, data.GetFileType())
|
||||
}
|
||||
f.formats[format].AddEncoder(data)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (f *ConvertorFormats) GetFormats() map[string]ConvertorFormatContract {
|
||||
return f.formats
|
||||
}
|
||||
|
||||
func (f *ConvertorFormats) GetFormat(format string) (ConvertorFormatContract, error) {
|
||||
if f.formats[format] == nil {
|
||||
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,
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package application
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
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)
|
||||
}
|
169
internal/ffmpeg/encoder/encoder.go
Normal file
169
internal/ffmpeg/encoder/encoder.go
Normal file
@ -0,0 +1,169 @@
|
||||
package encoder
|
||||
|
||||
import "errors"
|
||||
|
||||
type EncoderContract interface {
|
||||
GetName() string
|
||||
GetParams() []string
|
||||
GetParameter(name string) (ParameterContract, error)
|
||||
}
|
||||
|
||||
type ParameterContract interface {
|
||||
GetName() string
|
||||
Set(string) error
|
||||
Get() string
|
||||
IsEnabled() bool
|
||||
SetEnable()
|
||||
SetDisable()
|
||||
}
|
||||
|
||||
type EncoderDataContract interface {
|
||||
GetTitle() string
|
||||
GetFormats() []string
|
||||
GetFileType() FileTypeContract
|
||||
NewEncoder() EncoderContract
|
||||
}
|
||||
|
||||
type data struct {
|
||||
title string
|
||||
formats []string
|
||||
fileType FileTypeContract
|
||||
encoder func() EncoderContract
|
||||
}
|
||||
|
||||
func NewData(title string, formats []string, fileType FileTypeContract, encoder func() EncoderContract) EncoderDataContract {
|
||||
return &data{
|
||||
title: title,
|
||||
formats: formats,
|
||||
fileType: fileType,
|
||||
encoder: encoder,
|
||||
}
|
||||
}
|
||||
|
||||
func (data *data) GetTitle() string {
|
||||
return data.title
|
||||
}
|
||||
|
||||
func (data *data) GetFormats() []string {
|
||||
return data.formats
|
||||
}
|
||||
|
||||
func (data *data) NewEncoder() EncoderContract {
|
||||
return data.encoder()
|
||||
}
|
||||
|
||||
func (data *data) GetFileType() FileTypeContract {
|
||||
return data.fileType
|
||||
}
|
||||
|
||||
type FileTypeContract interface {
|
||||
Name() string
|
||||
Ordinal() int
|
||||
}
|
||||
|
||||
const (
|
||||
Video = iota
|
||||
Audio
|
||||
Image
|
||||
)
|
||||
|
||||
type FileType uint
|
||||
|
||||
var fileTypeStrings = []string{
|
||||
"video",
|
||||
"audio",
|
||||
"image",
|
||||
}
|
||||
|
||||
func (fileType FileType) Name() string {
|
||||
return fileTypeStrings[fileType]
|
||||
}
|
||||
|
||||
func (fileType FileType) Ordinal() int {
|
||||
return int(fileType)
|
||||
}
|
||||
|
||||
func GetListFileType() []FileTypeContract {
|
||||
return []FileTypeContract{
|
||||
FileType(Video),
|
||||
FileType(Audio),
|
||||
FileType(Image),
|
||||
}
|
||||
}
|
||||
|
||||
type encoder struct {
|
||||
name string
|
||||
parameters map[string]ParameterContract
|
||||
getParams func(parameters map[string]ParameterContract) []string
|
||||
}
|
||||
|
||||
func NewEncoder(name string, parameters map[string]ParameterContract, getParams func(parameters map[string]ParameterContract) []string) EncoderContract {
|
||||
return &encoder{
|
||||
name: name,
|
||||
parameters: parameters,
|
||||
getParams: getParams,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *encoder) GetName() string {
|
||||
return e.name
|
||||
}
|
||||
|
||||
func (e *encoder) GetParams() []string {
|
||||
return e.getParams(e.parameters)
|
||||
}
|
||||
|
||||
func (e *encoder) GetParameter(name string) (ParameterContract, error) {
|
||||
if e.parameters[name] == nil {
|
||||
return nil, errors.New("parameter not found")
|
||||
}
|
||||
|
||||
return e.parameters[name], nil
|
||||
}
|
||||
|
||||
type parameter struct {
|
||||
name string
|
||||
isEnabled bool
|
||||
parameter string
|
||||
setParameter func(string) (string, error)
|
||||
}
|
||||
|
||||
func NewParameter(name string, isEnabled bool, defaultParameter string, setParameter func(string) (string, error)) ParameterContract {
|
||||
return ¶meter{
|
||||
name: name,
|
||||
isEnabled: isEnabled,
|
||||
parameter: defaultParameter,
|
||||
setParameter: setParameter,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *parameter) GetName() string {
|
||||
return p.name
|
||||
}
|
||||
|
||||
func (p *parameter) Set(s string) (err error) {
|
||||
if p.setParameter != nil {
|
||||
s, err = p.setParameter(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
p.parameter = s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *parameter) Get() string {
|
||||
return p.parameter
|
||||
}
|
||||
|
||||
func (p *parameter) IsEnabled() bool {
|
||||
return p.isEnabled
|
||||
}
|
||||
|
||||
func (p *parameter) SetEnable() {
|
||||
p.isEnabled = true
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
58
internal/ffmpeg/encoder/h264_nvenc/encoder.go
Normal file
58
internal/ffmpeg/encoder/h264_nvenc/encoder.go
Normal file
@ -0,0 +1,58 @@
|
||||
package h264_nvenc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
"default",
|
||||
"slow",
|
||||
"medium",
|
||||
"fast",
|
||||
"hp",
|
||||
"hq",
|
||||
"bd",
|
||||
"ll",
|
||||
"llhq",
|
||||
"llhp",
|
||||
"lossless",
|
||||
"losslesshp",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
params := []string{"-c:v", "h264_nvenc"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
params = append(params, "-preset", parameters["preset"].Get())
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("h264_nvenc", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "h264_nvenc"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
return value, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
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)
|
||||
}
|
56
internal/ffmpeg/encoder/libx264/encoder.go
Normal file
56
internal/ffmpeg/encoder/libx264/encoder.go
Normal file
@ -0,0 +1,56 @@
|
||||
package libx264
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
"ultrafast",
|
||||
"superfast",
|
||||
"veryfast",
|
||||
"faster",
|
||||
"fast",
|
||||
"medium",
|
||||
"slow",
|
||||
"slower",
|
||||
"veryslow",
|
||||
"placebo",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
params := []string{"-c:v", "libx264"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
params = append(params, "-preset", parameters["preset"].Get())
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libx264", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libx264"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
return value, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
return encoder.NewParameter("preset", false, "medium", setParameter)
|
||||
}
|
56
internal/ffmpeg/encoder/libx265/encoder.go
Normal file
56
internal/ffmpeg/encoder/libx265/encoder.go
Normal file
@ -0,0 +1,56 @@
|
||||
package libx265
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
)
|
||||
|
||||
var Presets = []string{
|
||||
"ultrafast",
|
||||
"superfast",
|
||||
"veryfast",
|
||||
"faster",
|
||||
"fast",
|
||||
"medium",
|
||||
"slow",
|
||||
"slower",
|
||||
"veryslow",
|
||||
"placebo",
|
||||
}
|
||||
|
||||
func NewEncoder() encoder.EncoderContract {
|
||||
parameters := map[string]encoder.ParameterContract{
|
||||
"preset": newParameterPreset(),
|
||||
}
|
||||
getParams := func(parameters map[string]encoder.ParameterContract) []string {
|
||||
params := []string{"-c:v", "libx265"}
|
||||
|
||||
if parameters["preset"] != nil && parameters["preset"].IsEnabled() {
|
||||
params = append(params, "-preset", parameters["preset"].Get())
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
return encoder.NewEncoder("libx265", parameters, getParams)
|
||||
}
|
||||
|
||||
func NewData() encoder.EncoderDataContract {
|
||||
title := "libx265"
|
||||
formats := []string{"mp4"}
|
||||
fileType := encoder.FileType(encoder.Video)
|
||||
return encoder.NewData(title, formats, fileType, NewEncoder)
|
||||
}
|
||||
|
||||
func newParameterPreset() encoder.ParameterContract {
|
||||
setParameter := func(s string) (string, error) {
|
||||
for _, value := range Presets {
|
||||
if value == s {
|
||||
return value, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", errors.New("preset not found")
|
||||
}
|
||||
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)
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package ffmpeg
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
@ -10,6 +11,7 @@ import (
|
||||
|
||||
type FFmpegContract interface {
|
||||
GetPath() string
|
||||
GetEncoders(scanner func(scanner *bufio.Reader)) error
|
||||
}
|
||||
|
||||
type ffmpeg struct {
|
||||
@ -38,6 +40,26 @@ func (f *ffmpeg) GetPath() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
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)
|
||||
|
15
internal/gui/view/convertor/encoders/encoders.go
Normal file
15
internal/gui/view/convertor/encoders/encoders.go
Normal file
@ -0,0 +1,15 @@
|
||||
package encoders
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/encoder"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view/convertor/encoders/h264_nvenc"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view/convertor/encoders/libx264"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view/convertor/encoders/libx265"
|
||||
)
|
||||
|
||||
var Views = map[string]func(encoder encoder.EncoderContract) []*widget.FormItem{
|
||||
"libx264": libx264.View,
|
||||
"h264_nvenc": h264_nvenc.View,
|
||||
"libx265": libx265.View,
|
||||
}
|
13
main.go
13
main.go
@ -20,12 +20,21 @@ func main() {
|
||||
}
|
||||
app.SetMetadata(appMetadata)
|
||||
fyneApp := app.New()
|
||||
progressBarService := application.NewProgressBar()
|
||||
progressBarService := convertor.NewProgressBar()
|
||||
appSetting := setting.NewSetting(fyneApp)
|
||||
ffmpegService := ffmpeg.NewUtilities(appSetting)
|
||||
convertorService := convertor.NewConvertor(ffmpegService)
|
||||
itemsToConvert := convertor.NewItemsToConvert(ffmpegService)
|
||||
queue := convertor.NewQueueList()
|
||||
myApp := application.NewApp(fyneApp, appSetting, progressBarService, ffmpegService, itemsToConvert, queue)
|
||||
myApp := application.NewApp(
|
||||
fyneApp,
|
||||
appSetting,
|
||||
progressBarService,
|
||||
ffmpegService,
|
||||
itemsToConvert,
|
||||
queue,
|
||||
convertorService,
|
||||
)
|
||||
mainController := controller.NewController(myApp)
|
||||
mainController.Start()
|
||||
myApp.Run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user