From b52fa6650d6d50f251e7cf120e9cee3b177b48d8 Mon Sep 17 00:00:00 2001 From: qydysky Date: Thu, 6 Apr 2023 22:05:54 +0800 Subject: [PATCH] =?utf8?q?Improve=20=E9=BB=98=E8=AE=A4=E4=BF=9D=E5=AD=98?= =?utf8?q?=E4=B8=BAmp4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- Reply/stream.go | 35 ++++------------------------------- demo/config/config_K_v.json | 1 - 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 85bea1e..cb6dc40 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ I: 2022/09/15 02:23:23 Msg [qydysky丶 : 赞] 当直播流类型为`fmp4`或`fmp4H`时,使用`ffmpeg -i 0.m3u8 -c copy 0.mp4`命令可以合并切片 -当`直播hls流保存为MP4`为`true`时,默认将下载的切片合并保存为mp4 +~~当`直播hls流保存为MP4`为`true`时,~~默认将下载的切片合并保存为mp4 ass编码GB18030支持中文 diff --git a/Reply/stream.go b/Reply/stream.go index 88d7ef8..9f1e6a1 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -65,7 +65,6 @@ type M4SStream_Config struct { save_path string //直播流保存目录 want_qn int //直播流清晰度 want_type string //直播流类型 - save_as_mp4 bool //直播hls流保存为MP4 banlance_host bool //直播hls流故障转移 } @@ -171,9 +170,6 @@ func (t *M4SStream) LoadConfig(common c.Common) (e error) { } else { return errors.New(`未配置直播流保存位置`) } - if v, ok := common.K_v.LoadV(`直播hls流保存为MP4`).(bool); ok { - t.config.save_as_mp4 = v - } if v, ok := common.K_v.LoadV(`直播hls流故障转移`).(bool); ok { t.config.banlance_host = v } @@ -202,11 +198,7 @@ func (t *M4SStream) fetchCheckStream() bool { // 保存流类型 if strings.Contains(t.common.Live[0].Url, `m3u8`) { - if t.config.save_as_mp4 { - t.stream_type = "mp4" - } else { - t.stream_type = "m3u8" - } + t.stream_type = "mp4" } else if strings.Contains(t.common.Live[0].Url, `flv`) { t.stream_type = "flv" } @@ -826,11 +818,8 @@ func (t *M4SStream) saveStreamM4s() (e error) { Max: 3, } - var out *file.File - if t.config.save_as_mp4 { - out = file.New(t.Current_save_path+`0.mp4`, 0, false) - defer out.Close() - } + var out = file.New(t.Current_save_path+`0.mp4`, 0, false) + defer out.Close() // var ( @@ -908,9 +897,6 @@ func (t *M4SStream) saveStreamM4s() (e error) { `Connection`: `close`, }, } - if !t.config.save_as_mp4 { - reqConfig.SaveToPath = path + link.Base - } // t.log.L(`T: `, `下载`, link.Base) // defer t.log.L(`T: `, `下载完成`, link.Base, link.status, link.err) @@ -1056,7 +1042,7 @@ func (t *M4SStream) saveStreamM4s() (e error) { } // 获取解析m3u8 - var m4s_links, m3u8_addon, err = t.fetchParseM3U8() + var m4s_links, _, err = t.fetchParseM3U8() if err != nil { t.log.L(`E: `, `获取解析m3u8发生错误`, err) // if len(download_seq) != 0 { @@ -1097,24 +1083,11 @@ func (t *M4SStream) saveStreamM4s() (e error) { // 添加新切片到下载队列 download_seq = append(download_seq, m4s_links...) - - if !t.config.save_as_mp4 { - // 添加m3u8字节 - file.New(t.Current_save_path+"0.m3u8.dtmp", -1, true).Write(m3u8_addon, true) - } } // 发送空字节会导致流服务终止 t.Stream_msg.PushLock_tag(`data`, []byte{}) - if !t.config.save_as_mp4 { - // 结束 - if p.Checkfile().IsExist(t.Current_save_path + "0.m3u8.dtmp") { - file.New(t.Current_save_path+"0.m3u8.dtmp", -1, true).Write([]byte("#EXT-X-ENDLIST"), true) - p.FileMove(t.Current_save_path+"0.m3u8.dtmp", t.Current_save_path+"0.m3u8") - } - } - return } diff --git a/demo/config/config_K_v.json b/demo/config/config_K_v.json index 5d4fd36..20396d9 100644 --- a/demo/config/config_K_v.json +++ b/demo/config/config_K_v.json @@ -60,7 +60,6 @@ "直播流保存天数": 4, "直播hls流故障转移-help":"true:hls服务器故障时,使用其他", "直播hls流故障转移": true, - "直播hls流保存为MP4": true, "仅保存当前直播间流-help": "启用此项,才会保存Ass", "仅保存当前直播间流": true, "修改标题时重新录制": true, -- 2.39.2