From af200e39700e40be900db3635abea7791bed90c4 Mon Sep 17 00:00:00 2001 From: cpu Date: Mon, 18 Dec 2023 03:40:16 +0100 Subject: [PATCH] streaming to peertube --- README.md | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 171 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 603c914..a459221 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,172 @@ -# video-processing +Prerequisities +-------------- + +Install the collection of command line video4linux utilities +> `sudo apt-get install v4l-utils` + +Lists all available cameras +> `v4l2-ctl --list-devices` +``` +USB Video device: USB Camera (usb-0000:01:00.0-1.1.4): + /dev/video0 + /dev/video1 +``` + +List available formats for your camera `/dev/video0` (e.g. [Logitech QuickCam Pro 9000](https://download01.logitech.com/support/25174.1.0.pdf)) +> `v4l2-ctl -d /dev/video0 --list-formats-ext` +``` +ioctl: VIDIOC_ENUM_FMT + Type: Video Capture + + [0]: 'MJPG' (Motion-JPEG, compressed) + Size: Discrete 160x120 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 176x144 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 320x240 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 352x288 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 640x480 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 800x600 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 960x720 + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + [1]: 'YUYV' (YUYV 4:2:2) + Size: Discrete 160x120 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 176x144 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 320x240 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 352x288 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 640x480 + Interval: Discrete 0.033s (30.000 fps) + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 800x600 + Interval: Discrete 0.040s (25.000 fps) + Interval: Discrete 0.050s (20.000 fps) + Interval: Discrete 0.067s (15.000 fps) + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 960x720 + Interval: Discrete 0.100s (10.000 fps) + Interval: Discrete 0.200s (5.000 fps) + Size: Discrete 1600x1200 + Interval: Discrete 0.200s (5.000 fps) +``` +Lists all available recording devices +> `arecord -l` +``` +**** List of CAPTURE Hardware Devices **** +card 1: Q9000 [QuickCam Pro 9000], device 0: USB Audio [USB Audio] + Subdevices: 1/1 + Subdevice #0: subdevice #0 +``` +Live Streaming +-------------- +Use you own `LIVE-STREAM-KEY` and run + +### Live stream camera to peertube +> `ffmpeg -hide_banner -f v4l2 -framerate 15 -video_size 1600x1200 -input_format yuyv422 -i /dev/video0 -vcodec libx264 -tune zerolatency -b:v 1M -maxrate 1M -bufsize 2M -f flv rtmp://peertube.virtonline.eu:1935/live/LIVE-STREAM-KEY` + +### Live stream desktop to peertube +Note: Does not work on Waylad ([What is Wayland in Linux Distros and Should You Use it?](https://www.ubuntupit.com/what-is-wayland-in-linux-distros-and-should-you-use-it/)). You can quickly check whether you're using X or Wayland `echo $XDG_SESSION_TYPE` +> `DISPLAY=:0 ffmpeg -hide_banner -f x11grab -framerate 5 -video_size 830x630 -i :0.0+50,95 -vf format=pix_fmts=yuv420p -vcodec libx264 -tune zerolatency -preset veryfast -f flv rtmp://peertube.virtonline.eu:1935/live/LIVE-STREAM-KEY` + +### Live stream camera with sound and desktop as an overlay to peertube +> `DISPLAY=:0` # select display (only if run remotely e.g. ssh) +`ffmpeg -hide_banner` # do not output compile flags +`-thread_queue_size 4096 -f pulse -ac 2 -i default` # audio input from PulseAudio +`-thread_queue_size 512 -f v4l2 -framerate 5 -video_size 1600x1200 -input_format yuyv422 -i /dev/video0` # camera input +`-thread_queue_size 512 -f x11grab -framerate 5 -video_size 830x630 -i :0.0+50,95` # 830x630 window from screen 0 with offset 50,95 +`-filter_complex 'overlay=main_w-overlay_w:main_h-overlay_h'` # picture-in-picture +`-c:v libx264 -tune zerolatency -preset ultrafast -b:v 1M -maxrate 1M -bufsize 2M` # output video codec +`-c:a aac -b:a 64k` # output audio codec +`-f flv` # output container +`rtmp://peertube.virtonline.eu:1935/live/LIVE-STREAM-KEY` # peertube streaming url + +Adjusting camera functions +-------------------------- +Brightness, zoom, focus, etc, can be adjusted +> `v4l2-ctl -L` +``` + brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0 + contrast 0x00980901 (int) : min=0 max=95 step=1 default=0 value=0 + saturation 0x00980902 (int) : min=0 max=100 step=1 default=64 value=64 + hue 0x00980903 (int) : min=-2000 max=2000 step=1 default=0 value=0 + white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1 + gamma 0x00980910 (int) : min=100 max=300 step=1 default=100 value=100 + power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1 + 0: Disabled + 1: 50 Hz + 2: 60 Hz + white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=10 default=4600 value=4600 flags=inactive + sharpness 0x0098091b (int) : min=1 max=7 step=1 default=2 value=2 + backlight_compensation 0x0098091c (int) : min=0 max=1 step=1 default=0 value=0 + exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 value=3 + 1: Manual Mode + 3: Aperture Priority Mode + exposure_auto_priority 0x009a0903 (bool) : default=0 value=1 +``` +Then adjust the value: +> `v4l2-ctl -c