 Okay, whoop, I already recorded most of this video, but I forgot to press record on my computer. So hopefully things go better this time. In a previous video, I showed how you can stream your Android screen across the network through SSH to a desktop computer, and I said I was gonna do a follow-up video, and that would be really short, because it's one simple command, but based on the comments on my last video, I realized I'm gonna have to not just show how to do this, but explain things a little bit more. So this is gonna be a longer video, but I'm gonna show you things on a desktop computer on how to stream the desktop from one machine to another using FFMpeg and SSH, and we're gonna do something similar on our phone here. Now I'm not streaming through SSH the way we are going to be doing right now. Right now I'm streaming through USB using a program called, I think it's pronounced screen copy. It's spelt SCR CPY, in repositories for most Debian distributions I've talked about in the past. All you need to do is enable ADB, hook up USB, run that command, and you'll start viewing your screen on your desktop computer. It's very responsive, and not only can you view it, but on my desktop, I can actually use my keyboard and mouse to open up applications and type things, which in the end, what we're doing today, you won't be able to control the device remotely that way, although theoretically you could probably set something up like that, but we're just gonna be streaming the video to the screen from one machine to another. But there are a few things you need to realize. First of all, one of the questions was, do you need a beefy machine to do this? No, no, this phone was $100, brand new, I've done, actually no, that phone, my actual phone, this one was only $50, and my laptop is a ThinkPad that I bought used for about $150. So not beefy hardware at all, I've shown you in the last few years how much lag there was, almost none, just a little bit. Now, I don't know if that compounds over time, like if you're streaming it for like an hour, is it gonna all of a sudden start lagging more? I haven't gone that far. But you'll have different compression options, but I'm saying but a lot. I have another computer over there. So right now we're gonna look at my desktop and I am going to show you exactly what we're doing, I'm gonna try to explain a little bit more, but another thing you need to remember is an Android device is a computer. It is not just a computer, but it's a Linux computer. A lot of people say Android isn't really Linux. It is, it's running a Linux kernel, which is just a piece of software that allows the software on the device to communicate with the hardware. This is a Linux device just as much as my Debian devices, Debian desktop laptop is a Linux device. Yes, it has a funny file structure and yes, weird permissions, but it's a Linux system, nonetheless, and a lot of what you do, almost all that you do on your desktop, you can do on your Android device natively with a few exceptions. Now, the exception isn't that we're running Linux on that and not this. It's that we're running Xorg on this, our X display and not on this. So that will come into play here, but don't worry, hopefully everything will make sense once I jump in here. So let me go ahead, jump over to my screen here and start explaining stuff. Okay, let's move things over to this screen. So let me go ahead and again, right here I am running through USB, I'm streaming my screen, but let's go ahead and just kill that. As I said, I have a computer on the other side of the room, so it's on the network and of course you can do this across the internet if you need to, but we are going to use FFMpeg. What I'm gonna say here is, let me go ahead and jump to these notes I have here real quick so I can just copy and paste a command. So what is this command doing? What is FFMpeg? FFMpeg, if you don't know, is a program that is used for converting and compressing video files. That's the main purpose of it and it's used all over the place. Pretty sure when you upload videos to YouTube, it's probably using FFMpeg to compress those videos to different formats. What we're doing here is we're not compressing or converting a video, we're not grabbing something from a camera. We're saying, okay, dash F, that means this file, this is the input file, what do we want? We want to use our X11's grab. We're gonna grab our X11, which is our display manager on many Linux distributions. Again, if you're using something like Waylin, I would assume that you could probably do this, but it's gonna be a different command. Then we're gonna say input for display zero, which is actually all three of my screens here. I've got three screens, but they're all different parts of display zero. Then I'm gonna say F for file output, AVI. And you can give it lots of parameters. You can give it resolution, frame rate. You can also say how you want to compress. Here I'm just saying use the default AVI settings, which the quality is not gonna be the best. Now I can here say output.AVI. And let me make sure that's output one, because I might already have a file on here from the last recording. So I'm gonna do that. And right now it's actually recording all three of my displays. I can hit Control C to finish that. If I list out, you can see here I have output one AVI. And if I use something like MPV, which is my preferred video player, I can play that and you'll see the few seconds of video of all three of my displays being played there. Now, what I can also do is instead of saying put it in this file, I can say dash, okay? What is the dash going to do? Well, dash is saying put it to standard output. Mainly, basically what it's saying is instead of putting in a file, just dump it all right here to the terminal. So I do that and right away we just start seeing what you might think is just garbledy cook. I'm gonna Control C to kill that. Control L to clear the screen. That was actually our AVI file. It's a binary file, but being displayed to the screen instead of being sent to a file. But we could also just say, okay, whoops. Pipe that into FF Play. And FF Play is a player that comes with FFMpeg. And I'm gonna say dash to say, read what's being piped into it. So we do that, takes a second to buffer, and then we will start getting it on the screen here. So there's gonna be a second or two delay here because the buffering was also a very high resolution because it's three displays. But we're viewing it, okay? So we're doing it, we're recording the screen and then just piping it right into a player on the same device. Well, how do we do that across the network? Well again, SSH, if I didn't say earlier, SSH, we think of that as a shell. So we're logging to remote machine as a shell, but SSH can be used for tunneling or piping anything encrypted through a network or across the internet around the world. So you can get a shell, you can also share files, move them back and forth. You can pipe audio and video. You can even run applications, GUI, you know, graphical applications through SSH if you want. Anything you wanna do on a computer, you can do encrypted through SSH across the network or the internet. And that's exactly what we're going to do now. So what I'm gonna say here, again, I have a machine over there that I actually booted off a flash drive. It's a fresh boot of MX Linux and all I've done is installed FFMPEG and open SSH server on it. So I can say SSH, I give it the username of that device, which is demo on the live USB. I can say at its IP address. And then I'm going to put this first FFMPEG command into quotations. And what this is saying is, connect to this computer using SSH as this user and then run this command. Then outside of the quotations, we're saying pipe that to this current machine to FF Play. We're gonna say dash to get the input. And then we're just gonna say, this is basically dumping any extra output that would normally show up in the terminal into null so it's not taking up stuff on the screen. And otherwise you wouldn't see the login prompt. So we're gonna run that. It's gonna ask for my password. So I'm gonna type that and give it a second to buffer. And all of a sudden we're looking at the screen on the other computer. And again, it's just capturing the display as a video file and then dumping it through the network encrypted using SSH and dumping it into a player. Now again, I'm using the default AVI options. So the quality is a little gurgly, but you can set a bunch of different things. I don't wanna get too much into the settings of it, but here I can not control this. This is just a video and you can also stream audio from the microphone. We're just doing video right now but you can add a command to FFMPEG to stream audio from the microphone or output of the speakers as well. But what I'm gonna do is I'm gonna walk across the room here. So my audio might get a little low as I walk across, but I'm gonna walk over there and actually right now on this laptop, the screen has gone to sleep. So I can't even see what you're seeing over there. So once I move the mouse, I can start seeing stuff. And what I'm gonna do is here is I'm going to click and drag. So yeah, one to two seconds delay in this case. But again, this is not for controlling the remote machine. It's just reviewing it. So a second or two delay isn't really an issue because you're just like viewing something. So this could be for piping the display into a file remotely or just for monitoring what's going on on other systems. I don't like using VNC very much, although you can pipe VNC through a SSH server because VNC by default isn't encrypted. And if you don't know, VNC is software that's been around since the 90s and it basically is just for remote connection to desktops. And this is kind of the same concept except we're not giving it remote controls with mouse and keyboard. Okay, so we've done that with our desktop. How do we do this on our Android device? Well, okay, let me go ahead and bring up my display here again. And I have, I'll try, there we go. Just installed a fresh install of Turmux. Now, I installed it and I just updated the repositories. I haven't installed anything yet in Turmux. What is Turmux? Okay, so Turmux is basically a shell that you can install on Android device. It should be in your package manager, or your package manager, your app store. It's an fDroid, which I highly recommend using. And it's not a virtual machine. It's not an emulator. It's somewhat kind of like a churroot, which is basically telling you to use a certain directory as your main root directory. It's kind of like that, but basically what it's doing is it's linking different directories and saying use these directories so that you can have, its main purpose is it gives you a bunch of tools and a package manager to allow you to install and run applications easily that you normally install on a desktop Linux system. Again, it's not emulations. It's doing it natively on an Android device because you're using the Linux kernel. And that's what I used in my video. So do you need to be root? It is one of the questions that came up in the comments. Yes and no. No, you don't need to be root to do this. Yes, if you are in the way that I originally displayed using Turmux. And let me explain why. So again, this is my phone here. Let me go ahead and split my screen over here. Make this full screen. If I ADV shell, now I am at the default Android shell on this device, okay? So this is the shell that you will have on pretty much every Android device and what you can do. And if I type in screen and hit tab, you can see we have two options, screen capture and screen record. If I actually pull down on my Android device here and I swipe over, you see you have the screen record option? That is basically what we're doing here. This is really old versions of Android. This isn't here in the shell, but all modern versions of Android for the last couple of years, I don't remember what version they brought in. There's the screen record device. All I have to do is say screen record and you can pass the different options for like what file format you want and how much you wanna see on the screen. But I'm just gonna say SD card. So I'm telling it where I wanna save it. I'm gonna save it to my internal storage here and I'll just say screen.mp4. And when I hit enter here, it's giving me an error. And my bet is it's probably because this is running. So let me go ahead and clear that out, make this big and let me try this again. So we're just saying, let me clear the screen so you can see clearly what I'm typing here. We're just typing screen record and where we wanna save the video output file to. And it has to be somewhere you have right access to. So the SD card, which is the internal storage. I'll hit enter. And right now it's recording. What's on my Android screen? So I'll just start touching the screen, blah, blah, blah. And I'll hit control C to stop that. And again, screen record actually has options where you can say stop recording after a certain amount of time and this and that. But what I'm gonna do here now, yeah. I'll bring this up again. And if I actually go into, do I have a file manager here? Again, this is like a fresh install. And I can go here and I called it screen MP4. I can play it. This is what I just recorded, right? Me just touching stuff on the screen and typing random things. So again, that is the same as me pulling down from here and pressing record there. Now I don't need root to do that. I'm at the default ADB shell here and I can just run that command. The problem is if I was to do that in termux, termux does not necessarily have the permissions to access that. So if I go into termux and I type in screen record, is it screen recorder or screen recorder? Screen record, command not found. Yeah, screen record. Let me actually go here again. I'm gonna try something. I'm gonna say which screen record. And let me go ahead and type out the full. So I'll say system bin just to make sure that's not the case. Oh, you know what? Let me try something output.mp4. Okay. Oh wait, I'm recording. Again, that doesn't work when I'm doing this. So let me go ahead, you won't see it but I'm going to run that command again. It's recording. So I thought I needed to be root to do that. I just learned something new. No, you don't need to be root to do this. So let's go ahead, let me go ahead and kill that. Sorry, I can't record and display that at the same time. But let me go ahead now that I just learned something new and what we're gonna do next is we are going to TKG install open SSH and let that run. Okay, we installed open SSH. Now we need to generate some keys. Let me give me a second here. And I searched termux SSH and I'm gonna click here remote access. They give you some options here and here we're going to see. So I think I need to set up a password real quick, password authentication. So we're going to say, and I'm just going to say, well, let me just do something like this. Okay, I typed in demo since that's the password on the other demo machine. Okay, now I should be able to say SSHD. And now, again, by default, SSH will run on port 22 but you need special permissions to run stuff on port 22. So by default, termux has it set up to run on port 8022. So what I should be able to do is over here, type in IPA or IF config, if I can config, and I can see 126. So going back over here to my desktop machine, I'm gonna type in SSH 192.168.1.126, I said, port 8022. And okay, so this is because I've redone this machine since then. It's saying basically, last time I connected to this IP address, it was a different device and it's making sure that security keys are transmitted properly. I'm gonna remove the previous thing. Sorry, that's again, if you have an IP address or a server and you change the keys, since this is a fresh installed saying, okay, last time you connected to the device, it had different settings. So I just cleared that out. So this first time connecting, I'm gonna say, yes, share security keys. And I said the password was demo. Now I am at this device. So you can see, even though I'm on my desktop here, I'm SSH'd into my machine. That's all you have to do to set up SSH on Turmux and that's why I'm using Turmux. Now you can install SSH without Turmux. You can use something like Drop Bear, but Turmux just makes it easy. So now that I have this going, let me go back over here and let's go to my settings here. So last time in my previous video, the command I was using, let's go ahead and just make this full screen and I actually have to kill that. I ran this command. So I need to put in the IP address. Did I say that this is like a more advanced video? It's a 26, right? Yeah. So we're saying here, and you don't have to put in a username for when you're connecting to Turmux. We're saying SSH into this machine, port 8022, then I ran pseudo because I thought I needed a root, but I should be able to say system, bin, and then screen record. Here I'm just specifically saying use H264 format, pipe the output to my current machine. Now I'm going to run that and I say demo. And theoretically, I thought I killed, let's try how I normally do it. We're going to set up pseudo. So this is a rooted device. Just doing this will not give you root on a device, but I am going to SSH into this device. And this is just, we're gonna install git, git's gonna pull down a Turmux. It's basically a shell script that fakes pseudo commands. And so now I should be able to pseudo, I don't know, date, whatever, and it's asking me on my screen, grant permission. And okay, so that worked. Now let's exit out, let's go here to this, and I'm going to say pseudo demo. Okay. Okay, I've played around and I've discovered some things. Okay, so right now this is the original thing I did where I used pseudo, right? So we're gonna SSH into Turmux, pseudo screen record, and that, and we're gonna get an error here. I'll type it in and it's gonna give me this error. And that's because last time when I tried doing recording on the device and I stopped screen record, it's actually still running in the background. If I ADB into this device, and I say busy box, and I say PSAUX to see processes and I grep for screen, you can see here that screen record is actually still running, even though I thought I killed it. So the only way I know how to kill it is as roots, I'll kill all and kill that. So now it's dead. Now I can go back, I can run this command, hit enter, type in my password, give it a second here to connect, and now you can see that I am looking at my device, right? And there's again about a second lag. So cool. If I try to kill out of that and run it again, you'll see that we got the same error. So it's just not killing screen record properly on this device. So SU, kill all screen record. So that's one issue. Now, although I can SSH in and I can run the screen record command without sudo, and it saves to a file, if I try to pipe it to the output, just like this, it's not piping anything, right? So I'll run it again, it's not giving, it's just, there's gonna be no output. In fact, if I was to remove this F play command, nothing comes as output. For some reason, that's not working. So as of right now, doing it this way through Turmux, I do need sudo or root for screen record, even though I can run screen record without that, that doesn't make any sense to me. So let's talk about what I originally was gonna talk about in this video because I kind of went down a rabbit hole there a little bit. Let's go ahead and kill all record, just to make sure that it's dead. So, okay, I'm at the ADB shell now, okay? So we've taken Turmux out of the situation, out of the equation. We can pipe video through the network in many different ways. SSH is a clean and easy way to do it. And again, you can install a small version of SSH server and client using a program called Drop Bear, which is very common on routers and modems, and that sort of stuff, lightweight ARM devices. And you can find tutorials on that out online. I haven't tried this, but I would assume you could use Socat as well. I've talked about Socat in the past that allows you to create encryption keys and transport things through the network encrypted. But what about just unencrypted, right? So we're talking about not using Turmux, not using SSH, and just using default things, kind of default things on an Android device. Now, right now I'm on lineageOS, and there is a copy of Busybox on here. It's labeled Busybox underscore PHH, but it's still just Busybox. And I've talked about Busybox so many times in the past. I've shown how to get it. You can get pre-compiled binaries, you can compile it yourself for all different architectures. It's on many, many different devices. A lot of Android devices have it, but not all Android devices have it. If you have stock firmware on your device, you may not have Busybox, you may have Toybox, which is someone trying to recreate Busybox. In fact, I think it might even be some of the same developers that created Busybox, but under a different license. And it isn't as full-featured, but it's very easy to put Busybox on any Linux device, whether it be an ARM device, you know, an XA6 device, all these different, any architecture you can think of, MIPS devices, it's a single binary that has usually all of these applications built into it. Okay, and one of those applications is NC, and I've also talked about in the past, there's NC, which could be pointing towards Netcat or NCAT, which for years I thought were the same applications, but clearly they're not. But we are gonna use Busybox and NC now to pipe things through the network, the way we did the SSH, except for this is not gonna be encrypted. So theoretically, someone could be sniffing your network and see everything you're looking at. Take that into account. I'll link to notes, these notes in the description of this video, where is, I don't have those notes up. Let's go to filmsbychris.com, my website, right? And we're gonna go to software, we'll click on notes. And here I'm just gonna type in Busybox, Android, stream Android screen with Busybox NC. So I just did this the other day after you guys commented on stuff. And what we're gonna do is on my desktop, I'm gonna run this command, okay? What I'm saying here is start up a server on my desktop and pipe whatever comes into it into our FPLAY file, okay? So top screen here, my desktop, I have Busybox installed. This is Busybox on my desktop. I'm gonna run NC and then I'm going to run dash LP. L is for listen, P is for port. I'm gonna give it a port. I'm saying 8022 here. It really doesn't really matter as long as you have access to that port. And then we're gonna say, okay, anything that comes in to this server, pass it to FFPLAY and read the standard input. Down here I'm gonna ADB into my device. And what I'm going to say is from my notes here, I'm gonna copy and paste this and I'll put a link to these notes in the description of the video. We're saying use the screen record command. We're gonna give it this type of output. We're gonna pipe it to standard output into Busybox. On this particular device, it's Busybox underscore PH, but just depends on where you have Busybox installed to. Now we're gonna say NC and give it the IP address of my desktop machine. And I'll come up here. I'll start this server. I'll come down here. I'll start this and start touching stuff on your screen because I'm pretty sure screen record on Android is only really sending stuff. It's only really recording when you're actually moving stuff on the screen. So here we're doing this and it's through the network. It's completely unencrypted. No username, no password. Anybody on your network theoretically could be sniffing this. They could be seeing what you're seeing. So it's not a very secure way to do it, but it's working through the network. And so let me go swipe to the left. So yeah, about a second delay. It works. No root, no special tools. Screen record is installed on your device by default. Busybox may or may not. Check Toybox may have some sort of NC command, but I bet it's not fully flushed out. Not as developed as NC on Busybox. But again, search my videos on YouTube for Busybox or go to filmsbychrist.com and search netcat. And I'm sure, or Busybox, I mean, I have videos you can get, binaries from the standard Busybox website, static builds for pretty much all architectures. But yeah, so that's it. And again, yeah, I'm trying to swipe here. You can't swipe here. You're not controlling the device with this, but you see there's nothing coming through the screen here. Cause again, screen record on Android is only recording when you're actually stuff's changing on the screen, which keeps the file compressed, which is nice. So if you start this and nothing comes up on the screen right away, start moving stuff on the screen. But you can see the kilobytes coming through here, but only when I'm swiping stuff on the screen. I showed you lots of things. I hope I didn't confuse you. Again, you don't need root to do this, although the simplest way to set it up and the most secure way is using SSH and SSH through Turmux, in which case I had weird, again, I kind of went down a rabbit hole a little bit here. Installing SSH is easy. Apparently you can screen record in Turmux, but when I try to screen record through Turmux without root, it doesn't work, but does with root, but recording the screen works without root. It doesn't make any sense to me. If anyone can figure that out and let me know, I'm done. I've taken all morning to record this video that should have been like a five minute video if I just showed you how to do it, but I'm trying to explain stuff to you and hopefully you learned something new. You can pipe anything from one computer to another computer through a network. You can do it unencrypted easily with NC or Netcat or NCAT, again, I have a video about how there's slight differences between those, but the best way to pipe anything through a network, the simplest thing is SSH. SSH, it's secure and it runs on everything. So yeah, I hope you learned something. I hope I didn't go down too many rabbit holes. I hope you enjoyed this video. So let me know below. Did you, again, this would have been a short video, but there were so many comments and questions. I thought I'd go more in depth on what's happening and said to showing how to do it. And I hope I didn't confuse things. If you want to come back and just do a simple video on this without all the explanation, I can do that too. But yeah, you don't need root, although why don't you have your device rooted? I know everyone goes, it's a security issue, which is a little bit, right? Because having root or pseudo access on the device is not a bad thing. As an owner of a device, you should have that. The problem is with Android, there's no password. Once you've enabled root, it's an okay button, which is like Windows level security. So really a lot of stuff Android does to make things more secure actually, in my opinion, make them less secure. But I couldn't survive. I don't do a whole lot of stuff as root on my device, but I do do stuff barely regularly. Same with my desktop. It's like, yeah, I'm not doing root stuff all the time, but occasionally I do. And just rooting a device, as long as you don't buy a device that is locked down by the manufacturer, if you unlock the bootloader, you can root it. You can do whatever you want. You should have that freedom. It's your device. But you be you, you do you. But yeah, I could not imagine not having my phone rooted or any of my devices I should have root access. It's my device. I also don't understand someone else in the comments said, oh, I've never run a server. Running servers is easy. It's usually just one command, but there's different types of servers. And I don't, again, all my devices. The first thing I do when I install a system is the packages I install. I install Apache on all my devices and I install SSH server because those are two things I'm going to use for everything. When I'm out and about anywhere on the road, when I'm on a road trip or at work, I want access to all my computers, my wife's computer, my kids' computers, my computer here. I have like three or four servers in the house. I want to be able to have access to all those and just enabling SSH allows you to do all of that. Okay. And I'm going off on a rant. Filmsbychrist.com. Chris with a K. There's a link in the description. Yes, I really spelled a name with a K. So if you comment below, it's K-R-I-S. Thank you for watching. As always, I hope that you have a great day.