Browse Source

add ffmpeg.Check()

master v0.0.17
realxlfd 3 months ago
parent
commit
621f0a98fe
  1. 32
      cliapps/ffmpeg/checker.go

32
cliapps/ffmpeg/checker.go

@ -0,0 +1,32 @@
package ffmpeg
import (
"errors"
"os"
"os/exec"
"path/filepath"
)
func Check(file string) error {
stat, err := os.Stat(file)
if err != nil || stat.IsDir() {
return errors.New("file not found")
}
appPath := filepath.Join(
ffmpegPath,
`ffmpeg`,
)
// ffmpeg -v error -i your_video_file.mp4 -f null -
cmd := exec.Command(
appPath,
`-v`,
`error`,
`-i`,
file,
`-f`,
`null`,
`-`,
)
err = cmd.Run()
return err
}
Loading…
Cancel
Save