Add initial implementations for encoder handling and conversion logic

Introduce encoder modules for various codecs and formats (e.g., h264_nvenc, libx264, libmp3lame). Add `Convertor` logic to retrieve supported formats via FFmpeg utilities and manage encoders for audio, video, and image processing.
This commit is contained in:
2025-06-08 17:26:17 +05:00
parent 6c0abac1c5
commit 9cdfa18fc8
42 changed files with 1242 additions and 7 deletions

View 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
}