|
|
|
@ -13,8 +13,13 @@ import (
|
|
|
|
|
//运行的目录
|
|
|
|
|
var runDir string
|
|
|
|
|
|
|
|
|
|
// ffmpeg 的命令行位置
|
|
|
|
|
var ffmpeg string
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
runDir, _ = os.Getwd()
|
|
|
|
|
|
|
|
|
|
ffmpeg=runDir + `\ffmpeg\ffmpeg.exe`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -50,7 +55,7 @@ func Cut(source string) {
|
|
|
|
|
i++
|
|
|
|
|
}
|
|
|
|
|
//4、切片
|
|
|
|
|
cmdLine := runDir + `\ffmpeg\ffmpeg.exe -fflags +genpts -i ` + sourcePath + ` -acodec copy -vcodec copy -f segment -segment_time 300 -reset_timestamps 1 -map 0:0 -map 0:1 ` + targetPath
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -79,6 +84,48 @@ func ConvertToH264Mp4(childMovie string) {
|
|
|
|
|
if FileUtil.Exists(childMovieMp4) {
|
|
|
|
|
os.Remove(childMovieMp4)
|
|
|
|
|
}
|
|
|
|
|
cmdLine := runDir + `\ffmpeg\ffmpeg.exe -i ` + childMovie + ` -c:v libx264 -strict -2 ` + childMovieMp4
|
|
|
|
|
cmdLine := ffmpeg + ` -i ` + childMovie + ` -c:v libx264 -strict -2 ` + childMovieMp4
|
|
|
|
|
ShellUtil.ExecCommand(cmdLine)
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
功能:生成索引的文本文件
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-07-08
|
|
|
|
|
*/
|
|
|
|
|
func GenerateIndexTxt(source string,childMovie []string)string{
|
|
|
|
|
content:=make([]string,0)
|
|
|
|
|
for i := range childMovie {
|
|
|
|
|
extension := path.Ext(childMovie[i])
|
|
|
|
|
content= append(content, `file '`+strings.Replace(childMovie[i],extension,".mp4",-1)+`'`)
|
|
|
|
|
}
|
|
|
|
|
//文件位置
|
|
|
|
|
indexName:=runDir+`/Working/`+source[0:2]+"/"+source[0:36]+"/"+source[0:36]+".txt"
|
|
|
|
|
FileUtil.WriteLines(content,indexName)
|
|
|
|
|
return indexName
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
功能:合并视频
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-07-08
|
|
|
|
|
*/
|
|
|
|
|
func Merge(source string,indexName string){
|
|
|
|
|
Target := runDir + `/Target/` + source[0:2] + "/"
|
|
|
|
|
if !FileUtil.Exists(Target) {
|
|
|
|
|
os.Mkdir(Target, os.ModePerm)
|
|
|
|
|
}
|
|
|
|
|
Target = Target + source[0:36] + "/"
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:清除垃圾
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-07-08
|
|
|
|
|
*/
|
|
|
|
|
func ClearRubbish(source string){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|