Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Pipe downloading video to opencv #11291
Comments
|
Like this:
|
|
Thanks for your reply yan12125, but you didnt answer my question. Perhaps I need to be more explicit... Let's say I have a Youtube URL and I'm interested in analyzing the video without saving it to disk. Further, I am interested in doing this analysis using opencv in Python. In my Python script, I would write:
Does this make more sense? |
|
The info_dict = Y.extract_info(url, download=False)
video_stream = urllib.request.urlopen(info_dict['url'])
# video_stream is a file-like object with read() method |
|
Thanks for your response. I am able to get a stream as you have indicated, but I dont understand what to do with it. How do I decode the stream into a useable format? Others suggest that for live streams you can use opencv's cv2.imdecode and numpy's numpy.fromstring, but I am only getting nonsense from this. Is there further I can do using youtube_dl or do I need to start looking elsewhere after I get the url? |
|
YouTube videos are served as mp4 or webm files. Those files are usually compressed, so you need to decompress them first to get frame-by-frame images. |
|
Thanks for your help. I'm at a loss for now and can live with downloading the video. |
Please follow the guide below
xinto all the boxes [ ] relevant to your issue (like that [x])Make sure you are using the latest version: run
youtube-dl --versionand ensure your version is 2016.11.22. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.Before submitting an issue make sure you have:
What is the purpose of your issue?
The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue
Description of your issue, suggested solution and other information
I am writing a program to analyze the contents of a Youtube video using opencv. Ideally, I would like to be able to analyze the video while it is downloading (i.e. as if it were streaming on Youtube), and then throw away frames that have already been analyzed without ever writing to disk. Is it possible for me to pipe youtube_dl's download directly to another process rather than to disk, or some other workaround that would achieve my aims?