mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-21 00:06:44 +01:00
Fix raspberry pi hwaccel (#4955)
* use ffmpeg from raspbian repo * dynamically choose timeout param * invert logic * Add hwaccel presets for rpi Co-authored-by: Nick Mowen <nickmowen213@gmail.com>
This commit is contained in:
parent
bcbf0061ff
commit
1f963ec5aa
@ -12,10 +12,7 @@ apt-get -qq install --no-install-recommends -y \
|
||||
unzip locales tzdata libxml2 xz-utils \
|
||||
python3-pip
|
||||
|
||||
# add raspberry pi repo
|
||||
mkdir -p -m 600 /root/.gnupg
|
||||
gpg --no-default-keyring --keyring /usr/share/keyrings/raspbian.gpg --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E
|
||||
echo "deb [signed-by=/usr/share/keyrings/raspbian.gpg] http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi" | tee /etc/apt/sources.list.d/raspi.list
|
||||
|
||||
# add coral repo
|
||||
wget --quiet -O /usr/share/keyrings/google-edgetpu.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
|
||||
@ -30,13 +27,9 @@ apt-get -qq update
|
||||
apt-get -qq install --no-install-recommends --no-install-suggests -y \
|
||||
libedgetpu1-max python3-tflite-runtime python3-pycoral
|
||||
|
||||
# btbn-ffmpeg -> amd64 / arm64
|
||||
if [[ "${TARGETARCH}" == "amd64" || "${TARGETARCH}" == "arm64" ]]; then
|
||||
if [[ "${TARGETARCH}" == "amd64" ]]; then
|
||||
btbn_arch="64"
|
||||
else
|
||||
btbn_arch="arm64"
|
||||
fi
|
||||
# btbn-ffmpeg -> amd64
|
||||
if [[ "${TARGETARCH}" == "amd64" ]]; then
|
||||
btbn_arch="arm64"
|
||||
mkdir -p /usr/lib/btbn-ffmpeg
|
||||
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linux${btbn_arch}-gpl-5.1.tar.xz"
|
||||
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1
|
||||
@ -45,6 +38,17 @@ fi
|
||||
|
||||
# ffmpeg -> arm32
|
||||
if [[ "${TARGETARCH}" == "arm" ]]; then
|
||||
# add raspberry pi repo
|
||||
gpg --no-default-keyring --keyring /usr/share/keyrings/raspbian.gpg --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E
|
||||
echo "deb [signed-by=/usr/share/keyrings/raspbian.gpg] http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi" | tee /etc/apt/sources.list.d/raspi.list
|
||||
apt-get -qq install --no-install-recommends --no-install-suggests -y ffmpeg
|
||||
fi
|
||||
|
||||
# ffmpeg -> arm64
|
||||
if [[ "${TARGETARCH}" == "arm64" ]]; then
|
||||
# add raspberry pi repo
|
||||
gpg --no-default-keyring --keyring /usr/share/keyrings/raspbian.gpg --keyserver keyserver.ubuntu.com --recv-keys 82B129927FA3303E
|
||||
echo "deb [signed-by=/usr/share/keyrings/raspbian.gpg] https://archive.raspberrypi.org/debian/ bullseye main" | tee /etc/apt/sources.list.d/raspi.list
|
||||
apt-get -qq install --no-install-recommends --no-install-suggests -y ffmpeg
|
||||
fi
|
||||
|
||||
|
@ -7,6 +7,7 @@ YAML_EXT = (".yaml", ".yml")
|
||||
PLUS_ENV_VAR = "PLUS_API_KEY"
|
||||
PLUS_API_HOST = "https://api.frigate.video"
|
||||
MAX_SEGMENT_DURATION = 600
|
||||
BTBN_PATH = "/usr/lib/btbn-ffmpeg"
|
||||
|
||||
# Regex Consts
|
||||
|
||||
|
@ -1,8 +1,13 @@
|
||||
"""Handles inserting and maintaining ffmpeg presets."""
|
||||
|
||||
import os
|
||||
|
||||
from typing import Any
|
||||
|
||||
from frigate.version import VERSION
|
||||
from frigate.const import BTBN_PATH
|
||||
|
||||
TIMEOUT_PARAM = "-timeout" if os.path.exists(BTBN_PATH) else "-stimeout"
|
||||
|
||||
_user_agent_args = [
|
||||
"-user_agent",
|
||||
@ -114,6 +119,8 @@ PRESETS_HW_ACCEL_SCALE = {
|
||||
}
|
||||
|
||||
PRESETS_HW_ACCEL_ENCODE = {
|
||||
"preset-rpi-32-h264": "ffmpeg -hide_banner {0} -c:v h264_v4l2m2m -g 50 -bf 0 {1}",
|
||||
"preset-rpi-64-h264": "ffmpeg -hide_banner {0} -c:v h264_v4l2m2m -g 50 -bf 0 {1}",
|
||||
"preset-intel-qsv-h264": "ffmpeg -hide_banner {0} -c:v h264_qsv -g 50 -bf 0 -profile:v high -level:v 4.1 -async_depth:v 1 {1}",
|
||||
"preset-intel-qsv-h265": "ffmpeg -hide_banner {0} -c:v h264_qsv -g 50 -bf 0 -profile:v high -level:v 4.1 -async_depth:v 1 {1}",
|
||||
"preset-nvidia-h264": "ffmpeg -hide_banner {0} -c:v h264_nvenc -g 50 -profile:v high -level:v auto -preset:v p2 -tune:v ll {1}",
|
||||
@ -122,6 +129,8 @@ PRESETS_HW_ACCEL_ENCODE = {
|
||||
}
|
||||
|
||||
PRESETS_HW_ACCEL_GO2RTC_ENGINE = {
|
||||
"preset-rpi-32-h264": "v4l2m2m",
|
||||
"preset-rpi-64-h264": "v4l2m2m",
|
||||
"preset-intel-vaapi": "vaapi",
|
||||
"preset-intel-qsv-h264": "vaapi", # go2rtc doesn't support qsv
|
||||
"preset-intel-qsv-h265": "vaapi",
|
||||
@ -258,7 +267,7 @@ PRESETS_INPUT = {
|
||||
"+genpts+discardcorrupt",
|
||||
"-rtsp_transport",
|
||||
"tcp",
|
||||
"-timeout",
|
||||
TIMEOUT_PARAM,
|
||||
"5000000",
|
||||
"-use_wallclock_as_timestamps",
|
||||
"1",
|
||||
@ -271,7 +280,7 @@ PRESETS_INPUT = {
|
||||
"+genpts+discardcorrupt",
|
||||
"-rtsp_transport",
|
||||
"udp",
|
||||
"-timeout",
|
||||
TIMEOUT_PARAM,
|
||||
"5000000",
|
||||
"-use_wallclock_as_timestamps",
|
||||
"1",
|
||||
@ -290,7 +299,7 @@ PRESETS_INPUT = {
|
||||
"+genpts+discardcorrupt",
|
||||
"-rtsp_transport",
|
||||
"tcp",
|
||||
"-timeout",
|
||||
TIMEOUT_PARAM,
|
||||
"5000000",
|
||||
"-use_wallclock_as_timestamps",
|
||||
"1",
|
||||
|
Loading…
Reference in New Issue
Block a user