mirror of
https://github.com/xfrr/goffmpeg.git
synced 2025-10-16 04:50:45 +08:00
Get the ffmpeg command regardless of the platform
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
"strconv"
|
||||
"goffmpeg/models"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func DurToSec(dur string) (sec float64) {
|
||||
@@ -21,6 +22,70 @@ func DurToSec(dur string) (sec float64) {
|
||||
return secs
|
||||
}
|
||||
|
||||
func GetExec() string {
|
||||
var platform = runtime.GOOS
|
||||
var command = ""
|
||||
|
||||
switch platform {
|
||||
case "windows":
|
||||
command = "cmd"
|
||||
break
|
||||
default:
|
||||
command = "/bin/sh"
|
||||
break
|
||||
}
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func GetExecArgs() string {
|
||||
var platform = runtime.GOOS
|
||||
var args = ""
|
||||
|
||||
switch platform {
|
||||
case "windows":
|
||||
args = "/C"
|
||||
break
|
||||
default:
|
||||
args = "-c"
|
||||
break
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
func GetFFmpegExec() string {
|
||||
var platform = runtime.GOOS
|
||||
var command = ""
|
||||
|
||||
switch platform {
|
||||
case "windows":
|
||||
command = "where ffmpeg"
|
||||
break
|
||||
default:
|
||||
command = "which ffmpeg"
|
||||
break
|
||||
}
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func GetFFprobeExec() string {
|
||||
var platform = runtime.GOOS
|
||||
var command = ""
|
||||
|
||||
switch platform {
|
||||
case "windows":
|
||||
command = "where ffprobe"
|
||||
break
|
||||
default:
|
||||
command = "which ffprobe"
|
||||
break
|
||||
}
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func CheckFileType(streams []models.Streams) string {
|
||||
for i := 0; i < len(streams); i++ {
|
||||
st := streams[i]
|
||||
|
Reference in New Issue
Block a user