1
00:00:00,450 --> 00:00:04,140
So now let's take a look at capturing video using screenshots.

2
00:00:04,620 --> 00:00:05,910
So what does that mean?

3
00:00:06,120 --> 00:00:15,030
So sometimes if it's zoom in a bit, so sometimes if you have issues with accessing a video stream,

4
00:00:16,530 --> 00:00:22,350
let's assume it's a YouTube or live Facebook video stream that you want to process for some reason or

5
00:00:22,350 --> 00:00:23,190
Twitch stream.

6
00:00:23,670 --> 00:00:29,910
Now there all functions like remote and a couple others that allow you to plug in the URL or code for

7
00:00:29,940 --> 00:00:32,820
YouTube video and stream it using Python.

8
00:00:33,270 --> 00:00:40,740
However, a lot of the video companies like YouTube and Twitch, they don't like libraries can do that,

9
00:00:40,740 --> 00:00:46,260
so they occasionally try to block those things by putting up, making making slight changes in the algorithm

10
00:00:46,470 --> 00:00:47,460
that breaks those code.

11
00:00:48,090 --> 00:00:56,160
So one way to do it is you just bring up the stream on your video player, a web browser, and you use

12
00:00:56,160 --> 00:01:01,530
something a method called capturing screenshots as capturing screenshots of your desktop and turning

13
00:01:01,800 --> 00:01:02,640
it into a video.

14
00:01:03,060 --> 00:01:08,430
So the previous company I was at, we actually used that to process Twitch streams.

15
00:01:09,390 --> 00:01:11,820
It was quite an efficient way to do it.

16
00:01:11,910 --> 00:01:16,980
However, we wouldn't be doing what into two or three different Twitch streams at one time.

17
00:01:17,580 --> 00:01:23,940
This was a gambling EA Games gambling company, bingo that I was at, and we used the screenshot grabber.

18
00:01:24,450 --> 00:01:25,650
We didn't use image grab.

19
00:01:25,710 --> 00:01:26,550
We use another one.

20
00:01:26,970 --> 00:01:29,100
But it was good because it was quite fast.

21
00:01:29,550 --> 00:01:34,800
I actually experimented with many of them, so we actually have to install this here.

22
00:01:35,070 --> 00:01:37,180
So I'm going to install that right now.

23
00:01:37,180 --> 00:01:41,190
We don't have it in this environment that I'm using.

24
00:01:41,670 --> 00:01:44,220
So I'm just going to pause the video and store these things here.

25
00:01:44,490 --> 00:01:47,940
Now these are the install instructions for Mac and Linux.

26
00:01:48,450 --> 00:01:48,810
You can.

27
00:01:49,170 --> 00:01:50,490
This has to be done in terminal.

28
00:01:50,520 --> 00:01:56,130
If you're using a Mac or Linux Windows, you can run the pipe command service, but exclamation pip,

29
00:01:56,130 --> 00:01:58,500
install Polu and PIP installed by screenshot.

30
00:02:00,630 --> 00:02:02,810
So I've installed these these function.

31
00:02:02,820 --> 00:02:06,870
These are libraries here, and let's grab a screenshot.

32
00:02:06,870 --> 00:02:10,110
So let's run this function here and it's what it does.

33
00:02:10,110 --> 00:02:13,860
It grabs a screenshot of our current screen using image stock grab here.

34
00:02:13,980 --> 00:02:18,180
Image grab function is loaded here, and it saves it as fullscreen or PNG.

35
00:02:18,420 --> 00:02:22,700
So let's take a look and see if this works and you can see what.

36
00:02:22,710 --> 00:02:26,070
Specifically, it grabs a screenshot of the screen you on just now.

37
00:02:26,730 --> 00:02:27,840
So that's pretty cool.

38
00:02:29,070 --> 00:02:34,680
So what about if you wanted to do it like in the video stream so we can do it this way?

39
00:02:34,980 --> 00:02:39,630
What this does, it allows us to grab a specific region of the screen we're looking for.

40
00:02:39,660 --> 00:02:40,950
So we draw a bounding box.

41
00:02:40,950 --> 00:02:46,590
We're looking at a top left corner of the screen and we're going to displayed it as a video displaying

42
00:02:46,590 --> 00:02:51,420
the FBS of that here, which is a useful tool to get to see the performance of it.

43
00:02:51,930 --> 00:02:53,970
And you can see it's printing graphics here.

44
00:02:54,000 --> 00:03:01,170
You can actually use the TV to DOT protects the displays as well, and you can see this is our window

45
00:03:01,170 --> 00:03:03,720
here in top left window that we're looking at.

46
00:03:04,140 --> 00:03:11,880
When I move my most of it, it should probably the most of the mouse doesn't is invisible, but let's

47
00:03:11,880 --> 00:03:12,660
see this.

48
00:03:12,810 --> 00:03:17,660
It should know it has a bit of a lag, so you can see that it works pretty cool.

49
00:03:17,670 --> 00:03:21,260
And we do have the Bugs Bunny still playing in the back for the previous stream.

50
00:03:21,270 --> 00:03:23,160
So just ignore that can be distracting.

51
00:03:24,000 --> 00:03:25,080
Let's go back to this.

52
00:03:26,070 --> 00:03:31,200
So yeah, you can see it has a couple of seconds too late, but that's OK.

53
00:03:31,830 --> 00:03:33,540
So let's stop this now.

54
00:03:33,810 --> 00:03:36,710
Let's zoom out and stop that code.

55
00:03:37,320 --> 00:03:42,640
And what if you needed a fast frame rate grabber use and this?

56
00:03:42,690 --> 00:03:44,500
This is not a library that's loaded here.

57
00:03:44,520 --> 00:03:46,530
I'm not sure if I install this before this find.

58
00:03:47,520 --> 00:03:48,170
Yep, I did.

59
00:03:48,210 --> 00:03:51,240
And you can see immediately the frame rate is much, much faster.

60
00:03:52,170 --> 00:03:54,330
You can see that it has no, almost no lag.

61
00:03:54,930 --> 00:03:56,370
You can see where it was over it here.

62
00:03:56,460 --> 00:04:02,550
It was creating multiple layers of it because it's capturing it for each other point.

63
00:04:02,560 --> 00:04:05,400
So let's just move this box away.

64
00:04:06,010 --> 00:04:08,190
And this one doesn't grab a mouse as well.

65
00:04:09,340 --> 00:04:10,350
Doesn't grab this things.

66
00:04:10,350 --> 00:04:15,540
Maybe it's not in the region, actually, it's looking at, Oh yeah, it's in this region here.

67
00:04:15,540 --> 00:04:22,170
It's looking at so we can move this window over it and you can see there's minimal lag here.

68
00:04:22,230 --> 00:04:28,560
So if you needed to get a live video stream in here, this is one way to do it.

69
00:04:28,690 --> 00:04:34,350
This is one where you can put a video player right here and load the video here and process it using

70
00:04:34,350 --> 00:04:36,930
any open carry function that you want to do.

71
00:04:37,650 --> 00:04:40,050
So that's it for this lesson.

72
00:04:40,290 --> 00:04:43,850
Hope you enjoyed it, and I'll see you in the six.

73
00:04:43,860 --> 00:04:49,920
I started the seventh lesson here, which is importing YouTube videos into open TV, which is another

74
00:04:49,920 --> 00:04:52,020
cool way we can process video streams.

75
00:04:52,500 --> 00:04:54,510
So stay tuned for that lesson.

76
00:04:54,720 --> 00:04:55,230
Thank you.
