GithubHelp home page GithubHelp logo

bililiverecorder / bililiverecorder Goto Github PK

View Code? Open in Web Editor NEW
3.5K 36.0 289.0 3.66 MB

录播姬 | mikufans 生放送录制

Home Page: https://rec.danmuji.org

License: GNU General Public License v3.0

C# 95.50% Dockerfile 0.04% TypeScript 2.58% HTML 1.72% PowerShell 0.03% Shell 0.03% JavaScript 0.11%
bilibili bilibili-live stream flv dotnet-core wpf

bililiverecorder's Introduction

mikufans录播姬

Build and Test Version License Crowdin

简体中文 README | Simplified Chinese

GitHub is a global platform, and theoretically, everyone should use English. But since this project is mostly meant for Chinese user and rely on a Chinese website BiliBili (wikipedia), most things related to this project like code comments, documentations and other related repositories are written in Chinese. This README file will always use English so people like you can understand what is this, and perhaps make some use out of it.

Software UI is available in

  • 简体中文 (Source and default)
  • 繁体中文
  • 日本語
  • English

Installation

See rec.danmuji.org (in Chinese) for Windows installer with auto update.

Alernatively, you can download from releases page.
The zip file available at the releases page does not have auto update enabled. You are welcome to watch this repository for new releases. (Click the "Watch" dropdown menu, then "Custom", and check the "Releases" checkbox).

Binary files of the command line version are available for Linux, macOS, and Windows at releases.

Docker images can be pulled from Docker Hub bililive/recorder or ghcr.io/bililiverecorder/bililiverecorder.

See rec.danmuji.org/user/install for step by step installation guides (in Chinese).

Feature

  • Easy to use
  • Start recording automatically when stream starts
  • Record multiple stream at same time
  • Fix broken recording caused by broken bilibili stream server
  • Toolbox mode to fix broken bilibili stream recording recorded by other software1
  • Pure C#, no native dependency like ffmpeg2
  • Open source!

1: Only unprocessed flv file downloaded directly from stream servers can be fixed. If the file is downloaded or processed by FFmpeg it no longer can be fixed, FFmpeg will fvck up the already broken recording even further.
2: A minimal version of FFmpeg is bundled with the desktop edition of BililiveRecorder for the remux feature in toolbox.

Versioning

This project is following Semantic Versioning since version 2.0.0.

Please note this does not include the public .NET API of BililiveRecorder.Flv, or any project within this repository for that matter. They are considered as internal implementation thus could have breaking changes in any releases.

Building from source

Note: full git history is required for version generation to work.

WPF version:

cd BililiveRecorder.WPF
msbuild -t:restore
msbuild

Command line version:

# Build WebUI, optional
git submodule update --init --recursive
./webui/build.sh
# For building on Windows:
# ./webui/build.ps1

dotnet build BililiveRecorder.Cli

Project structure

Project Target
BililiveRecorder.Flv .NET Standard 2.0
BililiveRecorder.Core .NET 6
.NET Framework 4.7.2
BililiveRecorder.Toolbox .NET Standard 2.0
BililiveRecorder.WPF .NET Framework 4.7.2
BililiveRecorder.Web .NET 6
BililiveRecorder.Cli .NET 6
graph BT
    toolbox(BililiveRecorder.Toolbox) --> flv(BililiveRecorder.Flv)
    core(BililiveRecorder.Core) --> flv
    wpf(BililiveRecorder.WPF) --> core
    wpf --> toolbox
    cli(BililiveRecorder.Cli) --> toolbox
    cli ---> core
    web(BililiveRecorder.Web) --> core
    cli --> web

Reference & Acknowledgements

bililiverecorder's People

Contributors

123485k avatar ayumi-otosaka-314 avatar bbaa-bbaa avatar chirsz-ever avatar cxumol avatar dependabot[bot] avatar geektheripper avatar genteure avatar github-actions[bot] avatar gongt avatar gy6221 avatar handgrip avatar hguandl avatar hmbsbige avatar kira1928 avatar kotomei avatar li494391537 avatar nyamisty avatar pwntester avatar shugen002 avatar stackinspector avatar tooyoungtoosimp avatar valkjsaaa avatar wpcwzy avatar zkonge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bililiverecorder's Issues

房间配置项被删除

之前添加过的录制房间,在重启录播姬后房间配置消失
第一张为重新启动后的录播姬,第二张为百度云盘上存储的备份文件,相当多的直播间都消失了
lbj

配置

针对腾讯云服务器的问题特殊处理

是长期坑,咕。

腾讯云服务器给的flv流经常出现各种时间戳错乱和各种奇奇怪怪的奇葩问题。
研究一下具体怎么处理,目标是录出来的文件可以直接上传B站主站和喂给ffmpeg处理不报错。

时间戳问题备选解决方案:

  • 检测到时间戳跳动时断开重连。缺点感觉会大概率丢失一段直播画面。
  • 检测到时间戳跳动后完全由录播姬根据之前的FPS生成时间戳。缺点感觉这样不是很可靠。

还需要研究的问题:好像遇到过腾讯云的服务器重复给了多次同一个GOP的问题,未确认。

弃用 ClickOnce 使用 Squirrel

Squirrel.Windows
可能使用 ClickOnceToSquirrelMigrator

暂定迁移过程:

  • 取消所有现有的发布脚本
  • 新建一个 ClickOnce 专用分支,添加迁移提醒等信息或自动迁移代码
  • 在主分支上继续开发
  • 编写新的发布脚本
  • 使用 Squirrel 发布新版本 1.1.0
  • 在 ClickOnce 侧手动发布新版本 1.0.13

其他:

  • 检查代码签名相关有没有改动的需要
  • 配置文件的加载保存和升级
  • 录制数据的保存位置和文件夹结构

针对bililive近期更新的“加密直播间"功能进行适配

问题复现直播间地址
https://live.bilibili.com/21449068
追加直播间
提示
WARN 21449068 不能获取 21449068 的信息: "该房间已经被锁定"

原因为正式直播之前直播主进行了调试,调用了最近添加的加密直播间的功能,使游客访问为该直播间已锁定,登录之后则反馈为需要输入密码进入,但问题在于就算该直播间取消加密之后进行追加也反馈着同样的内容(此时游客进行访问并不会出现该直播间已锁定的反馈)

网络出错时填充预生成的画面而不是结束录制

在发生主播直播断开、录制系统网络不稳定、录制连接断开等情况时,不结束录制,而是填充预生成的黑屏画面或写有一些文字的画面(如:黑色背景白色文字的“录制网络连接断开”),使得整个直播流能完整的串起来。
注:应当给出选项,能切换本功能的开关。

重做 Appveyor 相关逻辑

现在的 CI CD 很不合理,应该做一些修改优化。

分支

把 dev 分支重新设置为 GitHub 上的主分支
master 分支作为稳定分支,永远在某一个 tag 上
目前就我一个人开发,就直接在 dev 上提交代码了,将来如果有需要的话可以使用 Git Flow

发布版本

目前发布版本的方法是在 dev 分支上提交一个 tag
打算修改为:

  • Appveyor 编译除了 tag 和 master 分支 以外的所有提交
  • 如果在 dev 分支上,同时 commit message 第一行匹配正则表达式 ^Release: (\d+\.\d+\.\d+)$ 则为正式发布
  • Appveyor 编译
  • after_build
    • 如果是正式发布,清空发布文件夹,并 msbuild /t:Publish
  • Appveyor 运行测试
  • before_deploy
    • 如果是正式发布,对编译成品进行代码签名
    • 如果是正式发布,将发布文件夹内容提交到 git 仓库 soft.danmuji.org
    • 如果是正式发布,git push origin master && git tag
  • Appveyor 自动打包 Debug 版本

Refactor Recorder

  • Create IRecorder
  • Implement INotifyPropertyChanged, INotifyCollectionChanged, IEnumerable<IRecordedRoom>, ICollection<IRecordedRoom>

根据大小或者时间来自动分割视频录制

鉴于有些主播设置的码率很高,导致最后处理时会要先处理分割然后再上传回B站,会造成音画不同步的现象,如果一开始录制的时候能根据大小或者时间来开一个新的录制文件,那么在上传回b站的时候就会方便些。

P.S. 如果我有空的话我也想帮忙去改下code...然而我不知道怎么build 这个project...

无法录制付费直播

已登陆账号,已付费。
提示“尝试下载直播流时服务器返回了Not Found”

在程序遇到异常后,程序界面无法控制实际的录制过程

在当前版本(1.1.15)的使用过程中,多次遇到这样的情况:程序遇到异常后,界面的按钮操作不再起效。部分例子包括:

  • 在(自动录制的)直播间因网络问题等原因自动中断录制之后(日志显示类似“本地操作结束录制”的提示),点击“手动触发开始录制”无作用
  • 在程序初始化加载完多个直播间信息后,正在直播的自动录制的直播间在长时间后仍然为“闲置”状态,且点击“手动触发开始录制”无作用

程序启动时获取多个直播间信息的并行化

目前(所使用版本1.1.15)程序在启动时,若保存配置中包含多个直播间,则会逐个访问直播间信息,导致非常严重的延时。另一方面,多次出现(可能在网络不好的条件下)直播间信息获取过程卡在某个直播间上,进而导致整个启动过程无法继续进行,既无法完成所有直播间信息的获取,也不能开始监测已经获取信息的直播间,也不响应手动操作。
是否可以并行获取所有直播间的信息?

修改改进 Core.Recorder

  • 添加 IRecorder 接口
  • 使 Recorder 继承 ObservableCollectionCollection, INotifyCollectionChanged, INotifyPropertyChanged
  • 添加录播姬事件(开始停止录制、添加删除直播间等)

安装过程中的bug

点击安装文件安装时直接报错:
BililiveRecorder.WPF Setup
An error occurred attempting to install BililiveRecorder.WPF

点击details后进一步显示:
An error occurred trying to download 'https://soft.danmuji.org/BililiveRecorder/BililiveRecorder.WPF.application'.

See the setup log file located at 'C:\Users\ADMINI~1\AppData\Local\Temp\VSD5B1D.tmp\install.log' for more information.

测试平台win10,安装包为官网上下载的1.0.12.0

希望能尽快修正,谢谢

使用 ReadAsync 重写直播流下载

玄学 bug

{
    "time": "2018-10-30 19:37:26.7653",
    "level": "INFO",
    "roomid": "[REMOVED]",
    "message": "直播流下载连接出错。将在30秒后重试启动。",
    "exception": {
        "type": "System.IO.IOException",
        "message": "读取操作失败,请参见内部异常。",
        "tostring": "System.IO.IOException: 读取操作失败,请参见内部异常。 ---> System.Net.InternalException: 系统错误。
        在 System.Net.AsyncProtocolRequest.CompleteRequest(Int32 result)
        在 System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
        在 System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
        --- 内部异常堆栈跟踪的结尾 ---
        在 System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
        在 BililiveRecorder.Core.RecordedRoom.<>c__DisplayClass54_1.<_StartRecord>g__callback|0(IAsyncResult ar)"
    }
}

image

应用程序: BililiveRecorder.WPF.exe Framework 版本: v4.0.30319 说明: 由于未经处理的异常,进程终止。
异常信息: System.ObjectDisposedException
 在 System.Net.Sockets.Socket.EndReceive(System.IAsyncResult, System.Net.Sockets.SocketError ByRef)
 在 System.Net.Sockets.Socket.EndReceive(System.IAsyncResult)
 在 System.Net.Sockets.NetworkStream.EndRead(System.IAsyncResult)
异常信息: System.IO.IOException
 在 System.Net.Sockets.NetworkStream.EndRead(System.IAsyncResult)
 在 System.Net.FixedSizeReader.ReadCallback(System.IAsyncResult)
 在 System.Net.LazyAsyncResult.Complete(IntPtr)
 在 System.Net.ContextAwareResult.CompleteCallback(System.Object)
 在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
 在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
 在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
 在 System.Net.ContextAwareResult.Complete(IntPtr)
 在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
 在 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
 在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

Server Client Web 设计草稿

待完善

BililiveRecorder.Server

  • 使用 .NET Core 2.0 / C#
  • 使用 EmbedIO 作为 Web 服务器
  • 使用 WebSocket
  • 使用 GraphQL

要提供的接口

WebSocket

  • 推送录制状态更新

GraphQL Query

  • 录制设置
  • 服务器状态信息(软件版本、运行状态等)
  • 整体录制状态 & 单个直播间状态

GraphQL Mutation

  • 录制设置
  • 添加直播间
  • 开启关闭自动录制
  • 触发录制
  • 切断录制

BililiveRecorder.Client

  • 使用 TypeScript / Node / blessed

BililiveRecorder.Web

  • 使用 TypeScript / Vue

处理有问题的 onMetaData 信息

部分服务器返回的 FLV Script Tag 有问题

FLV 头

46 4C 56 01 05 00 00 00 09
00 00 00 00

Script Tag

12
00 0D # length: 13
00 00 00 00 # timestamp: 0
00 00 00 # stream id: 0

AMF

02 # AMF Object

00 #
0A # 000A = string size 10

6F # o
6E # n
4D # M
65 # e
74 # t
61 # a
44 # D
61 # a
74 # t
61 # a

上一个 Tag 长度: 24

00 00 00 18

关于付费直播

  • 刚刚测试了付费直播,填入 Cookie 依旧无法获取正确的直播地址

    调试了一下,我直接加在 DefaultRequestHeaders 里就录制成功了,只需要 SESSDATA ,且值不需要 Decode。

    参考代码(半成品)

  • 又测试了一下,把值替换成 access_token 居然也行...

    如果之后还需要接入登录的话也许可以参考这个

增加新剪辑模式

增加第二个模式。在点击剪辑按钮时延长当前正在处理的 Clip ,而不是创建一个新的。可设置使用哪个模式,以及将来潜在的针对某个 Clip 的控制功能(延长时间、立刻结束)

同时把 Clip 改成实时写入硬盘,而不是完成后一次性写入。防止文件过大,写入时 IO 拖后腿。

无法录制

[11:45:12] INFO 4719881 弹幕服务器连接成功
[11:45:32] WARN 4719881 启动直播流下载出错。 The operation has timed out

*手动也不可以开始录制
*发现多个房间都这样

代码缺少文件

从这里下载回来的代码没办法正常打开,提示少RecordStateConverter等一堆文件

本地边播边录

提供一个本地播放的接口,用 VLC 之类的播放器播放。

低优先级功能,有可能不做

关于HTTP代理

为何这种格式的127.0.0.1:1080不能用
设置代理时发生错误 提示无效的URI: URI方案无效
用的SSR代理
难道只能那种专门的HTTP代理才行么 难找啊

服务器版的网页前端

目前打算自己用 TypeScript + Vue 写,最终打包成一个单页应用,布局类似目前的 WPF 界面。
要是有前端大佬来帮忙就好了😔

服务器请求不到playurl

B站端封停服务器请求流地址 {"code":20001,"msg":"Forbidden access.","message":"Forbidden access."}
请及时处理……

录制完成 无视频 - 显示错误

[10:29:35] ERROR System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at BililiveRecorder.Core.Utils.ReadB(NetworkStream stream, Byte[] buffer, Int32 offset, Int32 count)
at BililiveRecorder.Core.DanmakuReceiver.ReceiveMessageLoop() Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

添加“深层”直播流修复和“优化”功能

修复

要解决的问题和 #56 本质上是同一个问题,现在哪个服务器都有可能出这问题,不止是腾讯云(但是我怀疑是因为其他服务器是从腾讯云服务器上拉来的已经有问题的流)

把现有的『时间戳修复工具』的逻辑完善修改,内置到录播姬内,实现边录边处理。

优化

其实就是删除所有 Filler NALU,可以减少一点保存下来的文件大小,对实际文件的播放无影响。


因为这些修复处理逻辑是根据已知的问题流来实现的,如果服务器给了没见过的流会有搞坏的可能性,所以需要做成一个 opt in 的功能。如果可能的话可以考虑在修改了的地方插入一些 Sei NALU 记录一下都做了什么修改,实现反向处理还原原文件。


怪话

@Afanyiyu 自告奋勇想 PR

image

检测到切换分辨率时自动分割新文件

有时直播到一半分辨率会变

  • PK
  • 苹果手机直播切换横竖屏
  • 主播直播到一半闲的没事瞎改编码器参数

正常情况下应该服务器会断一下然后重连,但是有的服务器会把前后两次不同分辨率的推流粘在一起不断开(某训咳咳)

支持录制 PK 直播画面

PK 时通过弹幕服务器接收 PK_ 开头的命令消息,重新调用接口获取新播放地址。
PK 开始后原本的推流不会断开。
PK 开始后,直播姬将直播数据流传给声网SDK,发送到声网合成,B站rtmp(?)服务器从声网获取流,通过普通的 http-flv 发送到播放端。

待决定:

  • PK 开始后,原下载工作需不需要断开,还是持续录制成一个完整的视频
  • 如果上一项不断开,PK结束时如何处理
  • 网络错误重连的处理

需要做的工作:

  • 整理/重构/封装 下载 Flv 数据喂给 FlvStreamProcessor 的过程
  • 整理出错重试的逻辑

重构设置系统,从全局设置改为每个直播间独立设置

从现在的整个工作目录一个共享的设置,改为每个直播间一个独立设置。

可以独立设置录制模式(普通录制、剪辑、将来的“填充录制”)、各种超时时间、(将来的)是否保存弹幕、(将来的)填充录制无数据填充颜色。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.