first working version

This commit is contained in:
2026-09-06 03:48:12 +02:00
parent 69498110ed
commit d0d34beb44
3 changed files with 152 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
)
func ConvertVideo(path string) {
out := path[:len(path)-len(filepath.Ext(path))] + ".mp4"
cmd := exec.Command("ffmpeg",
"-i", "input.mp4",
"-c:v", "libx264",
"-crf", "23",
"-preset", "medium",
"-c:a", "aac",
"-b:a", "128k",
out,
)
cmd.Stderr = cmd.Stdout
_, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf("Error converting %s: %v\n", path, err)
return
}
if err := os.Remove(path); err != nil {
fmt.Printf("Converted %s -> %s, but failed to delete original: %v\n", path, out, err)
return
}
fmt.Printf("Converted %s -> %s (original deleted)\n", path, out)
}