Youtube live stream

asked 2018-05-22 07:48:25 -0600

I am having problem with handling live streams from youtube using CV2. Local media files and youtube videos work fine, but issue is only with live streams....I receive the stream frames for a few second, then hangs on network for a while and then recovers for a few seconds and then hang again. The same issue happens regardless of video quality(even with 144p)

cap = cv2.VideoCapture()
cap.open(stream_url)  # stream URL already extracted
ret, img = cap.read()

I already googled around, couldn't find any answers so far. Any hint?

edit retag flag offensive close merge delete

Comments

the "stream_url" you're using, probably does not really point to a video stream, but to something else (e.g. a javascript player)

berak gravatar imageberak ( 2018-05-22 08:03:03 -0600 )edit

I double checked that with

youtube-dl -f <format> -g <url>

the live video does play, but with breaks....hangs in cap.read() and returns after a while....looks like somekind of buffering issue.

cholan2100 gravatar imagecholan2100 ( 2018-05-22 08:08:13 -0600 )edit

Looks like issue with youtube-dl stream buffering issue in the background....having compiled OpenCV manually its showing some warnings of

tls connection was non properly terminated
cholan2100 gravatar imagecholan2100 ( 2018-05-22 11:22:14 -0600 )edit