Implement ffmpeg building

This commit is contained in:
Samuel Lorch 2024-05-09 04:46:49 +02:00
parent a31bd84eaa
commit 956c8f3a20

53
types/ffmpeg.go Normal file
View file

@ -0,0 +1,53 @@
package types
type FFmpegCommand struct {
Args []Arg `json:"args"`
InputFiles []File `json:"input_files"`
OutputFiles []File `json:"output_files"`
}
type File struct {
Path string `json:"path"`
Arguments []Arg `json:"args"`
}
type Arg struct {
Flag string `json:"flag"`
Value string `json:"value"`
}
func (c *FFmpegCommand) GetArgs() []string {
args := []string{}
for _, a := range c.Args {
args = append(args, a.Flag)
if a.Value != "" {
args = append(args, a.Value)
}
}
for _, i := range c.InputFiles {
for _, a := range i.Arguments {
args = append(args, a.Flag)
if a.Value != "" {
args = append(args, a.Value)
}
}
args = append(args, "-i", i.Path)
}
for _, i := range c.OutputFiles {
for _, a := range i.Arguments {
args = append(args, a.Flag)
if a.Value != "" {
args = append(args, a.Value)
}
}
args = append(args, i.Path)
}
return args
}
// ffmpeg -loglevel error -stats
// ffmpeg.exe -stats -v error -i "in.mp4" -f null -max_muxing_queue_size 9999 "out.mp4"