MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / buildFFmpegArgs

Function buildFFmpegArgs

agent/utils/convert/convert.go:116–144  ·  view source on GitHub ↗
(inputFile, outputFile, outputFormat string)

Source from the content-addressed store, hash-verified

114}
115
116func buildFFmpegArgs(inputFile, outputFile, outputFormat string) ([]string, string, error) {
117 args := []string{"-y", "-i", inputFile}
118 opt, ok := FormatMap[outputFormat]
119 if !ok {
120 return nil, "", fmt.Errorf("unsupported format: %s", outputFormat)
121 }
122
123 switch opt.Type {
124 case "image":
125 switch outputFormat {
126 case "webp":
127 args = append(args, "-c:v", "libwebp", "-lossless", "0", "-q:v", "75")
128 case "png", "gif", "jpg", "jpeg", "bmp", "tiff":
129 args = append(args, "-c:v", opt.Codec)
130 }
131
132 case "video":
133 args = append(args, "-c:v", opt.Codec, "-preset", "fast", "-crf", "23", "-c:a", "aac", "-b:a", "192k")
134
135 case "audio":
136 args = append(args, "-c:a", opt.Codec, "-b:a", "192k")
137
138 default:
139 return nil, opt.Type, fmt.Errorf("unsupported media type: %s", opt.Type)
140 }
141
142 args = append(args, outputFile)
143 return args, opt.Type, nil
144}
145
146func appendLog(f *os.File, content string) error {
147 _, err := f.WriteString(content)

Callers 1

MediaFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected