xfangfang / Macast

Macast is a cross-platform application which using mpv as DLNA Media Renderer.
https://xfangfang.github.io/Macast/
GNU General Public License v3.0
6.12k stars 382 forks source link

[NEW FEATURE] 支持 B 站/爱奇艺 等应用的弹幕投屏 #30

Closed sooxin closed 2 years ago

sooxin commented 3 years ago

New feature

B 站和爱奇艺的应用可以将弹幕投屏,如果可以的话,也希望 Macast 支持这一功能。

xfangfang commented 3 years ago

有没有懂法律的朋友科普一下法律风险?

ZanyRain commented 3 years ago

其实我更好奇弹幕渲染怎么做

xfangfang commented 3 years ago

https://github.com/m13253/danmaku2ass 应该可以参考这个项目

shugen002 commented 3 years ago

提供一份从小电视发出来SSDP及一份description.xml *号替代等长度的十六进制大写

NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
Location: http://172.25.53.75:9958/bilibili/description.xml
Cache-Control: max-age=30
Server: Linux/3.0.0, UPnP/1.0, Platinum/1.0.5.13
NTS: ssdp:alive
USN: uuid:XY29518260702D28298A945E6************::upnp:rootdevice
NT: upnp:rootdevice

NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
Location: http://172.25.53.75:9958/bilibili/description.xml
Cache-Control: max-age=30
Server: Linux/3.0.0, UPnP/1.0, Platinum/1.0.5.13
NTS: ssdp:alive
USN: uuid:XY29518260702D28298A945E6************
NT: uuid:XY29518260702D28298A945E6************

NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
Location: http://172.25.53.75:9958/bilibili/description.xml
Cache-Control: max-age=30
Server: Linux/3.0.0, UPnP/1.0, Platinum/1.0.5.13
NTS: ssdp:alive
USN: uuid:XY29518260702D28298A945E6************::urn:schemas-upnp-org:device:MediaRenderer:1
NT: urn:schemas-upnp-org:device:MediaRenderer:1

NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
Location: http://172.25.53.75:9958/bilibili/description.xml
Cache-Control: max-age=30
Server: Linux/3.0.0, UPnP/1.0, Platinum/1.0.5.13
NTS: ssdp:alive
USN: uuid:XY29518260702D28298A945E6************::urn:schemas-upnp-org:service:AVTransport:1
NT: urn:schemas-upnp-org:service:AVTransport:1

NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
Location: http://172.25.53.75:9958/bilibili/description.xml
Cache-Control: max-age=30
Server: Linux/3.0.0, UPnP/1.0, Platinum/1.0.5.13
NTS: ssdp:alive
USN: uuid:XY29518260702D28298A945E6************::urn:schemas-upnp-org:service:RenderingControl:1
NT: urn:schemas-upnp-org:service:RenderingControl:1

NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
Location: http://172.25.53.75:9958/bilibili/description.xml
Cache-Control: max-age=30
Server: Linux/3.0.0, UPnP/1.0, Platinum/1.0.5.13
NTS: ssdp:alive
USN: uuid:XY29518260702D28298A945E6************::urn:schemas-upnp-org:service:ConnectionManager:1
NT: urn:schemas-upnp-org:service:ConnectionManager:1

NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
Location: http://172.25.53.75:9958/bilibili/description.xml
Cache-Control: max-age=30
Server: Linux/3.0.0, UPnP/1.0, Platinum/1.0.5.13
NTS: ssdp:alive
USN: uuid:XY29518260702D28298A945E6************::urn:app-bilibili-com:service:NirvanaControl:3
NT: urn:app-bilibili-com:service:NirvanaControl:3
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:dlna="urn:schemas-dlna-org:device-1-0" configId="13300635">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
<friendlyName>我的小电视</friendlyName>
<manufacturer>Bilibili Inc.</manufacturer>
<manufacturerURL>https://bilibili.com/</manufacturerURL>
<modelDescription>云视听小电视</modelDescription>
<modelName>ASUS_I001DE</modelName>
<X_brandName>asus</X_brandName>
<hostVersion>25</hostVersion>
<modelNumber>1024</modelNumber>
<serialNumber>1024</serialNumber>
<ottVersion>104400</ottVersion>
<channelName>master</channelName>
<capability>0</capability>
<modelURL>https://app.bilibili.com/</modelURL>
<UDN>uuid:XY29518260702D28298A945E6************</UDN>
<dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
<dlna:X_DLNACAP xmlns:dlna="urn:schemas-dlna-org:device-1-0">playcontainer-1-0</dlna:X_DLNACAP>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
<serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
<SCPDURL>/bilibili/AVTransport/XY29518260702D28298A945E6************/scpd.xml</SCPDURL>
<controlURL>/bilibili/AVTransport/XY29518260702D28298A945E6************/control.xml</controlURL>
<eventSubURL>/bilibili/AVTransport/XY29518260702D28298A945E6************/event.xml</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
<serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
<SCPDURL>/bilibili/RenderingControl/XY29518260702D28298A945E6************/scpd.xml</SCPDURL>
<controlURL>/bilibili/RenderingControl/XY29518260702D28298A945E6************/control.xml</controlURL>
<eventSubURL>/bilibili/RenderingControl/XY29518260702D28298A945E6************/event.xml</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
<serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
<SCPDURL>/bilibili/ConnectionManager/XY29518260702D28298A945E6************/scpd.xml</SCPDURL>
<controlURL>/bilibili/ConnectionManager/XY29518260702D28298A945E6************/control.xml</controlURL>
<eventSubURL>/bilibili/ConnectionManager/XY29518260702D28298A945E6************/event.xml</eventSubURL>
</service>
<service>
<serviceType>urn:app-bilibili-com:service:NirvanaControl:3</serviceType>
<serviceId>urn:app-bilibili-com:serviceId:NirvanaControl</serviceId>
<SCPDURL>/bilibili/NirvanaControl/XY29518260702D28298A945E6************/scpd.xml</SCPDURL>
<controlURL>/bilibili/NirvanaControl/XY29518260702D28298A945E6************/control.xml</controlURL>
<eventSubURL>/bilibili/NirvanaControl/XY29518260702D28298A945E6************/event.xml</eventSubURL>
</service>
</serviceList>
</device>
</root>

因为用的是蓝叠hyper-v模拟器,不知道该怎么转bridge模式,希望有大佬指路。

shugen002 commented 3 years ago

破站新版客户端限制了1080p只能用小电视播放,希望尽快推进一下。 例如伪装成云试听小电视

xfangfang commented 3 years ago

@shugen002 推进这件事是要承担侵权风险的,在没有更好的办法前,应该不会盲目适配

shugen002 commented 3 years ago

@shugen002 推进这件事是要承担侵权风险的,在没有更好的办法前,应该不会盲目适配

忽然想到了个阴间的解决方案,伪装、尝试提取av号/直播间号、跳浏览器页面,或许用浏览器扩展的形式去做这个毕竟合适,这样的话应该没有多大的侵权风险吧。。。

shugen002 commented 3 years ago

那可能是这个 urn:app-bilibili-com:service:NirvanaControl:3 ?

xfangfang commented 3 years ago

那可能是这个 urn:app-bilibili-com:service:NirvanaControl:3 ?

感兴趣的话可以拉代码自己尝试一下,期待你的pr

shugen002 commented 3 years ago

是他,但是东西变了。

POST /AVTransport/action HTTP/1.1
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
User-Agent: Linux/3.0.0 UPnP/1.0 Platinum/1.0.5.13
Host: 192.168.0.188:1068
Content-Length: 1304
Content-Type: text/xml; charset="utf-8"

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI>bilibili://projection?_nva_ext_=</CurrentURI><CurrentURIMetaData>&lt;DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"&gt;&lt;item id="0" parentID="-1" restricted="1"&gt;&lt;dc:title&gt;有一个人前来买电视&lt;/dc:title&gt;&lt;upnp:longDescription&gt;osm5RAYuFy0cUSctINB1W9qVNuwZr16t09qJZPXlOZsDOJ_IyDX1x3dtxhXTd5_s9r0MwoaRobxu3Q4soQHaTCgJa3YkWiFd-TYnoqrIkdhSD04bRxhB2ynFEeofjDXvWlwRpJvXhH_CsXOCUTCFbRl0whn2dXUigv2oyCa8G434hHDJRe6yjHeidfEvj5_IByhWjW9US5LcU4TmHDbeBCzdwBpIDv0xQi5Ceuwqw3JA3npYDJzCFsAL77EWvXZ13Dz0zclbUwxBwXyaR2FzlHXoWfs3_EOR26KMyXMA5BM&lt;/upnp:longDescription&gt;&lt;res protocolInfo="http-get:*:video/x-flv:DLNA.ORG_OP=01;DLNA.ORG_CI=0"&gt;bilibili://projection?_nva_ext_=&lt;/res&gt;&lt;upnp:class&gt;object.item.videoItem&lt;/upnp:class&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>
shugen002 commented 3 years ago

去小电视那边搜了下这个longDescription似乎走了一圈native,这就没啥办法了。。。 挂一个 ‘help wanted’ 的tag吧

dacancc commented 2 years ago

破站新版客户端限制了1080p只能用小电视播放,希望尽快推进一下。 例如伪装成云试听小电视

不更新软件即可,play2.10.3不美滋滋,广告什么的都没得

xfangfang commented 2 years ago

最新的测试版支持了“协议插件“,允许基于这个特性开发适配不同协议。尝试了一下这个问题讨论的协议,目前大体功能正常,需要测试的朋友可以进群:983730955

xfangfang commented 2 years ago

@shugen002 @sooxin 如果没人理我我就关闭这个issue了?

zsbai commented 2 years ago

啊我来插一嘴emmmmm,弹幕现在好像帧率蛮低的,看起来弹幕一卡一卡的,各位有什么建议吗?

xfangfang commented 2 years ago

@zsbai 弹幕是转换成ass字幕在mpv上播放的,mpv可能是为了减轻系统负担,字幕的刷新频率是跟随视频帧数设定的,所以如果看低帧数的视频就会有点卡,或许可以通过修改mpv的配置文件实现自动插帧到60fps,那样或许能解决。


参考这个项目的设置:https://github.com/m13253/BiliDan/blob/b5181e979bc0a3f250adee7febf18cc3d1f461df/bilidan.py#L293

在mpv的配置文件中添加:vf=lavfi="fps=fps=60:round=down" 可以得到好一些的体验

zsbai commented 2 years ago

@zsbai 弹幕是转换成ass字幕在mpv上播放的,mpv可能是为了减轻系统负担,字幕的刷新频率是跟随视频帧数设定的,所以如果看低帧数的视频就会有点卡,或许可以通过修改mpv的配置文件实现自动插帧到60fps,那样或许能解决。

参考这个项目的设置:https://github.com/m13253/BiliDan/blob/b5181e979bc0a3f250adee7febf18cc3d1f461df/bilidan.py#L293

在mpv的配置文件中添加:vf=lavfi="fps=fps=60:round=down" 可以得到好一些的体验

奥,十分感谢!!

stonereese commented 1 year ago

Nirvana协议投屏B站失败, 以前可以, 协议失效了吗?