|
|
|
@ -60,10 +60,11 @@ func Cut(source string) {
|
|
|
|
|
//2、获取文件后缀
|
|
|
|
|
extension := path.Ext(source)
|
|
|
|
|
//3、输出的文件通配名称
|
|
|
|
|
targetPath := getPath(source,CutPath) + source[0:36] + `_%03d` + extension
|
|
|
|
|
targetPath := getPath(source, CutPath) + source[0:36] + `_%03d` + extension
|
|
|
|
|
//4、切片
|
|
|
|
|
cmdLine := ffmpeg + ` -fflags +genpts -i ` + sourcePath + ` -acodec copy -vcodec copy -f segment -segment_time 300 -reset_timestamps 1 -map 0:0 -map 0:1 ` + targetPath
|
|
|
|
|
ShellUtil.ExecCommand(cmdLine)
|
|
|
|
|
ShellUtil.Exec(ffmpeg, `-fflags`, `+genpts`, `-i`, sourcePath,
|
|
|
|
|
`-acodec`, `copy`, `-vcodec`, `copy`, `-f`, `segment`, `-segment_time`,
|
|
|
|
|
`300`, `-reset_timestamps`, `1`, `-map`, `0:0`, `-map`, `0:1`, targetPath)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -72,13 +73,13 @@ func Cut(source string) {
|
|
|
|
|
时间:2020-07-08
|
|
|
|
|
*/
|
|
|
|
|
func GetAllCutChild(source string) []string {
|
|
|
|
|
filepathNames, err := filepath.Glob(filepath.Join(getPath(source,CutPath), "*"))
|
|
|
|
|
filepathNames, err := filepath.Glob(filepath.Join(getPath(source, CutPath), "*"))
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
|
}
|
|
|
|
|
resultArray := make([]string, 0)
|
|
|
|
|
for i := range filepathNames {
|
|
|
|
|
resultArray = append(resultArray, filepathNames[i])
|
|
|
|
|
resultArray = append(resultArray, filepathNames[i])
|
|
|
|
|
}
|
|
|
|
|
return resultArray
|
|
|
|
|
}
|
|
|
|
@ -91,8 +92,8 @@ func GetAllCutChild(source string) []string {
|
|
|
|
|
func ConvertToH264Mp4(childMovie string) {
|
|
|
|
|
extension := path.Ext(childMovie)
|
|
|
|
|
childMovieMp4 := strings.Replace(filepath.Base(childMovie), extension, ".mp4", -1)
|
|
|
|
|
cmdLine := ffmpeg + ` -i ` + childMovie + ` -c:v libx264 -strict -2 ` + getPath(childMovie,Mp4Path)+childMovieMp4
|
|
|
|
|
ShellUtil.ExecCommand(cmdLine)
|
|
|
|
|
ShellUtil.Exec(ffmpeg, `-i`, childMovie, `-c:v`, `libx264`, `-strict`, `-2`,
|
|
|
|
|
getPath(childMovieMp4, Mp4Path)+childMovieMp4)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -128,8 +129,7 @@ func Merge(source string, indexName string) {
|
|
|
|
|
if !FileUtil.Exists(Target) {
|
|
|
|
|
os.Mkdir(Target, os.ModePerm)
|
|
|
|
|
}
|
|
|
|
|
cmdLine := ffmpeg + ` -f concat -i ` + indexName + ` -c copy ` + Target + "/" + source[0:36] + ".mp4"
|
|
|
|
|
ShellUtil.ExecCommand(cmdLine)
|
|
|
|
|
ShellUtil.Exec(ffmpeg, `-f`, `concat`, `-i`, indexName, `-c`, `copy`, Target+"/"+source[0:36]+".mp4")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|