From 8ee0742297a0e595551454568793f4f68b8af340 Mon Sep 17 00:00:00 2001 From: cpu Date: Thu, 21 Dec 2023 01:24:59 +0100 Subject: [PATCH] added VAAPI acceleration --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cb57da9..1c810f7 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ Or using ffmpeg Compressed: mjpeg : Motion-JPEG : 160x120 176x144 320x240 352x288 640x480 800x600 960x720 Raw : yuyv422 : YUYV 4:2:2 : 160x120 176x144 320x240 352x288 640x480 800x600 960x720 1600x1200 ``` -Lists all available recording devices +Lists all available audio recording devices > `arecord -l` ``` **** List of CAPTURE Hardware Devices **** @@ -140,8 +140,8 @@ Note: Does not work on Waylad ([What is Wayland in Linux Distros and Should You > `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 +> `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 @@ -154,6 +154,13 @@ Note: Does not work on Waylad ([What is Wayland in Linux Distros and Should You ### Live stream white text on black background [ffmpeg create blank screen with text video](https://stackoverflow.com/questions/22710099/ffmpeg-create-blank-screen-with-text-video) > `ffmpeg -hide_banner -f lavfi -i color=size=320x240:rate=25:color=black -vf "drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:fontsize=30:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text='Stream začne čoskoro...'" -vcodec libx264 -preset slow -f flv rtmp://peertube.virtonline.eu:1935/live/LIVE-STREAM-KEY` +### Live stream camera using h.264 hardware acceleration [VAAPI](https://trac.ffmpeg.org/wiki/Hardware/VAAPI) (e.g. on Intel iGPU) +Use the dockerized ffmpeg with precompiled vaapi support, adjust `/dev/video2` +> `alias ffmpeg='docker run --rm -w $(pwd) -v $(pwd):$(pwd) --device=/dev/dri --device=/dev/video2 jrottenberg/ffmpeg:vaapi'` + +Adjust `/dev/video2`, `-video_size 1920x1080 -framerate 60` and stream to peertube (if it can handle that much) +> `ffmpeg -hide_banner -y -f v4l2 -input_format mjpeg -video_size 1920x1080 -framerate 60 -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i /dev/video2 -vf 'scale_vaapi=format=nv12' -c:v h264_vaapi -b:v 10M -f flv rtmp://peertube.virtonline.eu:1935/live/LIVE-STREAM-KEY` + Adjusting camera functions -------------------------- Brightness, zoom, focus, etc, can be adjusted