mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-04-10 01:15:54 +02:00
Update ffmpeg to 7 and update intel hwaccel docs (#13834)
* Update ffmpeg to 7 and update intel hwaccel docs * Formatting * Redo early gen naming * Add gamma back in * Fix table * Add link to intel docs * Add hwaccel arg for disabling gamma * Formatting * Fix tests * Formatting * Fix nvidia
This commit is contained in:
parent
27e71eb142
commit
d498fabe72
@ -40,25 +40,25 @@ apt-get -qq install --no-install-recommends --no-install-suggests -y \
|
|||||||
# btbn-ffmpeg -> amd64
|
# btbn-ffmpeg -> amd64
|
||||||
if [[ "${TARGETARCH}" == "amd64" ]]; then
|
if [[ "${TARGETARCH}" == "amd64" ]]; then
|
||||||
mkdir -p /usr/lib/ffmpeg/5.0
|
mkdir -p /usr/lib/ffmpeg/5.0
|
||||||
mkdir -p /usr/lib/ffmpeg/6.0
|
mkdir -p /usr/lib/ffmpeg/7.0
|
||||||
wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linux64-gpl-5.1.tar.xz"
|
wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linux64-gpl-5.1.tar.xz"
|
||||||
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/5.0 --strip-components 1
|
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/5.0 --strip-components 1
|
||||||
rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/5.0/doc /usr/lib/ffmpeg/5.0/bin/ffplay
|
rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/5.0/doc /usr/lib/ffmpeg/5.0/bin/ffplay
|
||||||
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-08-31-12-50/ffmpeg-n6.1.2-2-gb534cc666e-linux64-gpl-6.1.tar.xz"
|
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-19-12-51/ffmpeg-n7.0.2-18-g3e6cec1286-linux64-gpl-7.0.tar.xz"
|
||||||
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/6.0 --strip-components 1
|
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/7.0 --strip-components 1
|
||||||
rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/6.0/doc /usr/lib/ffmpeg/6.0/bin/ffplay
|
rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/7.0/doc /usr/lib/ffmpeg/7.0/bin/ffplay
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ffmpeg -> arm64
|
# ffmpeg -> arm64
|
||||||
if [[ "${TARGETARCH}" == "arm64" ]]; then
|
if [[ "${TARGETARCH}" == "arm64" ]]; then
|
||||||
mkdir -p /usr/lib/ffmpeg/5.0
|
mkdir -p /usr/lib/ffmpeg/5.0
|
||||||
mkdir -p /usr/lib/ffmpeg/6.0
|
mkdir -p /usr/lib/ffmpeg/7.0
|
||||||
wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linuxarm64-gpl-5.1.tar.xz"
|
wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linuxarm64-gpl-5.1.tar.xz"
|
||||||
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/5.0 --strip-components 1
|
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/5.0 --strip-components 1
|
||||||
rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/5.0/doc /usr/lib/ffmpeg/5.0/bin/ffplay
|
rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/5.0/doc /usr/lib/ffmpeg/5.0/bin/ffplay
|
||||||
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-08-31-12-50/ffmpeg-n6.1.2-2-gb534cc666e-linuxarm64-gpl-6.1.tar.xz"
|
wget -qO btbn-ffmpeg.tar.xz "hhttps://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-19-12-51/ffmpeg-n7.0.2-18-g3e6cec1286-linuxarm64-gpl-7.0.tar.xz"
|
||||||
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/6.0 --strip-components 1
|
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/7.0 --strip-components 1
|
||||||
rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/6.0/doc /usr/lib/ffmpeg/6.0/bin/ffplay
|
rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/7.0/doc /usr/lib/ffmpeg/7.0/bin/ffplay
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# arch specific packages
|
# arch specific packages
|
||||||
|
@ -9,10 +9,12 @@ from pathlib import Path
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
sys.path.insert(0, "/opt/frigate")
|
sys.path.insert(0, "/opt/frigate")
|
||||||
from frigate.const import BIRDSEYE_PIPE # noqa: E402
|
from frigate.const import (
|
||||||
from frigate.ffmpeg_presets import ( # noqa: E402
|
BIRDSEYE_PIPE,
|
||||||
parse_preset_hardware_acceleration_encode,
|
DEFAULT_FFMPEG_VERSION,
|
||||||
|
INCLUDED_FFMPEG_VERSIONS,
|
||||||
)
|
)
|
||||||
|
from frigate.ffmpeg_presets import parse_preset_hardware_acceleration_encode
|
||||||
|
|
||||||
sys.path.remove("/opt/frigate")
|
sys.path.remove("/opt/frigate")
|
||||||
|
|
||||||
@ -110,13 +112,11 @@ else:
|
|||||||
path = config.get("ffmpeg", {}).get("path", "default")
|
path = config.get("ffmpeg", {}).get("path", "default")
|
||||||
if path == "default":
|
if path == "default":
|
||||||
if shutil.which("ffmpeg") is None:
|
if shutil.which("ffmpeg") is None:
|
||||||
ffmpeg_path = "/usr/lib/ffmpeg/6.0/bin/ffmpeg"
|
ffmpeg_path = f"/usr/lib/ffmpeg/{DEFAULT_FFMPEG_VERSION}/bin/ffmpeg"
|
||||||
else:
|
else:
|
||||||
ffmpeg_path = "ffmpeg"
|
ffmpeg_path = "ffmpeg"
|
||||||
elif path == "6.0":
|
elif path in INCLUDED_FFMPEG_VERSIONS:
|
||||||
ffmpeg_path = "/usr/lib/ffmpeg/6.0/bin/ffmpeg"
|
ffmpeg_path = f"/usr/lib/ffmpeg/{path}/bin/ffmpeg"
|
||||||
elif path == "5.0":
|
|
||||||
ffmpeg_path = "/usr/lib/ffmpeg/5.0/bin/ffmpeg"
|
|
||||||
else:
|
else:
|
||||||
ffmpeg_path = f"{path}/bin/ffmpeg"
|
ffmpeg_path = f"{path}/bin/ffmpeg"
|
||||||
|
|
||||||
|
@ -24,3 +24,4 @@ RUN rm -rf /usr/lib/btbn-ffmpeg/bin/ffmpeg
|
|||||||
RUN rm -rf /usr/lib/btbn-ffmpeg/bin/ffprobe
|
RUN rm -rf /usr/lib/btbn-ffmpeg/bin/ffprobe
|
||||||
ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffmpeg /usr/lib/ffmpeg/6.0/bin/
|
ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffmpeg /usr/lib/ffmpeg/6.0/bin/
|
||||||
ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffprobe /usr/lib/ffmpeg/6.0/bin/
|
ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffprobe /usr/lib/ffmpeg/6.0/bin/
|
||||||
|
ENV PATH="/usr/lib/ffmpeg/6.0/bin/:${PATH}"
|
||||||
|
@ -65,24 +65,33 @@ Or map in all the `/dev/video*` devices.
|
|||||||
|
|
||||||
## Intel-based CPUs
|
## Intel-based CPUs
|
||||||
|
|
||||||
|
**Recommended hwaccel Preset**
|
||||||
|
|
||||||
|
| CPU Generation | Intel Driver | Recommended Preset | Notes |
|
||||||
|
| -------------- | ------------ | ------------------ | ----------------------------------- |
|
||||||
|
| gen1 - gen7 | i965 | preset-vaapi | qsv is not supported |
|
||||||
|
| gen8 - gen12 | iHD | preset-vaapi | preset-intel-qsv-* can also be used |
|
||||||
|
| gen13+ | iHD / Xe | preset-intel-qsv-* | |
|
||||||
|
| Intel Arc GPU | iHD / Xe | preset-intel-qsv-* | |
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
The default driver is `iHD`. You may need to change the driver to `i965` by adding the following environment variable `LIBVA_DRIVER_NAME=i965` to your docker-compose file or [in the `frigate.yaml` for HA OS users](advanced.md#environment_vars).
|
||||||
|
|
||||||
|
See [The Intel Docs](https://www.intel.com/content/www/us/en/support/articles/000005505/processors.html to figure out what generation your CPU is.)
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
### Via VAAPI
|
### Via VAAPI
|
||||||
|
|
||||||
VAAPI supports automatic profile selection so it will work automatically with both H.264 and H.265 streams. VAAPI is recommended for all generations of Intel-based CPUs.
|
VAAPI supports automatic profile selection so it will work automatically with both H.264 and H.265 streams.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
ffmpeg:
|
ffmpeg:
|
||||||
hwaccel_args: preset-vaapi
|
hwaccel_args: preset-vaapi
|
||||||
```
|
```
|
||||||
|
|
||||||
:::note
|
### Via Quicksync
|
||||||
|
|
||||||
With some of the processors, like the J4125, the default driver `iHD` doesn't seem to work correctly for hardware acceleration. You may need to change the driver to `i965` by adding the following environment variable `LIBVA_DRIVER_NAME=i965` to your docker-compose file or [in the `frigate.yaml` for HA OS users](advanced.md#environment_vars).
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
### Via Quicksync (>=10th Generation only)
|
|
||||||
|
|
||||||
If VAAPI does not work for you, you can try QSV if your processor supports it. QSV must be set specifically based on the video encoding of the stream.
|
|
||||||
|
|
||||||
#### H.264 streams
|
#### H.264 streams
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ from frigate.const import (
|
|||||||
CACHE_DIR,
|
CACHE_DIR,
|
||||||
CACHE_SEGMENT_FORMAT,
|
CACHE_SEGMENT_FORMAT,
|
||||||
DEFAULT_DB_PATH,
|
DEFAULT_DB_PATH,
|
||||||
|
DEFAULT_FFMPEG_VERSION,
|
||||||
FREQUENCY_STATS_POINTS,
|
FREQUENCY_STATS_POINTS,
|
||||||
|
INCLUDED_FFMPEG_VERSIONS,
|
||||||
MAX_PRE_CAPTURE,
|
MAX_PRE_CAPTURE,
|
||||||
REGEX_CAMERA_NAME,
|
REGEX_CAMERA_NAME,
|
||||||
YAML_EXT,
|
YAML_EXT,
|
||||||
@ -896,27 +898,23 @@ class FfmpegConfig(FrigateBaseModel):
|
|||||||
def ffmpeg_path(self) -> str:
|
def ffmpeg_path(self) -> str:
|
||||||
if self.path == "default":
|
if self.path == "default":
|
||||||
if shutil.which("ffmpeg") is None:
|
if shutil.which("ffmpeg") is None:
|
||||||
return "/usr/lib/ffmpeg/6.0/bin/ffmpeg"
|
return f"/usr/lib/ffmpeg/{DEFAULT_FFMPEG_VERSION}/bin/ffmpeg"
|
||||||
else:
|
else:
|
||||||
return "ffmpeg"
|
return "ffmpeg"
|
||||||
elif self.path == "6.0":
|
elif self.path in INCLUDED_FFMPEG_VERSIONS:
|
||||||
return "/usr/lib/ffmpeg/6.0/bin/ffmpeg"
|
return f"/usr/lib/ffmpeg/{self.path}/bin/ffmpeg"
|
||||||
elif self.path == "5.0":
|
|
||||||
return "/usr/lib/ffmpeg/5.0/bin/ffmpeg"
|
|
||||||
else:
|
else:
|
||||||
return f"{self.path}/bin/ffmpeg"
|
return f"{self.path}/bin/ffmpeg"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ffprobe_path(self) -> str:
|
def ffprobe_path(self) -> str:
|
||||||
if self.path == "default":
|
if self.path == "default":
|
||||||
if int(os.getenv("LIBAVFORMAT_VERSION_MAJOR", "59")) >= 59:
|
if shutil.which("ffprobe") is None:
|
||||||
return "/usr/lib/ffmpeg/6.0/bin/ffprobe"
|
return f"/usr/lib/ffmpeg/{DEFAULT_FFMPEG_VERSION}/bin/ffprobe"
|
||||||
else:
|
else:
|
||||||
return "ffprobe"
|
return "ffprobe"
|
||||||
elif self.path == "6.0":
|
elif self.path in INCLUDED_FFMPEG_VERSIONS:
|
||||||
return "/usr/lib/ffmpeg/6.0/bin/ffprobe"
|
return f"/usr/lib/ffmpeg/{self.path}/bin/ffprobe"
|
||||||
elif self.path == "5.0":
|
|
||||||
return "/usr/lib/ffmpeg/5.0/bin/ffprobe"
|
|
||||||
else:
|
else:
|
||||||
return f"{self.path}/bin/ffprobe"
|
return f"{self.path}/bin/ffprobe"
|
||||||
|
|
||||||
|
@ -43,8 +43,10 @@ AUDIO_MIN_CONFIDENCE = 0.5
|
|||||||
|
|
||||||
MAX_WAL_SIZE = 10 # MB
|
MAX_WAL_SIZE = 10 # MB
|
||||||
|
|
||||||
# Ffmpeg Presets
|
# Ffmpeg constants
|
||||||
|
|
||||||
|
DEFAULT_FFMPEG_VERSION = "7.0"
|
||||||
|
INCLUDED_FFMPEG_VERSIONS = ["7.0", "5.0"]
|
||||||
FFMPEG_HWACCEL_NVIDIA = "preset-nvidia"
|
FFMPEG_HWACCEL_NVIDIA = "preset-nvidia"
|
||||||
FFMPEG_HWACCEL_VAAPI = "preset-vaapi"
|
FFMPEG_HWACCEL_VAAPI = "preset-vaapi"
|
||||||
FFMPEG_HWACCEL_VULKAN = "preset-vulkan"
|
FFMPEG_HWACCEL_VULKAN = "preset-vulkan"
|
||||||
|
@ -91,10 +91,10 @@ PRESETS_HW_ACCEL_DECODE["preset-nvidia-mjpeg"] = PRESETS_HW_ACCEL_DECODE[
|
|||||||
PRESETS_HW_ACCEL_SCALE = {
|
PRESETS_HW_ACCEL_SCALE = {
|
||||||
"preset-rpi-64-h264": "-r {0} -vf fps={0},scale={1}:{2}",
|
"preset-rpi-64-h264": "-r {0} -vf fps={0},scale={1}:{2}",
|
||||||
"preset-rpi-64-h265": "-r {0} -vf fps={0},scale={1}:{2}",
|
"preset-rpi-64-h265": "-r {0} -vf fps={0},scale={1}:{2}",
|
||||||
FFMPEG_HWACCEL_VAAPI: "-r {0} -vf fps={0},scale_vaapi=w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
FFMPEG_HWACCEL_VAAPI: "-r {0} -vf fps={0},scale_vaapi=w={1}:h={2},hwdownload,format=nv12,eq=gamma=1.05",
|
||||||
"preset-intel-qsv-h264": "-r {0} -vf vpp_qsv=framerate={0}:w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
"preset-intel-qsv-h264": "-r {0} -vf vpp_qsv=framerate={0}:w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
||||||
"preset-intel-qsv-h265": "-r {0} -vf vpp_qsv=framerate={0}:w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
"preset-intel-qsv-h265": "-r {0} -vf vpp_qsv=framerate={0}:w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
||||||
FFMPEG_HWACCEL_NVIDIA: "-r {0} -vf fps={0},scale_cuda=w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
FFMPEG_HWACCEL_NVIDIA: "-r {0} -vf fps={0},scale_cuda=w={1}:h={2},hwdownload,format=nv12,eq=gamma=1.05",
|
||||||
"preset-jetson-h264": "-r {0}", # scaled in decoder
|
"preset-jetson-h264": "-r {0}", # scaled in decoder
|
||||||
"preset-jetson-h265": "-r {0}", # scaled in decoder
|
"preset-jetson-h265": "-r {0}", # scaled in decoder
|
||||||
"preset-rk-h264": "-r {0} -vf scale_rkrga=w={1}:h={2}:format=yuv420p:force_original_aspect_ratio=0,hwmap=mode=read,format=yuv420p",
|
"preset-rk-h264": "-r {0} -vf scale_rkrga=w={1}:h={2}:format=yuv420p:force_original_aspect_ratio=0,hwmap=mode=read,format=yuv420p",
|
||||||
@ -185,6 +185,15 @@ def parse_preset_hardware_acceleration_scale(
|
|||||||
else:
|
else:
|
||||||
scale = PRESETS_HW_ACCEL_SCALE.get(arg, PRESETS_HW_ACCEL_SCALE["default"])
|
scale = PRESETS_HW_ACCEL_SCALE.get(arg, PRESETS_HW_ACCEL_SCALE["default"])
|
||||||
|
|
||||||
|
if (
|
||||||
|
",hwdownload,format=nv12,eq=gamma=1.05" in scale
|
||||||
|
and os.environ.get("FFMPEG_DISABLE_GAMMA_EQUALIZER") is not None
|
||||||
|
):
|
||||||
|
scale.replace(
|
||||||
|
",hwdownload,format=nv12,eq=gamma=1.05",
|
||||||
|
":format=nv12,hwdownload,format=nv12,format=yuv420p",
|
||||||
|
)
|
||||||
|
|
||||||
scale = scale.format(fps, width, height).split(" ")
|
scale = scale.format(fps, width, height).split(" ")
|
||||||
scale.extend(detect_args)
|
scale.extend(detect_args)
|
||||||
return scale
|
return scale
|
||||||
|
@ -78,7 +78,7 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
"fps=10,scale_cuda=w=2560:h=1920:format=nv12,hwdownload,format=nv12,format=yuv420p"
|
"fps=10,scale_cuda=w=2560:h=1920,hwdownload,format=nv12,eq=gamma=1.05"
|
||||||
in (" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"]))
|
in (" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"]))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user