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:
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
|
||||
}
|
Reference in New Issue
Block a user