mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
Add handling of encode engine and video codec
This commit is contained in:
parent
9791246895
commit
e5038b958b
@ -230,6 +230,15 @@ PRESETS_HW_ACCEL_ENCODE = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRESETS_HW_ACCEL_GO2RTC_ENGINE = {
|
||||||
|
"preset-intel-vaapi": "vaapi",
|
||||||
|
"preset-intel-qsv-h264": "vaapi", # go2rtc doesn't support qsv
|
||||||
|
"preset-intel-qsv-h265": "vaapi",
|
||||||
|
"preset-amd-vaapi": "vaapi",
|
||||||
|
"preset-nvidia-h264": "cuda",
|
||||||
|
"preset-nvidia-h265": "cuda",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def parse_preset_hardware_acceleration_decode(arg: Any) -> list[str]:
|
def parse_preset_hardware_acceleration_decode(arg: Any) -> list[str]:
|
||||||
"""Return the correct preset if in preset format otherwise return None."""
|
"""Return the correct preset if in preset format otherwise return None."""
|
||||||
@ -267,6 +276,14 @@ def parse_preset_hardware_acceleration_encode(arg: Any) -> list[str]:
|
|||||||
return PRESETS_HW_ACCEL_ENCODE.get(arg, PRESETS_HW_ACCEL_ENCODE["default"])
|
return PRESETS_HW_ACCEL_ENCODE.get(arg, PRESETS_HW_ACCEL_ENCODE["default"])
|
||||||
|
|
||||||
|
|
||||||
|
def parse_preset_hardware_acceleration_go2rtc_engine(arg: Any) -> list[str]:
|
||||||
|
"""Return the correct engine for the preset otherwise returns None."""
|
||||||
|
if not isinstance(arg, str):
|
||||||
|
return None
|
||||||
|
|
||||||
|
return PRESETS_HW_ACCEL_GO2RTC_ENGINE.get(arg)
|
||||||
|
|
||||||
|
|
||||||
PRESETS_INPUT = {
|
PRESETS_INPUT = {
|
||||||
"preset-http-jpeg-generic": _user_agent_args
|
"preset-http-jpeg-generic": _user_agent_args
|
||||||
+ [
|
+ [
|
||||||
|
|||||||
@ -3,18 +3,33 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
from frigate.util import escape_special_characters
|
|
||||||
|
|
||||||
from frigate.config import FrigateConfig
|
from typing import Optional
|
||||||
|
|
||||||
|
from frigate.config import FrigateConfig, RestreamCodecEnum
|
||||||
from frigate.const import BIRDSEYE_PIPE
|
from frigate.const import BIRDSEYE_PIPE
|
||||||
from frigate.ffmpeg_presets import parse_preset_hardware_acceleration_encode
|
from frigate.ffmpeg_presets import (
|
||||||
|
parse_preset_hardware_acceleration_encode,
|
||||||
|
parse_preset_hardware_acceleration_go2rtc_engine,
|
||||||
|
)
|
||||||
|
from frigate.util import escape_special_characters
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_manual_go2rtc_stream(camera_url: str) -> str:
|
def get_manual_go2rtc_stream(
|
||||||
|
camera_url: str, codec: RestreamCodecEnum, engine: Optional[str]
|
||||||
|
) -> str:
|
||||||
"""Get a manual stream for go2rtc."""
|
"""Get a manual stream for go2rtc."""
|
||||||
return f"ffmpeg:{camera_url}#video=copy#audio=aac#audio=opus"
|
if codec == RestreamCodecEnum.copy:
|
||||||
|
return f"ffmpeg:{camera_url}#video=copy#audio=aac#audio=opus"
|
||||||
|
|
||||||
|
if engine:
|
||||||
|
return (
|
||||||
|
f"ffmpeg:{camera_url}#video={codec}#hardware={engine}#audio=aac#audio=opus"
|
||||||
|
)
|
||||||
|
|
||||||
|
return f"ffmpeg:{camera_url}#video={codec}#audio=aac#audio=opus"
|
||||||
|
|
||||||
|
|
||||||
class RestreamApi:
|
class RestreamApi:
|
||||||
@ -41,7 +56,13 @@ class RestreamApi:
|
|||||||
else:
|
else:
|
||||||
# go2rtc only supports rtsp for direct relay, otherwise ffmpeg is used
|
# go2rtc only supports rtsp for direct relay, otherwise ffmpeg is used
|
||||||
self.relays[cam_name] = get_manual_go2rtc_stream(
|
self.relays[cam_name] = get_manual_go2rtc_stream(
|
||||||
escape_special_characters(input.path)
|
escape_special_characters(
|
||||||
|
input.path,
|
||||||
|
camera.restream.video_codec,
|
||||||
|
parse_preset_hardware_acceleration_go2rtc_engine(
|
||||||
|
self.config.ffmpeg.hwaccel_args
|
||||||
|
),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.config.restream.birdseye:
|
if self.config.restream.birdseye:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user