mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-04 18:25:22 +03:00
Correct HW accelerator usage for record output
This commit is contained in:
parent
4299f30dcd
commit
b14da7732c
@ -126,7 +126,7 @@ PRESETS_HW_ACCEL_SCALE = {
|
|||||||
"preset-intel-qsv-h265": "-r {0} -vf vpp_qsv=framerate={0}:{3}w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
"preset-intel-qsv-h265": "-r {0} -vf vpp_qsv=framerate={0}:{3}w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
||||||
"preset-nvidia-h264": "-r {0} -vf fps={0},{3}scale_cuda=w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
"preset-nvidia-h264": "-r {0} -vf fps={0},{3}scale_cuda=w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
||||||
"preset-nvidia-h265": "-r {0} -vf fps={0},{3}scale_cuda=w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
"preset-nvidia-h265": "-r {0} -vf fps={0},{3}scale_cuda=w={1}:h={2}:format=nv12,hwdownload,format=nv12,format=yuv420p",
|
||||||
"default": "-r {0} -s {1}x{2}",
|
"default": "-r {0}{3} -s {1}x{2}",
|
||||||
}
|
}
|
||||||
|
|
||||||
PRESETS_HW_ACCEL_SCALE_ROTATION = {
|
PRESETS_HW_ACCEL_SCALE_ROTATION = {
|
||||||
@ -218,7 +218,7 @@ def parse_preset_hardware_acceleration_scale(
|
|||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
"""Return the correct scaling preset or default preset if none is set."""
|
"""Return the correct scaling preset or default preset if none is set."""
|
||||||
if not isinstance(arg, str) or " " in arg:
|
if not isinstance(arg, str) or " " in arg:
|
||||||
scale = PRESETS_HW_ACCEL_SCALE["default"].format(fps, width, height).split(" ")
|
scale = PRESETS_HW_ACCEL_SCALE["default"].format(fps, width, height, "").split(" ")
|
||||||
scale.extend(detect_args)
|
scale.extend(detect_args)
|
||||||
return scale
|
return scale
|
||||||
|
|
||||||
@ -432,6 +432,8 @@ def parse_preset_output_record(arg: Any, hw_acc: Any, rotate: int) -> list[str]:
|
|||||||
"""Return the correct preset if in preset format otherwise return None."""
|
"""Return the correct preset if in preset format otherwise return None."""
|
||||||
if not isinstance(arg, str):
|
if not isinstance(arg, str):
|
||||||
return None
|
return None
|
||||||
|
if not isinstance(hw_acc, str):
|
||||||
|
hw_acc = "default"
|
||||||
|
|
||||||
preset_record_video_audio = PRESETS_RECORD_VIDEO_AUDIO.get(arg, None)
|
preset_record_video_audio = PRESETS_RECORD_VIDEO_AUDIO.get(arg, None)
|
||||||
if not preset_record_video_audio:
|
if not preset_record_video_audio:
|
||||||
|
|||||||
@ -420,13 +420,26 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
] = "preset-record-mjpeg"
|
] = "preset-record-mjpeg"
|
||||||
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
||||||
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
||||||
assert "preset-record-generic-audio-aac" not in (
|
assert "preset-record-mjpeg" not in (
|
||||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||||
)
|
)
|
||||||
assert "-c:v h264_v4l2m2m -an" in (
|
assert "-c:v h264_v4l2m2m -an" in (
|
||||||
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_ffmpeg_output_record_preset_no_hw_accel(self):
|
||||||
|
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-mjpeg" not in (
|
||||||
|
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||||
|
)
|
||||||
|
assert "-c:v libx264 -an" in (
|
||||||
|
" ".join(frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"])
|
||||||
|
)
|
||||||
|
|
||||||
def test_ffmpeg_output_rtmp_preset(self):
|
def test_ffmpeg_output_rtmp_preset(self):
|
||||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["output_args"][
|
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["output_args"][
|
||||||
"rtmp"
|
"rtmp"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user