Skip to content

Instantly share code, notes, and snippets.

@morrolinux
Last active July 10, 2023 22:01
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save morrolinux/743aaa0ec933fa68a5b2f82e4308605e to your computer and use it in GitHub Desktop.
Save morrolinux/743aaa0ec933fa68a5b2f82e4308605e to your computer and use it in GitHub Desktop.
Schermo Wireless a bassa latenza
- Parzialmente ispirato a vari gist sparsi per il web
- Sto ancora facendo tuning dei parametri
# TRASMETTERE:
INTEL e AMD [VAAPI] (libva-mesa-driver):
ffmpeg -f x11grab -s 1920x1080 -framerate 60 -i $DISPLAY -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload,scale_vaapi=w=1920:h=1080' -c:v h264_vaapi -qp:v 26 -bf 0 -preset superfast -tune zerolatency -b:v 2000K -minrate 2000K -maxrate 2000K -bufsize 512k -f rawvideo udp://192.168.1.222:12345
NVIDIA (CUDA/NVENC/H264) STREAM:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -f x11grab -s 1920x1080 -i $DISPLAY -c:v h264_nvenc -zerolatency 1 -delay:v 0 -preset p1 -tune ull -b:v 2000k -bufsize 512k -maxrate 2000k -qmin 0 -temporal-aq 1 -rc-lookahead 0 -i_qfactor 0.75 -b_qfactor 1.1 -f rawvideo udp://192.168.1.222:12345
NVIDIA (CUDA/NVENC/H265) STREAM:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -f x11grab -s 1920x1080 -i $DISPLAY -c:v hevc_nvenc -profile 0 -zerolatency 1 -delay:v 0 -preset p1 -tune ull -b:v 2000k -bufsize 512k -maxrate 2000k -qmin 0 -temporal-aq 1 -rc-lookahead 0 -i_qfactor 0.75 -b_qfactor 1.1 -f rawvideo udp://192.168.1.222:12345
SOLO CPU (Maggiore latenza)
ffmpeg -f x11grab -s 1920x1080 -framerate 30 -i $DISPLAY -c:v libx264 -profile:v baseline -trellis 0 -subq 1 -level 32 -preset superfast -tune zerolatency -crf 30 -threads 0 -bufsize 1 -refs 4 -coder 0 -b_strategy 0 -bf 0 -sc_threshold 0 -x264-params vbv-maxrate=2000:slice-max-size=1500:keyint=30:min-keyint=10: -pix_fmt yuv420p -an -f rawvideo udp://192.168.1.222:12345
NB1: con più GPU potrebbe essere necessario impostare il driver: LIBVA_DRIVER_NAME=radeonsi (amd) , vdpau(NVIDIA), i965 (Intel)...
NB2: $DISPLAY al posto di :0.0 è più flessibile (se impostata)
NB3: Sostituisci l'IP con quello del PC che userai come schermo
# RICEVERE (meglio se fatto partire prima):
mpv --no-cache --untimed --no-demuxer-thread --vd-lavc-threads=1 udp://127.0.0.1:12345?overrun_nonfatal=1
# CREARE UNO SCHERMO VIRTUALE AGGIUNTIVO:
xrandr --addmode VIRTUAL1 1920x1080
xrandr --output VIRTUAL1 --mode 1920x1080 --left-of eDP1
@MarcoFanti89
Copy link

MarcoFanti89 commented Feb 22, 2022

Un consiglio sulla migliore app che si potrebbe usare per "ricevere" su un tablet android?
(so che in teoria si può usare termux+anlinux e lì far girare mpv, ma mi sembra un po' overkill)

@NF02
Copy link

NF02 commented Mar 14, 2022

Se serve un front end ci potrebbero essere delle idee utili

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment