redefine ffmpeg options for VAAPI

This commit is contained in:
deflax 2025-01-13 03:28:43 +02:00
parent 4a12f606bd
commit 0c37b86ea7
4 changed files with 24 additions and 16 deletions

View file

@ -7,5 +7,10 @@
`sudo apt install scrcpy`
`sudo apt install v4l2loopback-dkms`
v4l2loopback.conf:
### v4l2loopback.conf:
`options v4l2loopback video_nr=7 card_label="android video"`
### set wireless android camera pairing
1. enable wifi debugging
2. `adb pair 192.168.0.123:37xxx'
3. set the ip above inside the config file

View file

@ -1,9 +1,14 @@
#!/bin/bash
#
source config
adb connect ${android_camera}:$1
scrcpy \
--no-playback \
--no-control \
--capture-orientation=270 \
--video-source=camera \
--camera-id=$1 --camera-size=1920x1080 --camera-fps=30 \
--camera-id=2 --camera-size=1920x1080 --camera-fps=30 \
--v4l2-sink=/dev/video7

View file

@ -1 +1,2 @@
android_camera=192.168.0.123
srt_output="srt://CHANGEME:6000?mode=caller&transtype=live&pkt_size=1316&streamid=CHANGEME.stream,mode:publish,token:CHANGEME"

View file

@ -3,31 +3,28 @@
echo "Press CTRL+C to exit"
source config
echo ${srt_output}
LOGLEVEL=debug
while :
do
CURRENTDATE=`date +"%Y-%m-%d %T"`
echo Start at ${CURRENTDATE}
threads=12
# gpu
hwaccel="-hwaccel vaapi -vaapi_device /dev/dri/renderD128"
input_video_filter="-vf format=nv12,hwupload"
h264_vaapi="-c:v h264_vaapi -qp 18"
#cpu
#libx264="-c:v libx264"
#calf plugins
#input_audio_filter="-af lv2=p=http\\\\://calf.sourceforge.net/plugins/Gate:c=threshold=0.04010706|knee=8|range=0.03148599, lv2=http\\\\://calf.sourceforge.net/plugins/Compressor:c=knee=8|threshold=0.125, lv2=http\\\\://calf.sourceforge.net/plugins/Limiter:c=level_out=0.71697748|limit=0.62763602"
#load normalization
#output_audio_filter="-filter:a loudnorm"
ffmpeg -hide_banner -loglevel repeat+level+info ${hwaccel} -f v4l2 -framerate 30 -pix_fmt yuv420p -video_size 1920x1080 -i /dev/video7 -f alsa -thread_queue_size 24000000 -ar 44100 -i plughw:CARD=USB ${input_audio_filter} ${input_video_filter} -f mpegts ${h264_vaapi} ${libx264} -b:v 5500k -c:a aac -b:a 192k ${output_audio_filter} -ac 2 -ar 44100 -threads ${threads} -y ${srt_output}
ffmpeg -loglevel ${LOGLEVEL} -threads:v 2 -threads:a 8 -filter_threads 2 \
-thread_queue_size 512 -f v4l2 -s 1920x1080 -framerate 60 -pix_fmt yuv420p -i /dev/video7 \
-thread_queue_size 512 -f alsa -ac 2 -i plughw:CARD=USB ${input_audio_filter} \
-bsf:a aac_adtstoasc -c:a aac -ac 2 -b:a 128k ${output_audio_filter} \
-init_hw_device vaapi=amd:/dev/dri/renderD128 -filter_hw_device va \
-vf 'format=nv12,hwupload' \
-c:v h264_vaapi -b:v 6000k -minrate:v 6000k -maxrate:v 6000k -bufsize:v 6000k \
-r:v 60 -g:v 120 -bf:v 3 -refs:v 16 \
-f mpegts ${srt_output}
CURRENTDATE=`date +"%Y-%m-%d %T"`
echo End at ${CURRENTDATE}