feat(fun/tvl): Implement hardware-accelerated stream rescaling

By randomly copy & pasting options that are impenetrable to mere
mortals from NVIDIA's developer blog and a bunch of gists scattered
throughout the internet, Andi and I managed to "get this to work".

The idea is that the x11grab stream should be resized into 720p (which
is the maximum supported by Google Meet), but with hardware
acceleration.
This commit is contained in:
Vincent Ambo 2020-04-04 02:24:28 +01:00
parent f8703d12da
commit bcfa11599d
2 changed files with 18 additions and 14 deletions

18
fun/tvl/default.nix Normal file
View file

@ -0,0 +1,18 @@
{ depot, ... }:
depot.third_party.writeShellScriptBin "start-tvl-stream" ''
env LD_LIBRARY_PATH=/run/opengl-driver/lib/ ${depot.third_party.ffmpeg}/bin/ffmpeg \
-vsync 0 \
-hwaccel cuvid \
-init_hw_device cuda=0 -filter_hw_device 0 \
-f x11grab \
-video_size 1920x1080 \
-framerate 30 \
-i :0.0+0,0 \
-filter:v "format=nv12,hwupload,scale_npp=w=1280:h=720:interp_algo=lanczos" \
-c:v h264_nvenc \
-preset:v llhq \
-rc:v cbr_ld_hq \
-an \
-f flv rtmp://tazj.in:1935/tvl
''

View file

@ -1,14 +0,0 @@
#!/usr/bin/env bash
env LD_LIBRARY_PATH=/run/opengl-driver/lib/ ffmpeg \
-vsync 0 \
-hwaccel cuvid \
-f x11grab \
-video_size 1920x1080 \
-framerate 60 \
-i :0.0+0,0 \
-vf "scale_npp=1280:720" \
-c:v h264_nvenc \
-preset fast \
-an \
-f flv rtmp://tazj.in:1935/tvl