revert
All checks were successful
Build Docker image / docker (push) Successful in 1m47s

This commit is contained in:
Lee 2024-03-02 16:39:33 +00:00
parent a63149d37a
commit c7486d6628
2 changed files with 25 additions and 15 deletions

@ -903,8 +903,20 @@ class UnifiCamBase(metaclass=ABCMeta):
base_args = [ base_args = [
"-avoid_negative_ts", "-avoid_negative_ts",
"make_zero", "make_zero",
# "-use_wallclock_as_timestamps 1", "-fflags",
"+genpts+discardcorrupt",
"-use_wallclock_as_timestamps 1",
] ]
try:
output = subprocess.check_output(["ffmpeg", "-h", "full"])
if b"stimeout" in output:
base_args.append("-stimeout 15000000")
else:
base_args.append("-timeout 15000000")
except subprocess.CalledProcessError:
self.logger.exception("Could not check for ffmpeg options")
return " ".join(base_args) return " ".join(base_args)
async def start_video_stream( async def start_video_stream(
@ -916,18 +928,16 @@ class UnifiCamBase(metaclass=ABCMeta):
if not has_spawned or is_dead: if not has_spawned or is_dead:
source = await self.get_stream_source(stream_index) source = await self.get_stream_source(stream_index)
cmd = ( cmd = (
"ffmpeg -nostdin -loglevel debug -y" "ffmpeg -nostdin -loglevel error -y"
f" {self.get_base_ffmpeg_args(stream_index)}" f" {self.get_base_ffmpeg_args(stream_index)} -rtsp_transport"
f' -i "{source}"' f' {self.args.rtsp_transport} -i "{source}"'
f" {self.get_extra_ffmpeg_args(stream_index)}" f" {self.get_extra_ffmpeg_args(stream_index)} -metadata"
f" -metadata streamName={stream_name} -f flv -" f" streamName={stream_name} -f flv - | {sys.executable} -m"
f" | {sys.executable} -m unifi.clock_sync" " unifi.clock_sync"
f" {'--write-timestamps' if self._needs_flv_timestamps else ''}" f" {'--write-timestamps' if self._needs_flv_timestamps else ''} | nc"
f" | nc {destination[0]} {destination[1]}" f" {destination[0]} {destination[1]}"
) )
if is_dead: if is_dead:
self.logger.warn(f"Previous ffmpeg process for {stream_index} died.") self.logger.warn(f"Previous ffmpeg process for {stream_index} died.")
@ -935,7 +945,7 @@ class UnifiCamBase(metaclass=ABCMeta):
f"Spawning ffmpeg for {stream_index} ({stream_name}): {cmd}" f"Spawning ffmpeg for {stream_index} ({stream_name}): {cmd}"
) )
self._ffmpeg_handles[stream_index] = subprocess.Popen( self._ffmpeg_handles[stream_index] = subprocess.Popen(
cmd, shell=True cmd, stdout=subprocess.DEVNULL, shell=True
) )
def stop_video_stream(self, stream_index: str): def stop_video_stream(self, stream_index: str):

@ -108,6 +108,7 @@ class Reolink(UnifiCamBase):
self.logger.info("Trigger motion end") self.logger.info("Trigger motion end")
await self.trigger_motion_stop() await self.trigger_motion_stop()
else: else:
# pass
self.logger.error( self.logger.error(
"Motion API request responded with " "Motion API request responded with "
"unexpected JSON, retrying. " "unexpected JSON, retrying. "
@ -143,7 +144,6 @@ class Reolink(UnifiCamBase):
stream = self.args.substream stream = self.args.substream
return ( return (
f"rtmp://{self.args.ip}/bcs/channel{self.args.channel}_{stream}.bcs" f"rtsp://{self.args.username}:{self.args.password}@{self.args.ip}:554"
f"?channel={self.args.channel}&stream=0&user={self.args.username}" f"//h264Preview_{int(self.args.channel) + 1:02}_{stream}"
f"&password={self.args.password}"
) )