Add HW acceleration to Neko config

If a ` /dev/dri/render*` device exists, enable vaapi encoding
This commit is contained in:
Josh.5
2022-09-17 19:35:30 +12:00
committed by Josh Sunnex
parent adac278106
commit f9149958bb
2 changed files with 24 additions and 1 deletions

View File

@@ -15,6 +15,18 @@ echo "Adding run user to video, audio, input and pulse groups"
usermod -a -G video,audio,input,pulse ${USER}
echo "Adding run user to render group (for HW accelerated encoding)"
render_guid=$(stat -c "%g" /dev/dri/render* | tail -n 1)
if [[ ! -z ${render_guid} ]]; then
render_group=$(getent group "${render_guid}" | cut -d: -f1)
if [[ -z ${render_group} ]]; then
groupadd -g "${render_guid}" "videorender"
render_group="videorender"
fi
usermod -a -G ${render_group} ${USER}
fi
echo "Setting umask to ${UMASK}";
umask ${UMASK}

View File

@@ -1,16 +1,27 @@
echo "**** Configure Neko ****"
# REF: https://neko.m1k1o.net/#/getting-started/configuration
if ([ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then
if [ ${WEB_UI_MODE} = "neko" ]; then
echo "Enable Neko server"
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/neko.ini
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/neko.ini
# Configure nat1to1 if it is not already set
if [[ -z ${NEKO_NAT1TO1} ]]; then
export NEKO_NAT1TO1=$(ip route get 1 | awk '{print $(NF-2);exit}')
echo "Setting NEKO_NAT1TO1=${NEKO_NAT1TO1}"
else
echo "User provided setting NEKO_NAT1TO1=${NEKO_NAT1TO1}"
fi
# Configure hardware acceleration if it is not already set
if [[ -z ${NEKO_HWENC} ]]; then
# Enable VAAPI if device available
if [[ ! -z $(stat -c "%g" /dev/dri/render* | tail -n 1) ]]; then
export NEKO_HWENC=vaapi
fi
fi
else
echo "Disable Neko server"
fi