Query ffmpeg version in s6 run script instead of subprocessing in every import

This commit is contained in:
Andrew Reiter 2023-07-04 09:22:26 -04:00
parent edb10330ee
commit 9a6bf3d167
3 changed files with 4 additions and 7 deletions

View File

@ -42,6 +42,8 @@ function migrate_db_path() {
fi
}
LIBAVFORMAT_VERSION_MAJOR=$(ffmpeg -version | grep -Po 'libavformat\W+\K\d+') || echo "[ERROR] Failed to determine ffmpeg version"
echo "[INFO] Preparing Frigate..."
migrate_db_path

View File

@ -9,7 +9,6 @@ import yaml
sys.path.insert(0, "/opt/frigate")
from frigate.const import BIRDSEYE_PIPE # noqa: E402
from frigate.ffmpeg_presets import ( # noqa: E402
LIBAVFORMAT_VERSION_MAJOR,
parse_preset_hardware_acceleration_encode,
)
@ -72,7 +71,7 @@ elif go2rtc_config["rtsp"].get("default_query") is None:
go2rtc_config["rtsp"]["default_query"] = "mp4"
# need to replace ffmpeg command when using ffmpeg4
if LIBAVFORMAT_VERSION_MAJOR < 59:
if int(os.environ['LIBAVFORMAT_VERSION_MAJOR']) < 59:
if go2rtc_config.get("ffmpeg") is None:
go2rtc_config["ffmpeg"] = {
"rtsp": "-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}"

View File

@ -2,7 +2,6 @@
import logging
import os
import subprocess
from enum import Enum
from typing import Any
@ -43,10 +42,7 @@ class LibvaGpuSelector:
return ""
LIBAVFORMAT_VERSION_MAJOR = int(
subprocess.getoutput("ffmpeg -version | grep -Po 'libavformat\W+\K\d+'")
)
TIMEOUT_PARAM = "-timeout" if LIBAVFORMAT_VERSION_MAJOR >= 59 else "-stimeout"
TIMEOUT_PARAM = "-timeout" if int(os.environ['LIBAVFORMAT_VERSION_MAJOR']) >= 59 else "-stimeout"
_gpu_selector = LibvaGpuSelector()
_user_agent_args = [