master
huanghai 5 years ago
parent 82348369f9
commit 862b6c4265

@ -5,25 +5,33 @@ import (
)
func main() {
//测试方法:
//(1)在 Firefox中添加m3u8播放组件
// https://jingyan.baidu.com/article/fdffd1f86f3e7ff3e98ca120.html
//源文件
source := "B7318F5D-46B8-4AA1-8811-1A9D65528E19.wmv"
//1、目录实始化
ConvertUtil.InitDir(source)
//2、对视频文件进行切片
//2、生成关键帧
ConvertUtil.ConvertToKeyFrame(source)
//3、对视频文件进行切片
ConvertUtil.Cut(source)
//3、切片完成后尝试进行转码
//4、切片完成后,尝试进行转码
var childMovie = ConvertUtil.GetAllCutChild(source)
for i := range childMovie {
ConvertUtil.ConvertToH264Mp4(childMovie[i])
}
//4、生成拼接的索引文件
//5、生成拼接的索引文件
ConvertUtil.GenerateIndexTxt(source, childMovie)
//5、合成MP4
//6、合成MP4
ConvertUtil.Merge(source)
//6、清除垃圾
//7、清除垃圾
ConvertUtil.ClearRubbish(source)
//7、查看转换结果
//8、查看转换结果
ConvertUtil.ShowMovieInfo(source)
//8、转码为M3U8
//9、转码为M3U8
ConvertUtil.ToM3u8(source)
}

@ -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)
}

@ -17,6 +17,7 @@ func main(){
//M3u8目录
// http://127.0.0.1:9000/M3u8/B7/B7318F5D-46B8-4AA1-8811-1A9D65528E19/B7318F5D-46B8-4AA1-8811-1A9D65528E19.m3u8
r.Static("/M3u8", "./Target")
// 指定地址和端口号
r.Run(":9000")
}

@ -0,0 +1 @@
./ffmpeg/ffmpeg.exe -i E:\Work\dsMin\dsSupport\Source\B7\B7318F5D-46B8-4AA1-8811-1A9D65528E19.wmv -strict -2 -qscale 0 -intra E:\Work\dsMin\dsSupport\Target\B7\B7318F5D-46B8-4AA1-8811-1A9D65528E19.wmv
Loading…
Cancel
Save