From 48307410cecf7a14e59b554d388fbdb583276d7f Mon Sep 17 00:00:00 2001 From: tiyn Date: Sat, 11 Nov 2023 23:35:27 +0100 Subject: [PATCH] android: added ip webcam and follow ups --- wiki/android/ip_webcam.md | 38 ++++++++++++++++++++++++++++++++++++++ wiki/linux/ffmpeg.md | 17 +++++++++++++++++ wiki/linux/v4l2.md | 27 +++++++++++++++++++++++---- wiki/webcams.md | 2 ++ 4 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 wiki/android/ip_webcam.md diff --git a/wiki/android/ip_webcam.md b/wiki/android/ip_webcam.md new file mode 100644 index 0000000..0122e76 --- /dev/null +++ b/wiki/android/ip_webcam.md @@ -0,0 +1,38 @@ +# IP Webcam + +[IP Webcam](https://play.google.com/store/apps/details?id=com.pas.webcam&hl=de&gl=US) is an App +developed and published by Pavel Khlebovich for [Android](/wiki/android.md) systems. +It enables a [smartphone](/wiki/smart_devices.md) to be used as [webcam](/wiki/webcams.md). + +## Setup + +On [Android](/wiki/android.md) IP Webcam is available on the +[Google Play Store](/wiki/android.md#app-store) in a package called +[IP Webcam](https://play.google.com/store/apps/details?id=com.pas.webcam&hl=de&gl=US). + +## Usage + +To initiate a connection between the [smartphone](/wiki/smart_devices.md) and the computer first +start the app on the smartphone. +Make sure to be connected to the same W-LAN as the computer or alternatively connect them with an +USB-cable. +After starting the application an IPv4 link be displayed. +This link can be pasted into a [browser](/wiki/web_browser.md). +There the video aswell as various settings will be available. +An example link will look like the following. + +```txt +http://192.168.178.66:8080 +``` + +Additionally it can be piped into [OBS](/wiki/obs.md) to edit it or into +[ffmpeg](/wiki/linux/ffmpeg.md) on [Linux](/wiki/linux.md) systems to create a virtual webcam +device as explained in the +[ffmpeg entry](/wiki/linux/ffmpeg.md#create-a-virtual-camera-using-an-ip-video-stream). +The link used for applications like this will be the previously displayed IPv4 link aswell as an +appended `/videofeed`. +An example link will look like the following. + +```txt +http://192.168.178.66:8080/videofeed +``` diff --git a/wiki/linux/ffmpeg.md b/wiki/linux/ffmpeg.md index a488bcb..b7a9ce0 100644 --- a/wiki/linux/ffmpeg.md +++ b/wiki/linux/ffmpeg.md @@ -63,3 +63,20 @@ Note that the bitrate for videos is split amongst a bitrate for video and a bitrate for audio. The target bitrate has to be equal to or greater than the sum of both video bitrate and audio bitrate. + +### Create a Virtual Camera Using an IP Video Stream + +The following section will create a virtual [webcam](/wiki/webcams.md) from an IP video stream like +the one provided by [IP Webcam](/wiki/android/ip_webcam.md) [Android](/wiki/android.md) app. +For this a free [V4L2](/wiki/linux/v4l2.md) video device will be needed. +To information on how to create it navigate to the V4L2 entry and its sections on +[permanent](/wiki/linux/v4l2.md#create-permanent-v4l2-devices) and +[temporary creation of V4L2 video devices](/wiki/linux/v4l2.md#create-temporary-v4l2-devices). +The following command will create a video device using the pixel format planar YUV 4:2:0. +In this example it is assumed that the IP link is `http://192.168.178.66:8080/videofeed` and the +V4L2 video device that is not used but exists is `/dev/video8`. +If any of those differs on a given system adjustments are needed. + +```sh +ffmpeg -i http://192.168.178.66:8080/videofeed -f v4l2 -pix_fmt yuv420p /dev/video8 +``` diff --git a/wiki/linux/v4l2.md b/wiki/linux/v4l2.md index 412839f..9d80019 100644 --- a/wiki/linux/v4l2.md +++ b/wiki/linux/v4l2.md @@ -13,11 +13,21 @@ The following section is based on a [v4l2loopback](https://github.com/umlaeute/v4l2loopback) is a utility to create a virtual video device. One use of it is in [OBS Virtual Camera](/wiki/obs.md#virtual-camera). + +### Setup + To use v4l2loopback an according package needs to be installed. Some distributions have a package named `v4l2loopback-dkms` in the package manager, making the manual installation process unnecessary. -Afterwards v4l2loopback can be manually started by running: + +### Usage + +This section focusses on various use-cases for the v4l2loopback software. + +### Create Temporary V4L2 Devices + +v4l2loopback can be manually started by running: ```sh modprobe v4l2loopback card_label='V4L2 Loopback' video_nr=7 exclusive_caps=1 @@ -28,6 +38,15 @@ modprobe v4l2loopback card_label='V4L2 Loopback' video_nr=7 exclusive_caps=1 This can be changed according to the needs. It is important that the device is not already in use by another application. +To create more than one device more labels or numbers can be appended. +An example command with 2 V4L2 video devices will look like the following command. + +```sh +modprobe v4l2loopback card_label='OBS Virtual Camera','IP Webcam' video_nr=7,8 exclusive_caps=1 +``` + +### Create Permanent V4L2 Devices + For an automatic start at boot via [SystemD](./systemd.md) a service can be created - as described in [the SystemD entry](./systemd.md#run-command-on-boot). For v4l2loopback create the file `/etc/systemd/system/v4l2loopback.service` @@ -40,15 +59,15 @@ Description=V4L2 Loopback [Service] Type=simple RemainAfterExit=yes -ExecStart=/bin/modprobe v4l2loopback card_label='V4L2 Loopback' video_nr=7 exclusive_caps=1 +ExecStart=/bin/modprobe v4l2loopback card_label='OBS Virtual Camera' video_nr=7 exclusive_caps=1 ExecStop=/bin/rmmod v4l2loopback [Install] WantedBy=default.target ``` -Note the line starting with `ExecStart=/bin/` is the same line described above -to change the device path. +Note the line starting with `ExecStart=/bin/` is the same line described in the +[above section](#create-temporary-v4l2-devices). Make sure to change it if needed. Afterwards enable the service to start at every boot process by running: diff --git a/wiki/webcams.md b/wiki/webcams.md index bf684d5..deeb7e6 100644 --- a/wiki/webcams.md +++ b/wiki/webcams.md @@ -27,3 +27,5 @@ A [smartphone](/wiki/smart_devices.md) and its camera aswell as flashlight can b replacement for a webcam. For [Android](/wiki/android.md) smartphones this can be easily achieved by using [DroidCam](/wiki/android/droidcam.md). +An alternative to DroidCam with a with decidedly better resolution is +[IP Webcam](/wiki/android/ip_webcam.md).