homesec 1.1.2__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
homesec/models/source.py CHANGED
@@ -30,6 +30,7 @@ class RTSPSourceConfig(BaseModel):
30
30
  heartbeat_s: float = 30.0
31
31
  rtsp_connect_timeout_s: float = 2.0
32
32
  rtsp_io_timeout_s: float = 2.0
33
+ ffmpeg_flags: list[str] = Field(default_factory=list)
33
34
 
34
35
 
35
36
  class LocalFolderSourceConfig(BaseModel):
homesec/sources/rtsp.py CHANGED
@@ -219,6 +219,7 @@ class RTSPSource(ThreadedClipSource):
219
219
  self.reconnect_backoff_s = float(config.reconnect_backoff_s)
220
220
  self.rtsp_connect_timeout_s = float(config.rtsp_connect_timeout_s)
221
221
  self.rtsp_io_timeout_s = float(config.rtsp_io_timeout_s)
222
+ self.ffmpeg_flags = list(config.ffmpeg_flags)
222
223
 
223
224
  if config.disable_hwaccel:
224
225
  logger.info("Hardware acceleration manually disabled")
@@ -551,9 +552,31 @@ class RTSPSource(ThreadedClipSource):
551
552
  "-f",
552
553
  "mp4",
553
554
  "-y",
554
- str(output_file),
555
555
  ]
556
556
 
557
+ user_flags = self.ffmpeg_flags
558
+
559
+ # Naive check to see if user overrode defaults
560
+ # If user supplies ANY -loglevel, we don't add ours.
561
+ # If user supplies ANY -fflags, we don't add ours (to avoid concatenation complexity).
562
+ # This allows full user control.
563
+ has_loglevel = any(x == "-loglevel" for x in user_flags)
564
+ if not has_loglevel:
565
+ cmd.extend(["-loglevel", "warning"])
566
+
567
+ has_fflags = any(x == "-fflags" for x in user_flags)
568
+ if not has_fflags:
569
+ cmd.extend(["-fflags", "+genpts+igndts"])
570
+
571
+ has_fps_mode = any(x == "-fps_mode" or x == "-vsync" for x in user_flags)
572
+ if not has_fps_mode:
573
+ cmd.extend(["-vsync", "0"])
574
+
575
+ # Add user flags last so they can potentially override or add to the above
576
+ cmd.extend(user_flags)
577
+
578
+ cmd.extend([str(output_file)])
579
+
557
580
  safe_cmd = list(cmd)
558
581
  try:
559
582
  idx = safe_cmd.index("-i")
@@ -753,6 +776,7 @@ class RTSPSource(ThreadedClipSource):
753
776
 
754
777
  cmd = ["ffmpeg"]
755
778
 
779
+ # 1. Global Flags (Hardware Acceleration)
756
780
  if self.hwaccel_config.is_available and not self._hwaccel_failed:
757
781
  hwaccel = self.hwaccel_config.hwaccel
758
782
  if hwaccel is not None:
@@ -762,6 +786,23 @@ class RTSPSource(ThreadedClipSource):
762
786
  elif self._hwaccel_failed:
763
787
  logger.info("Hardware acceleration disabled due to previous failures")
764
788
 
789
+ # 2. Global Flags (Robustness & Logging)
790
+ user_flags = self.ffmpeg_flags
791
+
792
+ has_loglevel = any(x == "-loglevel" for x in user_flags)
793
+ if not has_loglevel:
794
+ cmd.extend(["-loglevel", "warning"])
795
+
796
+ has_fflags = any(x == "-fflags" for x in user_flags)
797
+ if not has_fflags:
798
+ cmd.extend(["-fflags", "+genpts+igndts"])
799
+
800
+ # Add all user flags to global scope.
801
+ # Users who want input-specific flags (before -i) must rely on ffmpeg parsing them correctly
802
+ # or we would need a more complex config structure.
803
+ # For now, most robustness flags (-re, -rtsp_transport, etc) work as global or are handled below.
804
+ cmd.extend(user_flags)
805
+
765
806
  base_input_args = [
766
807
  "-rtsp_transport",
767
808
  "tcp",
@@ -778,11 +819,10 @@ class RTSPSource(ThreadedClipSource):
778
819
  ]
779
820
 
780
821
  timeout_us_connect = str(int(max(0.1, self.rtsp_connect_timeout_s) * 1_000_000))
781
- timeout_us_io = str(int(max(0.1, self.rtsp_io_timeout_s) * 1_000_000))
782
822
  attempts: list[tuple[str, list[str]]] = [
783
823
  (
784
- "stimeout+rw_timeout",
785
- ["-stimeout", timeout_us_connect, "-rw_timeout", timeout_us_io] + base_input_args,
824
+ "stimeout",
825
+ ["-stimeout", timeout_us_connect] + base_input_args,
786
826
  ),
787
827
  ("stimeout", ["-stimeout", timeout_us_connect] + base_input_args),
788
828
  ("no_timeouts", base_input_args),
@@ -790,6 +830,7 @@ class RTSPSource(ThreadedClipSource):
790
830
 
791
831
  process: subprocess.Popen[bytes] | None = None
792
832
  stderr_file: Any | None = None
833
+
793
834
  for label, extra_args in attempts:
794
835
  cmd_attempt = list(cmd) + extra_args
795
836
  logger.debug("Starting frame pipeline (%s), logging to: %s", label, stderr_log)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: homesec
3
- Version: 1.1.2
3
+ Version: 1.2.0
4
4
  Summary: Pluggable async home security camera pipeline with detection, VLM analysis, and alerts.
5
5
  Project-URL: Homepage, https://github.com/lan17/homesec
6
6
  Project-URL: Source, https://github.com/lan17/homesec
@@ -20,7 +20,7 @@ homesec/models/config.py,sha256=Z70xKrbDHi96j8IoRXPBw7DYAI7sjHR4M6nqReHTNds,1418
20
20
  homesec/models/enums.py,sha256=WQk1PvYnJd5iaz51P5GM3XayqCf0VpQnLYmSuw1hrZk,3293
21
21
  homesec/models/events.py,sha256=sgPDCSp9w60VUKKREYxNBZaxrFWW_bYyLwMFGHBawjk,4942
22
22
  homesec/models/filter.py,sha256=6NS1rBI2zmrswK9NtMn0vZlbwbeMGCPuLCDKP9XWN0I,2259
23
- homesec/models/source.py,sha256=PDtANsPaVzLz_VvR3cFVkQcfvema-7TrcuTY8a-gVq0,2309
23
+ homesec/models/source.py,sha256=F8ksGrOa09bxx5IEgQmxPWJNWOm8zvFLsRJxihJTlM4,2367
24
24
  homesec/models/storage.py,sha256=63wyHdDt3QrfdsP0SmhrxtOeWRllZ1O2GPrA4jI7XmU,235
25
25
  homesec/models/vlm.py,sha256=Uk6TPwqbKxzyAsOlBSzZru74nKjp2-LLyzIp5b3wM_c,3293
26
26
  homesec/pipeline/__init__.py,sha256=kiQLECc6JIPmeIdBJrVpTApPs0GBAgWoZ1kU4XZyJVY,214
@@ -53,7 +53,7 @@ homesec/sources/__init__.py,sha256=wuCtiF44ceo7n3wJN51VHHcDavko3ubUDICtFbWmaRI,5
53
53
  homesec/sources/base.py,sha256=dKTxJxcDwJtykWDN3WYzkW5mtkRqlOJxJLWcLy82_Zo,7582
54
54
  homesec/sources/ftp.py,sha256=ynIPbgcbIi1jub8yr4H1259Y1HbNM42RFDBBivXD4mg,7308
55
55
  homesec/sources/local_folder.py,sha256=eW7ghgRsqTnZ5ZMPbsXh9ntqfue1UeM29ZpvRvLthPA,8461
56
- homesec/sources/rtsp.py,sha256=3TOFDfIqadH3-DepB1xgv6mtOd0h-FYppZXBXSTBBi0,47304
56
+ homesec/sources/rtsp.py,sha256=T_DoAExu58pukRDjPNZ7wELDIebbQpVFrg29L9xACa8,48866
57
57
  homesec/state/__init__.py,sha256=Evt1jqTebmpJD1NUzNh3vwt5pbjDlLjQ0DgMCSAZOuM,255
58
58
  homesec/state/postgres.py,sha256=I-cXqW5cgz-hpaHc0JIv3DnIBTmGxE28P8ZxBAGabSw,17765
59
59
  homesec/telemetry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -61,8 +61,8 @@ homesec/telemetry/db_log_handler.py,sha256=KM8g4kcOyPzFJbpGxpSzecx_hrEWY0YfpoIKy
61
61
  homesec/telemetry/postgres_settings.py,sha256=EVD2_oi_KReFJvQmXxW026aurl_YD-KexT7rkbGQPHc,1198
62
62
  homesec/telemetry/db/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
63
63
  homesec/telemetry/db/log_table.py,sha256=wcZLwRht7FMa0z2gf37f_RxdVTNIdDiK4i_N3c_ibwg,473
64
- homesec-1.1.2.dist-info/METADATA,sha256=hdgJS5FnVtvipMsjSCaG_f9T2s_QLEdePmTDrcQF9yI,23274
65
- homesec-1.1.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
66
- homesec-1.1.2.dist-info/entry_points.txt,sha256=8ocCj_fP1qxIuL-DVDAUiaUbEdTMX_kg_BzVrJsbQYg,45
67
- homesec-1.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
68
- homesec-1.1.2.dist-info/RECORD,,
64
+ homesec-1.2.0.dist-info/METADATA,sha256=0N3Lg00FUl57PUV4VWe_vbIfQDOq-xib2wnkSU6dQS4,23274
65
+ homesec-1.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
66
+ homesec-1.2.0.dist-info/entry_points.txt,sha256=8ocCj_fP1qxIuL-DVDAUiaUbEdTMX_kg_BzVrJsbQYg,45
67
+ homesec-1.2.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
68
+ homesec-1.2.0.dist-info/RECORD,,