mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Add support for output arg presets
This commit is contained in:
parent
c6160181bb
commit
e67c9e7e83
@ -29,6 +29,8 @@ from frigate.util import (
|
||||
from frigate.ffmpeg_presets import (
|
||||
parse_preset_hardware_acceleration,
|
||||
parse_preset_input,
|
||||
parse_preset_output_record,
|
||||
parse_preset_output_rtmp,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -665,13 +667,13 @@ class CameraConfig(FrigateBaseModel):
|
||||
+ ["pipe:"]
|
||||
)
|
||||
if "rtmp" in ffmpeg_input.roles and self.rtmp.enabled:
|
||||
rtmp_args = get_ffmpeg_arg_list(self.ffmpeg.output_args.rtmp)
|
||||
rtmp_args = get_ffmpeg_arg_list(parse_preset_output_rtmp(self.ffmpeg.output_args.args.rtmp) or self.ffmpeg.output_args.rtmp)
|
||||
|
||||
ffmpeg_output_args = (
|
||||
rtmp_args + [f"rtmp://127.0.0.1/live/{self.name}"] + ffmpeg_output_args
|
||||
)
|
||||
if "record" in ffmpeg_input.roles and self.record.enabled:
|
||||
record_args = get_ffmpeg_arg_list(self.ffmpeg.output_args.record)
|
||||
record_args = get_ffmpeg_arg_list(parse_preset_output_record(self.ffmpeg.output_args.record) or self.ffmpeg.output_args.record)
|
||||
|
||||
ffmpeg_output_args = (
|
||||
record_args
|
||||
|
||||
@ -23,7 +23,7 @@ def parse_preset_hardware_acceleration(arg: Any) -> str:
|
||||
return PRESETS_HW_ACCEL.get(arg, None)
|
||||
|
||||
|
||||
PRESETS_INPUT_ARGS = {
|
||||
PRESETS_INPUT = {
|
||||
"preset-http-jpeg-generic": "-r {} -stream_loop -1 -f image2 -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1",
|
||||
"preset-http-mjpeg-generic": "-avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1",
|
||||
"preset-http-reolink": "-avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000",
|
||||
@ -40,6 +40,39 @@ def parse_preset_input(arg: Any, detect_fps: int) -> str:
|
||||
return None
|
||||
|
||||
if arg is "preset-jpeg-generic":
|
||||
return PRESETS_INPUT_ARGS[arg].format(f'{detect_fps}')
|
||||
return PRESETS_INPUT[arg].format(f'{detect_fps}')
|
||||
|
||||
return PRESETS_INPUT_ARGS.get(arg, None)
|
||||
return PRESETS_INPUT.get(arg, None)
|
||||
|
||||
|
||||
PRESETS_RECORD_OUTPUT = {
|
||||
"preset-record-generic": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an",
|
||||
"preset-record-generic-audio": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac",
|
||||
"preset-record-mjpeg": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an",
|
||||
"preset-record-jpeg": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an",
|
||||
"preset-record-ubiquiti": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -ar 44100 -c:a aac",
|
||||
}
|
||||
|
||||
|
||||
def parse_preset_output_record(arg: Any) -> str:
|
||||
"""Return the correct preset if in preset format otherwise return raw input."""
|
||||
if not isinstance(arg, str):
|
||||
return None
|
||||
|
||||
return PRESETS_RECORD_OUTPUT.get(arg, None)
|
||||
|
||||
|
||||
PRESETS_RTMP_OUTPUT = {
|
||||
"preset-rtmp-generic": "-c copy -f flv",
|
||||
"preset-rtmp-mjpeg": "-c:v libx264 -an -f flv",
|
||||
"preset-rtmp-jpeg": "-c:v libx264 -an -f flv",
|
||||
"preset-rtmp-ubiquiti": "-c:v copy -f flv -ar 44100 -c:a aac",
|
||||
}
|
||||
|
||||
|
||||
def parse_preset_output_rtmp(arg: Any, detect_fps: int) -> str:
|
||||
"""Return the correct preset if in preset format otherwise return raw input."""
|
||||
if not isinstance(arg, str):
|
||||
return None
|
||||
|
||||
return PRESETS_RTMP_OUTPUT.get(arg, None)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user