So now let's take a look at capturing video using screenshots.
So what does that mean?
So sometimes if it's zoom in a bit, so sometimes if you have issues with accessing a video stream,
let's assume it's a YouTube or live Facebook video stream that you want to process for some reason or
Twitch stream.
Now there all functions like remote and a couple others that allow you to plug in the URL or code for
YouTube video and stream it using Python.
However, a lot of the video companies like YouTube and Twitch, they don't like libraries can do that,
so they occasionally try to block those things by putting up, making making slight changes in the algorithm
that breaks those code.
So one way to do it is you just bring up the stream on your video player, a web browser, and you use
something a method called capturing screenshots as capturing screenshots of your desktop and turning
it into a video.
So the previous company I was at, we actually used that to process Twitch streams.
It was quite an efficient way to do it.
However, we wouldn't be doing what into two or three different Twitch streams at one time.
This was a gambling EA Games gambling company, bingo that I was at, and we used the screenshot grabber.
We didn't use image grab.
We use another one.
But it was good because it was quite fast.
I actually experimented with many of them, so we actually have to install this here.
So I'm going to install that right now.
We don't have it in this environment that I'm using.
So I'm just going to pause the video and store these things here.
Now these are the install instructions for Mac and Linux.
You can.
This has to be done in terminal.
If you're using a Mac or Linux Windows, you can run the pipe command service, but exclamation pip,
install Polu and PIP installed by screenshot.
So I've installed these these function.
These are libraries here, and let's grab a screenshot.
So let's run this function here and it's what it does.
It grabs a screenshot of our current screen using image stock grab here.
Image grab function is loaded here, and it saves it as fullscreen or PNG.
So let's take a look and see if this works and you can see what.
Specifically, it grabs a screenshot of the screen you on just now.
So that's pretty cool.
So what about if you wanted to do it like in the video stream so we can do it this way?
What this does, it allows us to grab a specific region of the screen we're looking for.
So we draw a bounding box.
We're looking at a top left corner of the screen and we're going to displayed it as a video displaying
the FBS of that here, which is a useful tool to get to see the performance of it.
And you can see it's printing graphics here.
You can actually use the TV to DOT protects the displays as well, and you can see this is our window
here in top left window that we're looking at.
When I move my most of it, it should probably the most of the mouse doesn't is invisible, but let's
see this.
It should know it has a bit of a lag, so you can see that it works pretty cool.
And we do have the Bugs Bunny still playing in the back for the previous stream.
So just ignore that can be distracting.
Let's go back to this.
So yeah, you can see it has a couple of seconds too late, but that's OK.
So let's stop this now.
Let's zoom out and stop that code.
And what if you needed a fast frame rate grabber use and this?
This is not a library that's loaded here.
I'm not sure if I install this before this find.
Yep, I did.
And you can see immediately the frame rate is much, much faster.
You can see that it has no, almost no lag.
You can see where it was over it here.
It was creating multiple layers of it because it's capturing it for each other point.
So let's just move this box away.
And this one doesn't grab a mouse as well.
Doesn't grab this things.
Maybe it's not in the region, actually, it's looking at, Oh yeah, it's in this region here.
It's looking at so we can move this window over it and you can see there's minimal lag here.
So if you needed to get a live video stream in here, this is one way to do it.
This is one where you can put a video player right here and load the video here and process it using
any open carry function that you want to do.
So that's it for this lesson.
Hope you enjoyed it, and I'll see you in the six.
I started the seventh lesson here, which is importing YouTube videos into open TV, which is another
cool way we can process video streams.
So stay tuned for that lesson.
Thank you.