This commit is contained in:
2026-03-13 00:04:04 +08:00
parent 030d8e9e6d
commit 5972ba1948
4 changed files with 50 additions and 32 deletions

View File

@@ -470,15 +470,17 @@ func handleFfmpegProcess(ctx context.Context, ffmpegCmd []string) (bool, error)
return true, nil
}
func CompressTo720p(ctx context.Context, inputFile, outputFile string) (bool, error) {
subCtx, span := tracer.Start(ctx, "CompressTo720p")
func CompressVideo(ctx context.Context, inputFile, outputFile string, height int) (bool, error) {
subCtx, span := tracer.Start(ctx, "CompressVideo")
defer span.End()
span.SetAttributes(attribute.Int("height", height))
scaleFilter := fmt.Sprintf("scale=-2:%d", height)
ffmpegCmd := []string{
FfmpegExec,
"-hide_banner",
"-y",
"-i", inputFile,
"-vf", "scale=-2:720",
"-vf", scaleFilter,
"-c:v", "libx264",
"-preset", "fast",
"-crf", "28",