|
|
|
@ -26,6 +26,7 @@ func init() {
|
|
|
|
|
const WorkingPath = "/"
|
|
|
|
|
const WorkingCutPath = "/Cut/"
|
|
|
|
|
const WorkingMp4Path = "/Mp4/"
|
|
|
|
|
const WorkingKeyFramePath="/KeyFrame/"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:获取指定源文件的不同工作目录
|
|
|
|
@ -64,6 +65,7 @@ func InitDir(source string) {
|
|
|
|
|
//2、创建新目录
|
|
|
|
|
os.MkdirAll(getWorkingPath(source, WorkingCutPath), os.ModePerm)
|
|
|
|
|
os.Mkdir(getWorkingPath(source, WorkingMp4Path), os.ModePerm)
|
|
|
|
|
os.Mkdir(getWorkingPath(source,WorkingKeyFramePath),os.ModePerm)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -73,7 +75,7 @@ func InitDir(source string) {
|
|
|
|
|
*/
|
|
|
|
|
func Cut(source string) {
|
|
|
|
|
//1、源视频文件
|
|
|
|
|
sourcePath := getSourcePath(source) + source
|
|
|
|
|
sourcePath := getWorkingPath(source,WorkingKeyFramePath) + source
|
|
|
|
|
//2、获取文件后缀
|
|
|
|
|
extension := path.Ext(source)
|
|
|
|
|
//3、输出的文件通配名称
|
|
|
|
@ -186,3 +188,16 @@ func ToM3u8(source string) {
|
|
|
|
|
//删除mp4
|
|
|
|
|
os.Remove(getTargetPath(source)+source[0:36]+".mp4")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:将文件转换为每帧都是关键帧
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-07-09
|
|
|
|
|
*/
|
|
|
|
|
func ConvertToKeyFrame(source string){
|
|
|
|
|
if FileUtil.Exists(getWorkingPath(source,WorkingKeyFramePath)+source){
|
|
|
|
|
os.Remove(getWorkingPath(source,WorkingKeyFramePath)+source)
|
|
|
|
|
}
|
|
|
|
|
CommonUtil.Exec(ffmpeg, getWorkingPath(source,WorkingKeyFramePath), `-i`,
|
|
|
|
|
getSourcePath(source)+source,`-strict`, `-2`, `-qscale`, `0`,`-intra`, getWorkingPath(source,WorkingKeyFramePath)+source)
|
|
|
|
|
}
|