Trying to stream telegram media and playing it in a web page

安稳与你 提交于 2020-12-05 11:52:07

问题


I am trying to stream Telegram video files and play them on a web page.

I am using this script to stream Telegram videos to a web server. It uses Telethon and AIOhttp to stream the file. The streaming part can be seen here.

I am currently serving it on a server to serve media files. The videos can be downloaded using the link the script provides and can be streamed on any media player. But when I try to stream them on a web page, it has problems.

For mp4 videos, Chrome does not play them while Firefox does. Example

This is the DEBUG log of the script when I opened the above script in 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

For mkv videos, none of them plays it. Firefox shows the error matroska files can't be played For one or two mp4 videos, I got Chrome to play them as well. Example

I am using here Fluidplayer which uses dash.js which might be incompatible with mp4 files. I have tried to play the video with barebones HTML using the video tag but that didn't work as well.

For the web page part, I have added a route in the web_routes file that contains all AIOhttp server routes.

What can I do to play the videos on a web page? (I have also tried using Flask to add routes. So, the server on one side and a playing website in another place).

来源:https://stackoverflow.com/questions/59895767/trying-to-stream-telegram-media-and-playing-it-in-a-web-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!