26 lines
1.7 KiB
Python
Executable file
26 lines
1.7 KiB
Python
Executable file
from flask import Flask, Response
|
|
import cv2
|
|
|
|
app = Flask(__name__)
|
|
|
|
stream_url = "https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1743083179/ei/SwLlZ_TyK86d4t4P4Nm5uAw/ip/116.72.228.68/id/t45_gP7I82I.13/itag/232/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/sgovp/gir%3Dyes%3Bitag%3D136/rqh/1/hls_chunk_host/rr4---sn-i5uif5t-cvhz.googlevideo.com/xpc/EgVo2aDSNQ%3D%3D/playlist_duration/3600/manifest_duration/3600/bui/AccgBcMZtqTEgW5Kja9LOqfnyDmWuS4py5YycnMr4RyuxGQaLdQWSKKJgKCgjMGkGMOE9pDHidC_GuxS/spc/_S3wKsm-245alH4iN-U1nMxYuLh8G7uDozzsjDhEgZcFUzBEJR3XUYKe/vprv/1/playlist_type/DVR/initcwndbps/2192500/met/1743061580,/mh/A5/mm/44/mn/sn-i5uif5t-cvhz/ms/lva/mv/m/mvi/4/pl/22/rms/lva,lva/dover/13/pacing/0/short_key/1/keepalive/yes/mt/1743061238/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,sgovp,rqh,xpc,playlist_duration,manifest_duration,bui,spc,vprv,playlist_type/sig/AJfQdSswRAIgYWVOhqdR5svCACAWL9r-cucD1ZO6Y3aWQaVMvhSYWVMCIBdiYRz1hjLRLSsctXu5vExw5Ycgf1qjULsiHJaPhqx_/lsparams/hls_chunk_host,initcwndbps,met,mh,mm,mn,ms,mv,mvi,pl,rms/lsig/AFVRHeAwRAIgTCGRG9x25ozegw4guNRfaeJplSZZ-37bZtg5pRrmfWgCIAS8J-bVcZ1uSiG_MTgS4XfLX209irAzyyAekBo_D_mK/playlist/index.m3u8"
|
|
|
|
cap = cv2.VideoCapture(stream_url, cv2.CAP_FFMPEG)
|
|
|
|
def generate():
|
|
while True:
|
|
ret, frame = cap.read()
|
|
if not ret:
|
|
print("❌ No frame received!")
|
|
break
|
|
_, buffer = cv2.imencode('.jpg', frame)
|
|
yield (b'--frame\r\n'
|
|
b'Content-Type: image/jpeg\r\n\r\n' + buffer.tobytes() + b'\r\n')
|
|
|
|
@app.route('/video')
|
|
def video_feed():
|
|
return Response(generate(), mimetype='multipart/x-mixed-replace; boundary=frame')
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0', port=5000, debug=True)
|
|
|