diff --git a/content/blog/phone-wireless-webcam-linux.md b/content/blog/phone-wireless-webcam-linux.md new file mode 100644 index 0000000..335ea15 --- /dev/null +++ b/content/blog/phone-wireless-webcam-linux.md @@ -0,0 +1,90 @@ ++++ +title = 'How to setup a phone as wireless webcam on linux' +date = 2025-01-20T18:16:55+01:00 +tags = ['linux', 'android', 'scrcpy'] ++++ + +Anybody else need to have a webcam nowdays because of all the remote stuff that has started happening since covid, getting forced into having a webcam so that your boss/teacher/professor can follow what you are doing but don't wanna spend money on getting one and you are luckilly using linux? Then look no further because if you have a decent phone ( S24 in my case ) you can have use it as a wireless webcam ( or usb if your android version is lover than 14 ). + +I will now show you the steps and some basic settings and a script to simplify the steps. + + + +# 1. Enable Wireless/Usb Debugging on your phone + +First you will have to enable wireless/usb debugging on your phone. The steps can somewhat differ depending on your phone and as such I will use my phone as an example. + +1. Enter your settings +2. Enter "About phone" +3. Enter "Software Information" +4. Click on "Build number" until a popup tells you developer mode has been enable +5. Exit back to main menu of settings and enter "Developer Options" +6. Enable Wireless/Usb debugging + +Note that for Wireless Debugging you will have to enable it again every time you wanna use your phone as a webcam. To help with that you can ebale wireless debugging as a tile by going to developer options>"Quick settings for developer tiles" and enabling wireless debugging. + +# 2. Installing necesarry software on your linux system + +Now we have to install the needed software on your linux system to make all this work. I will use arch as an example but will first list the software you need: + +- android-tools (adb) +- v4l2loopback +- scrcpy + +> example command + +```bash +sudo pacman -S android-tools v4l2loopback-dkms scrcpy +``` + +# 3. Pair your phone with your pc using adb + +Now we will need to pair your phone using adb wirelessly with your pc. + +Go to wireless debugging settings on your phone, make sure it's enable and click the pair with code option. Take note of the ip and port, you will have to use it on your pc. + +Next you have to run this command: `adb pair IP:PORT`. After running the command you have to enter the pair code and press enter. + +And we are done, you are now connected to your phone. + +# 4. Setup video dummy device and output camera feed to it. + +Now we need to setup a dummy video device using v4l2loopback driver, using this command : `sudo modprobe -v v4l2loopback exclusive_caps=1 card_label="Virtual Webcam"`. + +Now we need to use the command `v4l2-ctl` to get which number the video device is, in my case it's `/dev/video2` + +> example + +```bash +❯ v4l2-ctl --list-devices +Virtual Webcam (platform:v4l2loopback-000): + /dev/video2 + +HD User Facing: HD User Facing (usb-0000:05:00.3-1): + /dev/video0 + /dev/video1 + /dev/media0 + +``` + +Now we can use scrcpy to get our phone's camera and show it on your pc in a nice little window, in my case I use this command which is pretty long but will explain it: + +```bash +scrcpy --video-source=camera --no-audio --camera-facing=front --v4l2-sink=/dev/video2 --camera-fps=60 --video-codec=h265 --camera-ar=4:3 -m1920 --capture-orientation=flip90 +``` + +Now to explain the options: +- `--video-source=camerate` makes sure scrcpy uses your camera as the source +- `--no-audio` makes sure to not catch phone mic audio, +- `--camera-facing=front` uses front camera, you can change it to use back camera also +- `--v4l2-sink=/dev/video2` make sure to use the video output to your "Virtual Webcam" +- `--camera-fps=60` uses 60fps mode of the camera +- `--video-coded=h265` provides better quality than `h264`, but higher latency +- `--camera-ar=4:3` and `-m1920` limits resolution to 1920 and makes it 4:3, for more caught on camera +- `--capture-orientation=flip90` flips the picture and rotates it by 90 degrees, you don't need the 90 and can use just flip0 if you make your phone stand landscape + +And now you have a nice little window showing of your phone camera wirelessly on your pc. It is also accebible with software like zoom/obs/discord/... + +--- + +Hope you had a decent time reading this and have managed to get it all working with your nice new webcam ;) diff --git a/public/blog/index.html b/public/blog/index.html index 2f4712d..a5e3802 100644 --- a/public/blog/index.html +++ b/public/blog/index.html @@ -46,6 +46,9 @@
+ + 20-01-2025 || How to setup a phone as wireless webcam on linux
+ 04-04-2024 || Securing SSH
diff --git a/public/blog/index.xml b/public/blog/index.xml index 825d82d..4b99982 100644 --- a/public/blog/index.xml +++ b/public/blog/index.xml @@ -6,11 +6,80 @@ Recent content in Blog on Crony Akatsuki's Website Hugo -- gohugo.io en-us - Thu, 04 Apr 2024 20:44:10 +0200 + Mon, 20 Jan 2025 18:16:55 +0100 + +How to setup a phone as wireless webcam on linux +https://cronyakatsuki.xyz/blog/phone-wireless-webcam-linux/ +20-01-2025 + + https://cronyakatsuki.xyz/blog/phone-wireless-webcam-linux/ +<p>Anybody else need to have a webcam nowdays because of all the remote stuff that has started happening since covid, getting forced into having a webcam so that your boss/teacher/professor can follow what you are doing but don&rsquo;t wanna spend money on getting one and you are luckilly using linux? Then look no further because if you have a decent phone ( S24 in my case ) you can have use it as a wireless webcam ( or usb if your android version is lover than 14 ).</p> +<p>I will now show you the steps and some basic settings and a script to simplify the steps.</p> +<!-- raw HTML omitted --> +<h1 id="1-enable-wirelessusb-debugging-on-your-phone">1. Enable Wireless/Usb Debugging on your phone</h1> +<p>First you will have to enable wireless/usb debugging on your phone. The steps can somewhat differ depending on your phone and as such I will use my phone as an example.</p> +<ol> +<li>Enter your settings</li> +<li>Enter &ldquo;About phone&rdquo;</li> +<li>Enter &ldquo;Software Information&rdquo;</li> +<li>Click on &ldquo;Build number&rdquo; until a popup tells you developer mode has been enable</li> +<li>Exit back to main menu of settings and enter &ldquo;Developer Options&rdquo;</li> +<li>Enable Wireless/Usb debugging</li> +</ol> +<p>Note that for Wireless Debugging you will have to enable it again every time you wanna use your phone as a webcam. To help with that you can ebale wireless debugging as a tile by going to developer options&gt;&ldquo;Quick settings for developer tiles&rdquo; and enabling wireless debugging.</p> +<h1 id="2-installing-necesarry-software-on-your-linux-system">2. Installing necesarry software on your linux system</h1> +<p>Now we have to install the needed software on your linux system to make all this work. I will use arch as an example but will first list the software you need:</p> +<ul> +<li>android-tools (adb)</li> +<li>v4l2loopback</li> +<li>scrcpy</li> +</ul> +<blockquote> +<p>example command</p> +</blockquote> +<div class="highlight"><pre tabindex="0" style="color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo pacman -S android-tools v4l2loopback-dkms scrcpy +</span></span></code></pre></div><h1 id="3-pair-your-phone-with-your-pc-using-adb">3. Pair your phone with your pc using adb</h1> +<p>Now we will need to pair your phone using adb wirelessly with your pc.</p> +<p>Go to wireless debugging settings on your phone, make sure it&rsquo;s enable and click the pair with code option. Take note of the ip and port, you will have to use it on your pc.</p> +<p>Next you have to run this command: <code>adb pair IP:PORT</code>. After running the command you have to enter the pair code and press enter.</p> +<p>And we are done, you are now connected to your phone.</p> +<h1 id="4-setup-video-dummy-device-and-output-camera-feed-to-it">4. Setup video dummy device and output camera feed to it.</h1> +<p>Now we need to setup a dummy video device using v4l2loopback driver, using this command : <code>sudo modprobe -v v4l2loopback exclusive_caps=1 card_label=&quot;Virtual Webcam&quot;</code>.</p> +<p>Now we need to use the command <code>v4l2-ctl</code> to get which number the video device is, in my case it&rsquo;s <code>/dev/video2</code></p> +<blockquote> +<p>example</p> +</blockquote> +<div class="highlight"><pre tabindex="0" style="color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ v4l2-ctl --list-devices +</span></span><span style="display:flex;"><span>Virtual Webcam <span style="color:#99d1db;font-weight:bold">(</span>platform:v4l2loopback-000<span style="color:#99d1db;font-weight:bold">)</span>: +</span></span><span style="display:flex;"><span> /dev/video2 +</span></span><span style="display:flex;"><span> +</span></span><span style="display:flex;"><span>HD User Facing: HD User Facing <span style="color:#99d1db;font-weight:bold">(</span>usb-0000:05:00.3-1<span style="color:#99d1db;font-weight:bold">)</span>: +</span></span><span style="display:flex;"><span> /dev/video0 +</span></span><span style="display:flex;"><span> /dev/video1 +</span></span><span style="display:flex;"><span> /dev/media0 +</span></span></code></pre></div><p>Now we can use scrcpy to get our phone&rsquo;s camera and show it on your pc in a nice little window, in my case I use this command which is pretty long but will explain it:</p> +<div class="highlight"><pre tabindex="0" style="color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>scrcpy --video-source<span style="color:#99d1db;font-weight:bold">=</span>camera --no-audio --camera-facing<span style="color:#99d1db;font-weight:bold">=</span>front --v4l2-sink<span style="color:#99d1db;font-weight:bold">=</span>/dev/video2 --camera-fps<span style="color:#99d1db;font-weight:bold">=</span><span style="color:#ef9f76">60</span> --video-codec<span style="color:#99d1db;font-weight:bold">=</span>h265 --camera-ar<span style="color:#99d1db;font-weight:bold">=</span>4:3 -m1920 --capture-orientation<span style="color:#99d1db;font-weight:bold">=</span>flip90 +</span></span></code></pre></div><p>Now to explain the options:</p> +<ul> +<li><code>--video-source=camerate</code> makes sure scrcpy uses your camera as the source</li> +<li><code>--no-audio</code> makes sure to not catch phone mic audio,</li> +<li><code>--camera-facing=front</code> uses front camera, you can change it to use back camera also</li> +<li><code>--v4l2-sink=/dev/video2</code> make sure to use the video output to your &ldquo;Virtual Webcam&rdquo;</li> +<li><code>--camera-fps=60</code> uses 60fps mode of the camera</li> +<li><code>--video-coded=h265</code> provides better quality than <code>h264</code>, but higher latency</li> +<li><code>--camera-ar=4:3</code> and <code>-m1920</code> limits resolution to 1920 and makes it 4:3, for more caught on camera</li> +<li><code>--capture-orientation=flip90</code> flips the picture and rotates it by 90 degrees, you don&rsquo;t need the 90 and can use just flip0 if you make your phone stand landscape</li> +</ul> +<p>And now you have a nice little window showing of your phone camera wirelessly on your pc. It is also accebible with software like zoom/obs/discord/&hellip;</p> +<hr> +<p>Hope you had a decent time reading this and have managed to get it all working with your nice new webcam ;)</p> + + + Securing SSH https://cronyakatsuki.xyz/blog/securing-ssh/ diff --git a/public/blog/phone-wireless-webcam-linux/index.html b/public/blog/phone-wireless-webcam-linux/index.html new file mode 100644 index 0000000..21216fa --- /dev/null +++ b/public/blog/phone-wireless-webcam-linux/index.html @@ -0,0 +1,179 @@ + + + + + + + + + + + + How to setup a phone as wireless webcam on linux - Crony Akatsuki + + + + + + + + + + + + + + + + + + +
+

Crony Akatsuki

+ +
+ + +
+
+ +

How to setup a phone as wireless webcam on linux

+ + + +
+

20-01-2025

+ +

+ | + linux | + android | + scrcpy

+ + +
+
+ +

Anybody else need to have a webcam nowdays because of all the remote stuff that has started happening since covid, getting forced into having a webcam so that your boss/teacher/professor can follow what you are doing but don’t wanna spend money on getting one and you are luckilly using linux? Then look no further because if you have a decent phone ( S24 in my case ) you can have use it as a wireless webcam ( or usb if your android version is lover than 14 ).

+

I will now show you the steps and some basic settings and a script to simplify the steps.

+ +

1. Enable Wireless/Usb Debugging on your phone

+

First you will have to enable wireless/usb debugging on your phone. The steps can somewhat differ depending on your phone and as such I will use my phone as an example.

+
    +
  1. Enter your settings
  2. +
  3. Enter “About phone”
  4. +
  5. Enter “Software Information”
  6. +
  7. Click on “Build number” until a popup tells you developer mode has been enable
  8. +
  9. Exit back to main menu of settings and enter “Developer Options”
  10. +
  11. Enable Wireless/Usb debugging
  12. +
+

Note that for Wireless Debugging you will have to enable it again every time you wanna use your phone as a webcam. To help with that you can ebale wireless debugging as a tile by going to developer options>“Quick settings for developer tiles” and enabling wireless debugging.

+

2. Installing necesarry software on your linux system

+

Now we have to install the needed software on your linux system to make all this work. I will use arch as an example but will first list the software you need:

+
    +
  • android-tools (adb)
  • +
  • v4l2loopback
  • +
  • scrcpy
  • +
+
+

example command

+
+
sudo pacman -S android-tools v4l2loopback-dkms scrcpy
+

3. Pair your phone with your pc using adb

+

Now we will need to pair your phone using adb wirelessly with your pc.

+

Go to wireless debugging settings on your phone, make sure it’s enable and click the pair with code option. Take note of the ip and port, you will have to use it on your pc.

+

Next you have to run this command: adb pair IP:PORT. After running the command you have to enter the pair code and press enter.

+

And we are done, you are now connected to your phone.

+

4. Setup video dummy device and output camera feed to it.

+

Now we need to setup a dummy video device using v4l2loopback driver, using this command : sudo modprobe -v v4l2loopback exclusive_caps=1 card_label="Virtual Webcam".

+

Now we need to use the command v4l2-ctl to get which number the video device is, in my case it’s /dev/video2

+
+

example

+
+
❯ v4l2-ctl --list-devices
+Virtual Webcam (platform:v4l2loopback-000):
+        /dev/video2
+
+HD User Facing: HD User Facing (usb-0000:05:00.3-1):
+        /dev/video0
+        /dev/video1
+        /dev/media0
+

Now we can use scrcpy to get our phone’s camera and show it on your pc in a nice little window, in my case I use this command which is pretty long but will explain it:

+
scrcpy --video-source=camera --no-audio --camera-facing=front --v4l2-sink=/dev/video2 --camera-fps=60 --video-codec=h265 --camera-ar=4:3 -m1920 --capture-orientation=flip90
+

Now to explain the options:

+
    +
  • --video-source=camerate makes sure scrcpy uses your camera as the source
  • +
  • --no-audio makes sure to not catch phone mic audio,
  • +
  • --camera-facing=front uses front camera, you can change it to use back camera also
  • +
  • --v4l2-sink=/dev/video2 make sure to use the video output to your “Virtual Webcam”
  • +
  • --camera-fps=60 uses 60fps mode of the camera
  • +
  • --video-coded=h265 provides better quality than h264, but higher latency
  • +
  • --camera-ar=4:3 and -m1920 limits resolution to 1920 and makes it 4:3, for more caught on camera
  • +
  • --capture-orientation=flip90 flips the picture and rotates it by 90 degrees, you don’t need the 90 and can use just flip0 if you make your phone stand landscape
  • +
+

And now you have a nice little window showing of your phone camera wirelessly on your pc. It is also accebible with software like zoom/obs/discord/…

+
+

Hope you had a decent time reading this and have managed to get it all working with your nice new webcam ;)

+
+
+ + + + + diff --git a/public/index.html b/public/index.html index 0115f9a..4b41321 100644 --- a/public/index.html +++ b/public/index.html @@ -2,7 +2,7 @@ - + diff --git a/public/sitemap.xml b/public/sitemap.xml index 6cce6b9..8d60ef6 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -2,29 +2,38 @@ + https://cronyakatsuki.xyz/tags/android/ + 2025-01-20T18:16:55+01:00 + https://cronyakatsuki.xyz/blog/ - 2024-04-04T20:44:10+02:00 + 2025-01-20T18:16:55+01:00 https://cronyakatsuki.xyz/ - 2024-04-04T20:44:10+02:00 + 2025-01-20T18:16:55+01:00 + + https://cronyakatsuki.xyz/blog/phone-wireless-webcam-linux/ + 2025-01-20T18:16:55+01:00 + + https://cronyakatsuki.xyz/tags/linux/ + 2025-01-20T18:16:55+01:00 + + https://cronyakatsuki.xyz/tags/scrcpy/ + 2025-01-20T18:16:55+01:00 + + https://cronyakatsuki.xyz/tags/ + 2025-01-20T18:16:55+01:00 https://cronyakatsuki.xyz/blog/securing-ssh/ 2024-04-04T20:44:10+02:00 https://cronyakatsuki.xyz/blog/setup-traefik/ 2024-01-19T09:33:47+01:00 - - https://cronyakatsuki.xyz/tags/linux/ - 2024-01-07T12:15:21+01:00 https://cronyakatsuki.xyz/tags/mail/ 2024-01-07T12:15:21+01:00 https://cronyakatsuki.xyz/tags/mblaze/ 2024-01-07T12:15:21+01:00 - - https://cronyakatsuki.xyz/tags/ - 2024-01-07T12:15:21+01:00 https://cronyakatsuki.xyz/blog/using-mblaze/ 2024-01-07T12:15:21+01:00 diff --git a/public/tags/android/index.html b/public/tags/android/index.html new file mode 100644 index 0000000..49a2b59 --- /dev/null +++ b/public/tags/android/index.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + Android - Crony Akatsuki + + + + + + + + + + + + +
+

Crony Akatsuki

+ +
+ + +
+ +
+ + + + + diff --git a/public/tags/index.html b/public/tags/index.html index ea75b30..f88b29d 100644 --- a/public/tags/index.html +++ b/public/tags/index.html @@ -45,15 +45,21 @@
+ + Scrcpy
+ + + Linux
+ + + Android
+ Mblaze
Mail
- - Linux
- Ssh
diff --git a/public/tags/linux/index.html b/public/tags/linux/index.html index 94d5fac..4522e72 100644 --- a/public/tags/linux/index.html +++ b/public/tags/linux/index.html @@ -43,6 +43,9 @@
+ + 20-01-2025 || How to setup a phone as wireless webcam on linux
+ 07-01-2024 || Using Mblaze
diff --git a/public/tags/scrcpy/index.html b/public/tags/scrcpy/index.html new file mode 100644 index 0000000..7ac1dce --- /dev/null +++ b/public/tags/scrcpy/index.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + Scrcpy - Crony Akatsuki + + + + + + + + + + + + +
+

Crony Akatsuki

+ +
+ + +
+ +
+ + + + +