 Hello and welcome today. We're gonna be looking at accessing our webcam now I've done videos on this topic before and I remember last time I did that someone commented something like this is why I hate Linux you have to type all these stupid commands to get simple things like webcams to work and That's that's not true. I'm showing you how to access it through the shell and give it options So you can code things out if you're looking just to access your webcam You can use a gooey in your face VLC is a good one or a very good one. Once you install is called cheese I'm typing at the shell here because I don't have a start menu, but I have effects going here Cheese is a webcam application. You can see it right here Once it's installed it will be under your application menu You know your start menu like you are if you are on Windows and you open it up. You get this I can do photos. I can do videos. I can do burst shots. I can do all these effects. I Here's a fun one Okay, visit films by chris.com And you can I'm sorry. I'm having too much fun with this I can do over this looks like a fun one. Oh and Yeah, so if you're just looking to access the webcam take some pictures or videos and maybe do effects cheese is a great application It's it might already be installed on a lot of distros just search cheese if not install it with your package manager But beyond that we're gonna look at how to do it from the shell Why do it from the shell? Well, this is allows you to script it out if you want to write a script or an alias You know or if you just want to like grab a shop We're gonna work on not saving it to a file not taking a picture, but actually displaying it on the screen and It's super simple video devices on Linux are gonna be under your device folder video So if I was to list out my fault my directory here I can say video and asterisk and you can see here. I have two listed. This first one is my webcam here, and I'm being this is not gonna work if I go cat in valid command used to be able to cat out Video devices. Yeah invalid arguments, and it would just give you the binary data You can dump to a file might still be able to do that with some webcams, but we're gonna use MPV MPV is my personal Video player by media player by default. I like it for playing music and audio files and video files I just I like it and so I want to use that for my webcams So I should be able to just type in MPV and tell it which webcam I want So webcam or my camera video is zero. I do that and it's gonna open up and You can see here that said this last thing I said it to So I don't have the best webcam thought I was buying one that was halfway decent And it's just kind of so there's a little bit of delay in the audio here the way it's streaming through here There are a lot of settings you can give up. You can see right here right now It's playing at this resolution at 15 frames a second. So how do we change that? Okay? I can change it by using another command. So to get started. I should have mentioned to install VLC Or not he'll see MPV. You would use your package manager. I'm gonna use apt and so I would pseudo apt install MPV a second thing we need or we don't I guess we don't need but we're going to use is vl2 Vl2 Loopback Dash utilities are utils. So I already have both those installed once you have those installed again MPV is the media player but vl2 vl2 is video for Linux I guess version 2 but installing that package will give us this command here, which just like MPV has lots of options But it's gonna let us set our camera something so I'm gonna go ahead and set it using this command again This looks like a long command But you can alias this out or putting in a script which we'll talk about in a little bit But look so we do VLC and we do set dash MT and there's gonna be links in the description so you can copy and paste some of this stuff Set dash MFT I'm assuming format video and then we can give it a width and a height Right, I can do that and now it's set that camera or set all my cameras to play at that resolution So I can come up here and run this MPV command again And now you're gonna see I have a much slower frame rate, but a higher resolution again This just has to do with my having a cheap webcam Of course there's other options you might be able to change to get the higher resolution with higher frame rate We can go back in here and change these to different settings now You're not gonna be able to set it to a resolution that your camera doesn't support so if I was to do like Something like this That's not a standard resolution, but it's gonna go to the closest available based on those numbers We give it so now I do that and you can see it's doing 1280 by 960 still getting five frames a second thing is since it's going to the closest by way I'm in control C just to close that out is I only have to give it one the height or the width and it's gonna go to the closest so I can say like 600 here and now when I open it up with MPV It's going to go to the closest which is 640 by 480 and I'm getting 30 frames a second which is good There's still a slight delay which I'm not seeing in cheese So again, there's other settings you can change, but I'm just showing you quickly some of the default things you can set But yeah, I got good, you know a little bit of a delay, but I got good Frame rate and I got it at a resolution of 640 by 480 Let's go ahead and all the way down to 300 and I can do that and it's probably gonna do 320 no 352 by 288 It's gonna set it it's nuts. It's not quite as wide screen as before. It's a little more squished It's just one of those standard resolutions that are there but I'm getting my 30 frames a second out of that and Not much of a delay at this point. We can go even lower if we want I can just say 100 and then run MPV on that camera again now I'm very pixelated almost no delay and 30 frames a second again A lot of the speed the frames per second and the resolution it's gonna have to do with your camera My camera is a 1080p camera, but it doesn't get that that frame rate at that at least not with these settings again That's all I have to show you again if you want you can run this Video for Linux to control if you're a man on that or MPV You'll get the man file and you can see all the different options in here So you can tweak it to your liking and it even gives you plenty of examples I love man pages that give examples because you just copy and paste some of these and you're all set But definitely looks through that if you want to get more options But I just wanted to show you how to change the resolution and how to play the video Another option now. I'm just doing MPV and pointing it directly to that video device a lot of videos Or a lot of things I've read suggest using AV colon forward slash forward slash video for Linux to colon forward slash and then the file I'm showing you this because it works the same on my system But for some reason if the first command doesn't go ahead and give that a try But again, you can alias this stuff or using scripts Which is why we use the shell to shorten things up so I don't have to type out all this, right? I can alias that and then I already alias it to webcam on mine So I can a webcam it's gonna start playing that again at the last settings I had set but I can also alias it to run both those commands or put in scripts run both those commands So I'm gonna type in webcam and it will put it to the resolution. I want and display it on the screen I can also set it to sense the resolution I want to dump it to a file and stream it and play it on my screen But that's the point of the shelves like you can shorten up these commands to to simple little commands So you can have three lines of code all in you know one letter I could be like W although W's already or a command, right? So that's it for this tutorial again check out the link in the description to the notes where you'll see the examples of these commands that I've done and Pleases my website films by chris.com. That's Chris the K. There's a link in description as always I hope that you have a great day