From 53a14d0c788ed67b073a9a3280c6a7b7bcf0f6c0 Mon Sep 17 00:00:00 2001 From: dm1sh Date: Tue, 24 May 2022 03:04:58 +0300 Subject: [PATCH] added article about using phone as linux camera --- .../Use_phone_as_camera_for_linux_desktop.md | 31 +++++++++++++++++++ static/articles/list.db | 1 + 2 files changed, 32 insertions(+) create mode 100644 static/articles/Use_phone_as_camera_for_linux_desktop/Use_phone_as_camera_for_linux_desktop.md diff --git a/static/articles/Use_phone_as_camera_for_linux_desktop/Use_phone_as_camera_for_linux_desktop.md b/static/articles/Use_phone_as_camera_for_linux_desktop/Use_phone_as_camera_for_linux_desktop.md new file mode 100644 index 0000000..03221f7 --- /dev/null +++ b/static/articles/Use_phone_as_camera_for_linux_desktop/Use_phone_as_camera_for_linux_desktop.md @@ -0,0 +1,31 @@ +First, we need to install an application, that'll provide MJPEG video stream. There is IP Webcam, but it is closed source, so it doesn't fit our requirements, through it could be a simplier solution. We will use [ScreenStream](https://github.com/dkrivoruchko/ScreenStream) instead, that is also [available](https://f-droid.org/packages/info.dvkr.screenstream) on F-Droid. With it we can share anything displayed on the phone screen, so, to stream video from camera, we can use any camera solution. + +Next, we need to connect phone with our linux PC. For it you can connect them to the same network. But to lower thresold, you can connect them with a wire, enable USB debugging and forward port with adb: + +``` +adb forward tcp:8000 tcp:8080 +``` + +Prior command will set up PC' port 8000 to phone's 8080. Also note, then if you use ScreenStream, you need to enable local host in its settings. + +Next step is to set up a dummy interface for our camera. For it, install and enable v4l2loopback kernel module: + +``` +sudo pacman -S v4l2loopback-dkms +``` + +It will create a dummy video interface on `/dev/video0`. We'll assume, it is enough, but if you need more then one device, you can easely google, what params need to be passed while manually enabling the module. + +Then, if you don't have ffmpeg, install it: + +``` +sudo pacman -S ffmpeg +``` + +And finally: + +``` +sudo ffmpeg -i http://[localhost или ip адресс телефона]:8000/stream.mjpeg -fflags nobuffer -pix_fmt yuv420p -r 30 -f v4l2 /dev/video0 +``` + +That's all, now you can use your phone camera (or, any other app) just like your PC camera. \ No newline at end of file diff --git a/static/articles/list.db b/static/articles/list.db index 7c87971..344cd8a 100644 --- a/static/articles/list.db +++ b/static/articles/list.db @@ -3,3 +3,4 @@ 1619034957605 Stack_VM_V1.0 1627839955679 Publite_-_an_Ebook_reader 1646570601234 Mount_WSL_partition_on_Arch_Linux +1653350638050 Use_phone_as_camera_for_linux_desktop \ No newline at end of file