mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
support multiple rtsp/rtmp URI schemes
This commit is contained in:
parent
1240a073c9
commit
265c400234
@ -1,12 +1,11 @@
|
|||||||
|
import re
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
from xmlrpc.client import Boolean
|
|
||||||
|
|
||||||
from matplotlib.style import available
|
|
||||||
from frigate.const import (
|
from frigate.const import (
|
||||||
CACHE_DIR,
|
CACHE_DIR,
|
||||||
GSTREAMER_RECORD_SUFFIX,
|
GSTREAMER_RECORD_SUFFIX,
|
||||||
@ -124,8 +123,8 @@ class GstreamerBaseBuilder:
|
|||||||
"""
|
"""
|
||||||
Set RTMP or RTSP data source with the list of options
|
Set RTMP or RTSP data source with the list of options
|
||||||
"""
|
"""
|
||||||
is_rtsp = "rtsp://" in uri
|
is_rtsp = re.match(r"rtsps?:\/\/", uri)
|
||||||
is_rtmp = "rtmp://" in uri
|
is_rtmp = re.match(r"rtm(p|pt|ps|pe|fp|pte|pts)?:\/\/", uri)
|
||||||
if is_rtsp:
|
if is_rtsp:
|
||||||
self.input_pipeline = f'rtspsrc location="{uri}"'
|
self.input_pipeline = f'rtspsrc location="{uri}"'
|
||||||
elif is_rtmp:
|
elif is_rtmp:
|
||||||
@ -198,7 +197,7 @@ class GstreamerBaseBuilder:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def accept(plugins: List[str]) -> Boolean:
|
def accept(plugins: List[str]) -> bool:
|
||||||
"""
|
"""
|
||||||
Accept method receives a list of plugins and return true if the builder can hande the current list
|
Accept method receives a list of plugins and return true if the builder can hande the current list
|
||||||
Builder should check all necessary pluguns before returning True
|
Builder should check all necessary pluguns before returning True
|
||||||
@ -272,7 +271,7 @@ class GstreamerBaseBuilder:
|
|||||||
def get_detect_decoder_pipeline(self) -> List[str]:
|
def get_detect_decoder_pipeline(self) -> List[str]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _build(self, use_detect: Boolean, use_record: Boolean) -> List[str]:
|
def _build(self, use_detect: bool, use_record: bool) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Build a pipeline based on the provided parameters
|
Build a pipeline based on the provided parameters
|
||||||
"""
|
"""
|
||||||
@ -309,7 +308,7 @@ class GstreamerBaseBuilder:
|
|||||||
pipeline, use_detect=use_detect, use_record=use_record
|
pipeline, use_detect=use_detect, use_record=use_record
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, use_detect: Boolean, use_record: Boolean) -> List[str]:
|
def build(self, use_detect: bool, use_record: bool) -> List[str]:
|
||||||
if self.raw_pipeline is None or len(self.raw_pipeline) == 0:
|
if self.raw_pipeline is None or len(self.raw_pipeline) == 0:
|
||||||
full_pipeline = self._build(use_detect, use_record)
|
full_pipeline = self._build(use_detect, use_record)
|
||||||
else:
|
else:
|
||||||
@ -327,7 +326,7 @@ class GstreamerNvidia(GstreamerBaseBuilder):
|
|||||||
super().__init__(width, height, name, format)
|
super().__init__(width, height, name, format)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def accept(plugins: List[str]) -> Boolean:
|
def accept(plugins: List[str]) -> bool:
|
||||||
"""
|
"""
|
||||||
Accept method receives a list of plugins and return true if the builder can hande the current list
|
Accept method receives a list of plugins and return true if the builder can hande the current list
|
||||||
Builder should check all necessary pluguns before returning True
|
Builder should check all necessary pluguns before returning True
|
||||||
|
|||||||
@ -149,6 +149,13 @@ class TestGstreamerBaseBuilder(TestCase):
|
|||||||
'rtspsrc location="rtsp://some/path1" name=rtp_stream latency=0 do-timestamp=true'
|
'rtspsrc location="rtsp://some/path1" name=rtp_stream latency=0 do-timestamp=true'
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"rtsps://some/path1",
|
||||||
|
None,
|
||||||
|
[
|
||||||
|
'rtspsrc location="rtsps://some/path1" name=rtp_stream latency=0 do-timestamp=true'
|
||||||
|
],
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"rtsp://some/path2",
|
"rtsp://some/path2",
|
||||||
[],
|
[],
|
||||||
@ -184,6 +191,26 @@ class TestGstreamerBaseBuilder(TestCase):
|
|||||||
None,
|
None,
|
||||||
['rtmpsrc location="rtmp://some/path" name=rtp_stream'],
|
['rtmpsrc location="rtmp://some/path" name=rtp_stream'],
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"rtmpt://some/path",
|
||||||
|
None,
|
||||||
|
['rtmpsrc location="rtmpt://some/path" name=rtp_stream'],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"rtmps://some/path",
|
||||||
|
None,
|
||||||
|
['rtmpsrc location="rtmps://some/path" name=rtp_stream'],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"rtmpe://some/path",
|
||||||
|
None,
|
||||||
|
['rtmpsrc location="rtmpe://some/path" name=rtp_stream'],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"rtmfp://some/path",
|
||||||
|
None,
|
||||||
|
['rtmpsrc location="rtmfp://some/path" name=rtp_stream'],
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"myawesomesource key1=value1 ! myawesomeplugin key2=value2 option",
|
"myawesomesource key1=value1 ! myawesomeplugin key2=value2 option",
|
||||||
None,
|
None,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user