mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-15 00:11:15 +03:00
fall back to tcp transport when rtsp probes fail over udp
This commit is contained in:
parent
b7261c8e70
commit
5a99634b96
@ -711,23 +711,31 @@ def ffprobe_stream(ffmpeg, path: str, detailed: bool = False) -> sp.CompletedPro
|
|||||||
else:
|
else:
|
||||||
format_entries = None
|
format_entries = None
|
||||||
|
|
||||||
ffprobe_cmd = [
|
def run(rtsp_transport: Optional[str] = None) -> sp.CompletedProcess:
|
||||||
ffmpeg.ffprobe_path,
|
cmd = [ffmpeg.ffprobe_path]
|
||||||
"-timeout",
|
if rtsp_transport:
|
||||||
"1000000",
|
cmd += ["-rtsp_transport", rtsp_transport]
|
||||||
"-print_format",
|
cmd += [
|
||||||
"json",
|
"-timeout",
|
||||||
"-show_entries",
|
"1000000",
|
||||||
f"stream={stream_entries}",
|
"-print_format",
|
||||||
]
|
"json",
|
||||||
|
"-show_entries",
|
||||||
|
f"stream={stream_entries}",
|
||||||
|
]
|
||||||
|
if detailed and format_entries:
|
||||||
|
cmd.extend(["-show_entries", f"format={format_entries}"])
|
||||||
|
cmd.extend(["-loglevel", "error", clean_path])
|
||||||
|
return sp.run(cmd, capture_output=True)
|
||||||
|
|
||||||
# Add format entries for detailed mode
|
result = run()
|
||||||
if detailed and format_entries:
|
|
||||||
ffprobe_cmd.extend(["-show_entries", f"format={format_entries}"])
|
|
||||||
|
|
||||||
ffprobe_cmd.extend(["-loglevel", "error", clean_path])
|
# For RTSP: retry with explicit TCP transport if the first attempt failed
|
||||||
|
# (default UDP may be blocked)
|
||||||
|
if result.returncode != 0 and clean_path.startswith("rtsp://"):
|
||||||
|
result = run(rtsp_transport="tcp")
|
||||||
|
|
||||||
return sp.run(ffprobe_cmd, capture_output=True)
|
return result
|
||||||
|
|
||||||
|
|
||||||
def vainfo_hwaccel(device_name: Optional[str] = None) -> sp.CompletedProcess:
|
def vainfo_hwaccel(device_name: Optional[str] = None) -> sp.CompletedProcess:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user