mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-04 18:25:22 +03:00
Add hw acceleration capacity to record output.
This commit is contained in:
parent
ead1c36a87
commit
4049316305
@ -52,6 +52,17 @@ _user_agent_args = [
|
||||
f"FFmpeg Frigate/{VERSION}",
|
||||
]
|
||||
|
||||
PRESETS_FFMPEG_HW_ACCEL = {
|
||||
"preset-rpi-32-h264": "h264_v4l2m2m",
|
||||
"preset-rpi-64-h264": "h264_v4l2m2m",
|
||||
"preset-vaapi": "h264_vaapi",
|
||||
"preset-intel-qsv-h264": "h264_qsv", # From Sandy Bridge (gen 6)
|
||||
"preset-intel-qsv-h265": "h264_qsv", # From Sandy Bridge (gen 6)
|
||||
"preset-nvidia-h264": "h264_nvenc",
|
||||
"preset-nvidia-h265": "h264_nvenc",
|
||||
"default": "libx264", # SW codecs
|
||||
}
|
||||
|
||||
PRESETS_HW_ACCEL_DECODE = {
|
||||
"preset-rpi-32-h264": ["-c:v", "h264_v4l2m2m"],
|
||||
"preset-rpi-64-h264": ["-c:v", "h264_v4l2m2m"],
|
||||
@ -430,8 +441,9 @@ def parse_preset_output_record(arg: Any, hw_acc: Any, rotate: int) -> list[str]:
|
||||
|
||||
video = preset_record_video_audio["video"]
|
||||
transpose =_parse_rotation_scale(hw_acc, "record", rotate)
|
||||
if transpose != "":
|
||||
video = transpose + " -c:v libx264"
|
||||
if transpose != "" or not "copy" in video:
|
||||
encode = PRESETS_FFMPEG_HW_ACCEL.get(hw_acc, "libx264")
|
||||
video = transpose + " -c:v " + encode
|
||||
|
||||
return PRESETS_RECORD_OUTPUT.format(video, audio).split(" ")
|
||||
|
||||
|
||||
@ -307,7 +307,7 @@ class TestFfmpegPresets(unittest.TestCase):
|
||||
assert "preset-record-generic-audio-aac" not in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
assert "-vf transpose=clock -c:v libx264 -c:a aac" in (
|
||||
assert "-vf transpose=clock -c:v h264_nvenc -c:a aac" in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
|
||||
@ -327,7 +327,7 @@ class TestFfmpegPresets(unittest.TestCase):
|
||||
assert "preset-rpi-64-h264" not in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
assert "-vf transpose=clock,transpose=clock -c:v libx264 -c:a aac" in (
|
||||
assert "-vf transpose=clock,transpose=clock -c:v h264_v4l2m2m -c:a aac" in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
|
||||
@ -347,7 +347,7 @@ class TestFfmpegPresets(unittest.TestCase):
|
||||
assert "preset-vaapi" not in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
assert "-vf transpose_vaapi=reverse -c:v libx264 -c:a aac" in (
|
||||
assert "-vf transpose_vaapi=reverse -c:v h264_vaapi -c:a aac" in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
|
||||
@ -367,7 +367,7 @@ class TestFfmpegPresets(unittest.TestCase):
|
||||
assert "preset-intel-qsv-h264" not in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
assert "-vf vpp_qsv=transpose=reverse -c:v libx264 -c:a aac" in (
|
||||
assert "-vf vpp_qsv=transpose=reverse -c:v h264_qsv -c:a aac" in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
|
||||
@ -387,7 +387,7 @@ class TestFfmpegPresets(unittest.TestCase):
|
||||
assert "preset-nvidia-h264" not in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
assert "-vf transpose=cclock -c:v libx264 -c:a aac" in (
|
||||
assert "-vf transpose=cclock -c:v h264_nvenc -c:a aac" in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
|
||||
@ -411,6 +411,22 @@ class TestFfmpegPresets(unittest.TestCase):
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
|
||||
def test_ffmpeg_output_record_preset_hw_accel(self):
|
||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"][
|
||||
"hwaccel_args"
|
||||
] = "preset-rpi-32-h264"
|
||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["output_args"][
|
||||
"record"
|
||||
] = "preset-record-mjpeg"
|
||||
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
||||
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
||||
assert "preset-record-generic-audio-aac" not in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
assert "-c:v h264_v4l2m2m -an" in (
|
||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||
)
|
||||
|
||||
def test_ffmpeg_output_rtmp_preset(self):
|
||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["output_args"][
|
||||
"rtmp"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user