From 956c8f3a201f13da822b2298fb4c8da13d79897d Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Thu, 9 May 2024 04:46:49 +0200 Subject: [PATCH] Implement ffmpeg building --- types/ffmpeg.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 types/ffmpeg.go 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"