]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Improve 默认保存为mp4
authorqydysky <qydysky@foxmail.com>
Thu, 6 Apr 2023 14:05:54 +0000 (22:05 +0800)
committerqydysky <qydysky@foxmail.com>
Thu, 6 Apr 2023 14:05:54 +0000 (22:05 +0800)
README.md
Reply/stream.go
demo/config/config_K_v.json

index 85bea1eed2b984468ecf633a7b28b828d5389564..cb6dc40bc30a919e26a8e6a90eb0dd7fcd930119 100644 (file)
--- 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支持中文
 
index 88d7ef836c7fe84bbb98dcd0a00bf5b8e27b5f32..9f1e6a17da6b79786ab7f2d4a8f5ea6bd049e58a 100644 (file)
@@ -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
 }
 
index 5d4fd368bc1207d238e65c607e5348d8d8cd0475..20396d9c17ec3284264745774e9663e8c89c0ec0 100644 (file)
@@ -60,7 +60,6 @@
     "直播流保存天数": 4,
     "直播hls流故障转移-help":"true:hls服务器故障时,使用其他",
     "直播hls流故障转移": true,
-    "直播hls流保存为MP4": true,
     "仅保存当前直播间流-help": "启用此项,才会保存Ass",
     "仅保存当前直播间流": true,
     "修改标题时重新录制": true,