ADB_Forwarder
ADB_Forwarder copied to clipboard
Code erroring out
Hi, I am having a simple but strange error. I can get everything to work but the python script is erroring out. It can't find the file on line: check = sp.Popen(shlex.split("{0} devices".format(self.config["location"])), stdout=sp.PIPE, stderr=sp.PIPE). Exact error is "FileNotFoundError"
I have download adb, I can see my devices through the Powershell, I have set up the IP cam, I can the IP cam as a browser in OBS. The JSON is configured to the address of the adb.exe (and it's reading the JSON as it shows up in the debugger). Correct port (default of 8080).
same issue.
same issue.
Easy enough to resolve this error. Add , shell=True as an argument within the end of the brackets. You'll need to repeat this later in the code. But having said all that, the code ran and did nothing. It couldn't detect any devices via adb when I can clearly see them in Powershell. Conclusion: I gave up. If you have any better luck, please share! There is an obvious gap in the market here for some simple code to convert a phone into a webcam (and all the versions on the web , DroidCam / IVcam etc are inconsistent or plain right dodgy pieces of software).
@lawrencestroud @utsawb1
Can you post the config you use? My guess is that you may not have formatted the path to the ADB executable correctly: if you have the path C:\Users\tester\adb\adb.exe
you would need the path in the config file to look like C:\\Users\\tester\\adb\\adb.exe
I'm also hesitant to use shell=True
because it's considered insecure.
Hi @HunterAP23 - I'm running into the same issue with my config set up like this:
{ "location": "C:\\Users\\Victor\\Downloads\\platform-tools\\adb.exe", "port": "8080" }
The forwarder and platform tools are here:
Having added shell=True to the two sp.Popen calls has made it run somewhat farther, but now it stalls on my ADB being invalid. The ADB is a fresh download, I'm not sure why it'd be invalid. I've had apps like Iriun Webcam (which I suspect does exactly this) running perfectly on this computer + phone. The error still occurs when I switch to use the ADB that came with Iriun.
Going to rework and refactor some things - I'll follow up when I release some updates and see if the issues are fixed.
Excited to see what you come up with, it'd be great to have something like this actually functional. It's mind-blowing to me how there's not a single app/program out there that just offers a USB feed plus basic camera controls (manual exposure, focus lock, that sort of thing). I was thinking I'd probably be able to extend this myself to get the camera controls I'm looking for exposed. Would you happen to have any idea how soon you'd be able to take a look at this? Days, weeks? Appreciate the effort, and that you put this out here in the first place!
Excited to see what you come up with, it'd be great to have something like this actually functional. It's mind-blowing to me how there's not a single app/program out there that just offers a USB feed plus basic camera controls (manual exposure, focus lock, that sort of thing). I was thinking I'd probably be able to extend this myself to get the camera controls I'm looking for exposed.
The issue with getting camera controls accessible over USB is that it's not possible to access hardware on Android devices in that way. It would essentially require one app on desktop and another on the device itself to communicate over a network connection, where the device app opens the hardware camera and the desktop app receives the camera feed. I'm not an Android programmer but I was toying with the idea of doing this, but it'll take quite a bit of work (a few months for me).
Would you happen to have any idea how soon you'd be able to take a look at this? Days, weeks? Appreciate the effort, and that you put this out here in the first place!
I'm working on it as we speak, I'm expecting to actually get it done by later today/tonight (I'm US eastern time). This app's been needing a good rewrite for some time now.
The issue with getting camera controls accessible over USB is that it's not possible to access hardware on Android devices in that way. It would essentially require one app on desktop and another on the device itself to communicate over a network connection, where the device app opens the hardware camera and the desktop app receives the camera feed. I'm not an Android programmer but I was toying with the idea of doing this, but it'll take quite a bit of work (a few months for me).
I hadn't considered that - I had just assumed that there would be pre-existing hooks/function calls for that sort of thing over the debug connection, but it's not surprising that that's not the case. I imagine it'd be easier to do something like this if the controls were phone-side, rather than the phone being controlled from the desktop... Maybe I'll give something like that a shot. I'm entirely unfamiliar with software/application programming as all my experience is in the game-dev space, but who knows, maybe I'll be able to figure it out.
Looking forward to giving it another shot once you've done your rewrite though!
For a completely different awful idea - do you think it'd be possible to handle my camera controls etc. through a regular camera app on my phone, so that the sensor and image processing settings are set to what I want, and to still be able to use this to stream the final result to the PC?
For a completely different awful idea - do you think it'd be possible to handle my camera controls etc. through a regular camera app on my phone, so that the sensor and image processing settings are set to what I want, and to still be able to use this to stream the final result to the PC?
You know if you use the IP Webcam
app that you can access the web GUI for that camera instance through a URL right?
The README provides an example of this in steps 13-16, but this assumes you're using the IP Webcam
app on your device
I created a new branch called testing
where I've posted the updated code for the project. Please try it out and let me know if it works as expected.
You know if you use the IP Webcam app that you can access the web GUI for that camera instance through a URL right? The README provides an example of this in steps 13-16, but this assumes you're using the IP Webcam app on your device
I did actually know that, and I've got it set up - I don't know why I blanked on this, but just completely forgot while typing these comments. That does indeed solve that 'issue'.
I created a new branch called testing where I've posted the updated code for the project. Please try it out and let me know if it works as expected.
I'll give it a shot sometime today!
Alright, just had a go;
The code runs just fine and it says it's forwarding the device:
I see zero difference compared to the stream's delay/dropped frames compared to when I have the USB disconnected, though, and I can disconnect the USB cable and it'll continue without even the slightest hiccup. If I re-plug the USB cable nothing happens, and if I re-run the adb_handler once again it runs fine but nothing happens. Disabling my desktop's internet connection causes it to stop working entirely.
I'm not entirely certain how this works under the hood, but it looks suspiciously much like it's just not doing anything over USB and it's using the network connection instead, and it just does nothing when the network connection doesn't exist.
Maybe my expectations were off, but I was expecting to be able to push 1080p30 at high quality compression more effectively than over Wi-Fi, as that was dropping 90% of frames. As this is a wired connection, I expected it to have more bandwidth available.
@Mr4Goosey Not sure if you're still interested in this Goosey and perhaps you already did the connection correctly but... The script creates a loopback on the local computer, so you should be entering 127.0.0.1:8080 as the target address to use the phone connected over USB. I got it working as such with the script in testing branch.
To avoid getting your hopes up, The performance over wired was still lackluster for me with lots of compression artefacts when cranking the quality to 100% (Using the IP Webcam app). I was honestly hoping for minimal compression, I dont think any IP Webcam / similar app etc developer is reading the sensor data and pushing low compression over the network. RAW data from the sensor is likely too bandwidth intensive so no one does it, this is a pretty strange niche use case after all.
I admittedly forgot about this project - been too busy with other ones. I merged the testing branch into the master to include that loopback fix.
To avoid getting your hopes up, The performance over wired was still lackluster for me with lots of compression artefacts when cranking the quality to 100% (Using the IP Webcam app). I was honestly hoping for minimal compression, I dont think any IP Webcam / similar app etc developer is reading the sensor data and pushing low compression over the network. RAW data from the sensor is likely too bandwidth intensive so no one does it, this is a pretty strange niche use case after all.
The 100% quality setting on the IP Webcam app isn't really viable for any Android device to use, since it's an insane performance hog. It'll drop frames, and might not even really improve the image much when you go past 90% quality.
I hate to say that my project isn't up to snuff, but I would recommend looking at alternatives like DroidCam/DroidCamX (for using your device as a general UVC webcam device) or DroidCam OBS (a newer version of DroidCam that only works inside of OBS).