From 082686d391929177a8a8b6893c18fa6e21cdf1a9 Mon Sep 17 00:00:00 2001 From: huanghai <10402852@qq.com> Date: Thu, 9 Jul 2020 09:59:17 +0800 Subject: [PATCH] 'commit' --- dsSupport/ConvertMovie/Convert.go | 8 ++++---- dsSupport/Utils/ConvertUtil/ConvertUtil.go | 23 +++++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dsSupport/ConvertMovie/Convert.go b/dsSupport/ConvertMovie/Convert.go index 4ded05da..b8ca5a15 100644 --- a/dsSupport/ConvertMovie/Convert.go +++ b/dsSupport/ConvertMovie/Convert.go @@ -2,7 +2,6 @@ package main import ( "dsSupport/Utils/ConvertUtil" - "fmt" ) func main() { @@ -17,13 +16,14 @@ func main() { for i := range childMovie { ConvertUtil.ConvertToH264Mp4(childMovie[i]) } - ////3、生成拼接的索引文件 - indexName := ConvertUtil.GenerateIndexTxt(source, childMovie) - fmt.Println(indexName) + //3、生成拼接的索引文件 + ConvertUtil.GenerateIndexTxt(source, childMovie) //4、合成MP4 ConvertUtil.Merge(source) //5、清除垃圾 ConvertUtil.ClearRubbish(source) //6、查看转换结果 ConvertUtil.ShowMovieInfo(source) + //7、转码为M3U8 + ConvertUtil.ToM3u8(source) } diff --git a/dsSupport/Utils/ConvertUtil/ConvertUtil.go b/dsSupport/Utils/ConvertUtil/ConvertUtil.go index 7ce7cc25..5002205e 100644 --- a/dsSupport/Utils/ConvertUtil/ConvertUtil.go +++ b/dsSupport/Utils/ConvertUtil/ConvertUtil.go @@ -132,7 +132,7 @@ func Merge(source string) { os.Remove(Target + "/" + source[0:36] + ".mp4") } //合并 - CommonUtil.Exec(ffmpeg,getPath(source,Mp4Path) ,`-f`, `concat`, `-i`, source[0:36] + ".txt", `-c`, `copy`, Target+"/"+source[0:36]+".mp4") + CommonUtil.Exec(ffmpeg, getPath(source, Mp4Path), `-f`, `concat`, `-i`, source[0:36]+".txt", `-c`, `copy`, Target+"/"+source[0:36]+".mp4") } /** @@ -152,7 +152,20 @@ func ClearRubbish(source string) { 功能:显示视频的信息 作者:黄海 时间:2020-07-09 - */ -func ShowMovieInfo(source string){ - CommonUtil.Exec(ffmpeg,runDir + `/Target/` + source[0:2]+"/"+source[0:36]+"/" ,`-i`, runDir + `/Target/` + source[0:2]+"/"+source[0:36]+"/"+source[0:36]+".mp4") -} \ No newline at end of file +*/ +func ShowMovieInfo(source string) { + CommonUtil.Exec(ffmpeg, runDir+`/Target/`+source[0:2]+"/"+source[0:36]+"/", `-i`, runDir+`/Target/`+source[0:2]+"/"+source[0:36]+"/"+source[0:36]+".mp4") +} + +/** +功能:将转码H264完成的MP4,切成M3U8形式 +作者:黄海 +时间:2020-07-09 +*/ +func ToM3u8(source string) { + CommonUtil.Exec(ffmpeg, runDir+`/Target/`+source[0:2]+"/"+source[0:36]+"/", `-i`, + runDir+`/Target/`+source[0:2]+"/"+source[0:36]+"/"+source[0:36]+".mp4", + `-f`,`segment`, `-segment_time`, `60`, `-segment_format`, `mpegts`, `-segment_list`, + runDir+`/Target/`+source[0:2]+"/"+source[0:36]+"/"+source+`.m3u8`, `-c`, `copy`, `-bsf:v`, `h264_mp4toannexb`, + `-map`, `0`, runDir+`/Target/`+source[0:2]+"/"+source[0:36]+"/"+source[0:36]+`_%04d.ts`) +}