]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Add 可自定义录播回放网速
authorqydysky <32743305+qydysky@users.noreply.github.com>
Mon, 30 Jan 2023 11:54:25 +0000 (19:54 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Mon, 30 Jan 2023 11:54:25 +0000 (19:54 +0800)
Reply/F.go
demo/config/config_K_v.json
demo/go.mod
demo/go.sum
go.mod
go.sum

index 81523c176a69a570d70a0c8dfeaf575228ab6f9f..7408a2af86614aa23093259ff410a9f6d5d7e5d9 100644 (file)
@@ -19,6 +19,7 @@ import (
 
        // "runtime"
 
+       humanize "github.com/dustin/go-humanize"
        "golang.org/x/text/encoding/simplifiedchinese"
 
        c "github.com/qydysky/bili_danmu/CV"
@@ -1191,7 +1192,17 @@ func init() {
                                                f := file.New(v, int64(rangeHeaderNum), false)
                                                defer f.Close()
 
-                                               if e := f.CopyToIoWriter(w, 1000000, true); e != nil {
+                                               // 直播流回放速率
+                                               var speed, _ = humanize.ParseBytes("1 M")
+                                               if rc, ok := c.C.K_v.LoadV(`直播流回放速率`).(string); ok {
+                                                       if s, e := humanize.ParseBytes(rc); e != nil {
+                                                               flog.L(`W: `, `直播流回放速率不合法:`, e)
+                                                       } else {
+                                                               speed = s
+                                                       }
+                                               }
+
+                                               if e := f.CopyToIoWriter(w, int64(speed), true); e != nil {
                                                        flog.L(`E: `, e)
                                                }
                                        } else {
index 50eda5766c8dc1520e5b13bf38248035a597622e..73cbba87b0fca565eab635b1671ac4632917eca4 100644 (file)
@@ -69,6 +69,8 @@
     "直播Web可以发送弹幕":true,
     "弹幕回放-help": "仅保存当前直播间流为true时才有效",
     "弹幕回放": true,
+    "直播流回放速率-help": "速率为每秒速率 例最小值(1 MB)",
+    "直播流回放速率": "1 MB",
     "ass-help": "只有保存直播流时才考虑生成ass,ass编码默认GB18030(可选utf-8)",
     "生成Ass弹幕": true,
     "Ass编码": "GB18030",
index 45dba613c5a96843f56765b9981f3e1c9fec5de7..f87b02f8a8aca5d0a13d12274f69274c6936c913 100644 (file)
@@ -7,6 +7,7 @@ require github.com/qydysky/bili_danmu v0.5.9
 require (
        github.com/andybalholm/brotli v1.0.4 // indirect
        github.com/christopher-dG/go-obs-websocket v0.0.0-20200720193653-c4fed10356a5 // indirect
+       github.com/dustin/go-humanize v1.0.1 // indirect
        github.com/go-ole/go-ole v1.2.6 // indirect
        github.com/gofrs/uuid v4.3.0+incompatible // indirect
        github.com/gorilla/websocket v1.5.0 // indirect
index 85b1c2ad0887a5344bc5579657ac3bd3e308db69..8e748d8403c6f595a218a9f05702eb529f088295 100644 (file)
@@ -12,6 +12,8 @@ github.com/christopher-dG/go-obs-websocket v0.0.0-20200720193653-c4fed10356a5/go
 github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
+github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
 github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
 github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
 github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
diff --git a/go.mod b/go.mod
index f9018ea1bd4cdd5ca4dbbf7779bdd54e612e2c33..1467ce68b11341b38a12cb17869edb49cb230c1c 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -16,6 +16,7 @@ require (
 require (
        github.com/andybalholm/brotli v1.0.4 // indirect
        github.com/davecgh/go-spew v1.1.1 // indirect
+       github.com/dustin/go-humanize v1.0.1
        github.com/go-ole/go-ole v1.2.6 // indirect
        github.com/gorilla/websocket v1.5.0 // indirect
        github.com/klauspost/compress v1.15.11 // indirect
diff --git a/go.sum b/go.sum
index f1bd25b35d9cd756120c225e60917e766e05f663..9dc4b241cc0dff5f2c1cd2a91d42ce2783efe25f 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -6,6 +6,8 @@ github.com/christopher-dG/go-obs-websocket v0.0.0-20200720193653-c4fed10356a5/go
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
+github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
 github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
 github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
 github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=