feat: fix command issues
This commit is contained in:
@@ -262,9 +262,9 @@ func compressVideo(srcPath, dstPath string) error {
|
||||
}
|
||||
log.Infof("video size: %dx%d", width, height)
|
||||
|
||||
cmd := exec.Command("ffmpeg", "-i", srcPath, "-c:v", "libx264", "-crf", "23", "-r", "25", "-c:a", "copy", dstPath)
|
||||
cmd := exec.Command("ffmpeg", "-i", srcPath, "-c:v", "libx264", "-crf", "23", "-r", "25", "-c:a", "copy", fmt.Sprintf("%q", dstPath))
|
||||
if width > 1920 || height > 1080 {
|
||||
cmd = exec.Command("ffmpeg", "-i", srcPath, "-c:v", "libx264", "-crf", "23", "-r", "25", "-c:a", "copy", "-vf", "scale=1920:1080", dstPath)
|
||||
cmd = exec.Command("ffmpeg", "-i", fmt.Sprintf("%q", srcPath), "-c:v", "libx264", "-crf", "23", "-r", "25", "-c:a", "copy", "-vf", "scale=1920:1080", fmt.Sprintf("%q", dstPath))
|
||||
}
|
||||
log.Infof("executing command: %s", cmd.String())
|
||||
|
||||
@@ -276,7 +276,7 @@ func compressVideo(srcPath, dstPath string) error {
|
||||
}
|
||||
|
||||
func getVideoSize(filePath string) (int, int, error) {
|
||||
cmd := exec.Command("ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=height,width", "-of", "default=noprint_wrappers=1:nokey=1", filePath)
|
||||
cmd := exec.Command("ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=height,width", "-of", "default=noprint_wrappers=1:nokey=1", fmt.Sprintf("%q", filePath))
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return 0, 0, errors.Wrapf(err, "failed to execute command: %s", cmd.String())
|
||||
|
||||
Reference in New Issue
Block a user