diff --git a/types/ffmpeg.go b/types/ffmpeg.go new file mode 100644 index 0000000..4f9bd99 --- /dev/null +++ b/types/ffmpeg.go @@ -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"