尝试流式传输电报媒体并在网页中播放

2024-10-02 12:32:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试流式传输电报视频文件,并在网页上播放它们

我正在使用this脚本将电报视频流到web服务器。它使用TelethonAIOhttp对文件进行流式处理。可以看到流部分here

我目前正在一台服务器上为其提供媒体文件服务。视频可以使用脚本提供的链接下载,也可以在任何媒体播放器上播放。但是当我尝试在网页上流式传输它们时,它有问题

对于mp4视频,Chrome不会播放,而Firefox会播放ExampleWhen playing the video in Chrome(the extensions are not causing any issue, disabled on this page)

这是我在Chrome中打开上述脚本时脚本的调试日志

INFO:tl.web_routes:Serving file in 723 (chat 550559022) to ::1
DEBUG:tl.paralleltransfer:Starting parallel download: chunks 0-663 of 663 InputDocumentFileLocation(id=4981324115240550559, access_hash=7389576518823114674, file_reference=b'\x01\x00\x00\x02\xd3^*\xe3\xe5\xca;oLS\xe7k\xe1i\xae\xf0\xaf#Z_\xd5', thumb_size='')
INFO:tl.paralleltransfer.dc1.conn1:Connecting...
INFO:telethon.network.mtprotosender:Connecting to 149.154.175.51:443/TcpFull...
INFO:telethon.network.mtprotosender:Connection to 149.154.175.51:443/TcpFull complete!
INFO:tl.paralleltransfer.dc1:Exporting auth to DC 1 (main client is in 5)
INFO:aiohttp.access:::1 [24/Jan/2020:12:32:40 +0000] "GET /favicon.ico HTTP/1.1" 404 172 "http://localhost:8080/watch/12423247656120/Little.America.S01E03.WEB-DL.x264-ION10.mp4" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
DEBUG:tl.paralleltransfer.dc1.conn1:Part 0/663 (total 663) downloaded
DEBUG:tl.paralleltransfer.dc1.conn1:Parallel download interrupted
INFO:tl.web_routes:Serving file in 723 (chat 550559022) to ::1
DEBUG:tl.paralleltransfer:Starting parallel download: chunks 659-663 of 663 InputDocumentFileLocation(id=4981324115240550559, access_hash=7389576518823114674, file_reference=b'\x01\x00\x00\x02\xd3^*\xe3\xec\xbb\xd2vinG\xa3Q\xb1\xf4\x033;\xa0$?', thumb_size='')
DEBUG:tl.paralleltransfer.dc1.conn1:Parallel download interrupted

对于mkv视频,没有人播放它。Firefox显示错误matroska files can't be played 对于一两个mp4视频,我也用Chrome来播放Example

我在这里使用的Fluidplayer使用的dash.js可能与mp4文件不兼容。我曾经尝试过使用video标记用裸体HTML播放视频,但效果并不理想

对于web页面部分,我在web_routes文件中添加了一个包含所有AIOhttp服务器路由的路由

如何在网页上播放视频?(我还尝试使用Flask添加路由。因此,服务器在一侧,播放网站在另一侧)


Tags: todebuginfo服务器脚本web视频download

热门问题