0

I make vehicle detection program with OpenCV in C#. This program works well with already downloaded videos, but i want to use live streams from youtube. If I use

VideoCapture capture = new VideoCapture("https://www.youtube.com/v/qHqIjDoMYAk")

I get only a preview of the video.

slavoo
  • 5,798
  • 64
  • 37
  • 39
imaxons
  • 3
  • 1
  • 2
  • You can try YouTube-dl and then processing the downloaded file https://stackoverflow.com/questions/37040798/how-do-you-use-youtube-dl-to-download-live-streams-that-are-live – Devstr Feb 20 '18 at 07:57

1 Answers1

3

You need to use the stream URL for Initializing the VideoCapture, not the webpage URL

when initializing with the m3u8 this works.

How to do this is already described on this question: How can I get the actual video URL of a YouTube live stream?

It is the same method posted by Devstr in the comment, only an other post.

Gwen Royakkers
  • 431
  • 2
  • 11
  • Thanks! You really helped me. – imaxons Feb 20 '18 at 09:11
  • Hi @imaxons , I am trying something similar to grab frames from YouTube live stream. I got the actual URL as @Gwen suggested and using OpenCVFrameGrabber("") which internally uses VideoCapture class . Got error `Caused by: org.bytedeco.javacv.FrameGrabber$Exception: read() Error: Could not read frame in start().` Could you share sample code . Also I didn't get this part from the answer `when initializing with the m3u8 this works.` – Pintu May 31 '20 at 12:02