internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: blakeblackshear/frigate

Issue:
list of objects detected by zone
As @blakeblackshear kindly suggested, it would be great to be able to indicate objects detected inside an area.

Maybe like this:

```
camera:
  cour:
    width: 1920
    height: 1080

    ffmpeg:
      inputs:
        - path: rtsp://camera_cour:554/stream=0
          roles:
            - clips
            - detect

    zones:
      A:
        coordinates: 1920,0,1920,280,0,280,0,0
        objects:
          track:
            - person
            - car
      B:
        coordinates: 0,1080,1920,1080,1920,280,0,280
        objects:
          track:
            - dog
            - cat
            - bird

    clips:
      enabled: True
      required_zones:
      - A
      - B

    snapshots:
      enabled: True
      required_zones:
      - A
      - B

```

This has been discussed #1107.

Thank you very much for considering this need :-)


Discussion:

Resolving patch:
diff --git a/frigate/config.py b/frigate/config.py
--- a/frigate/config.py
+++ b/frigate/config.py
@@ -99,11 +99,13 @@ def __init__(self, **config):
         frame_shape = config.get("frame_shape", (1, 1))
 
         if "frame_height" not in config:
-            config["frame_height"] = max(frame_shape[0] // 6, 120)
+            config["frame_height"] = max(frame_shape[0] // 6, 180)
 
         if "contour_area" not in config:
             frame_width = frame_shape[1] * config["frame_height"] / frame_shape[0]
-            config["contour_area"] = config["frame_height"] * frame_width * 0.003912363
+            config["contour_area"] = (
+                config["frame_height"] * frame_width * 0.00173611111
+            )
 
         mask = config.get("mask", "")
         config["raw_mask"] = mask
@@ -185,6 +187,10 @@ class ZoneConfig(BaseModel):
     coordinates: Union[str, List[str]] = Field(
         title="Coordinates polygon for the defined zone."
     )
+    objects: List[str] = Field(
+        default_factory=list,
+        title="List of objects that can trigger the zone.",
+    )
     _color: Optional[Tuple[int, int, int]] = PrivateAttr()
     _contour: np.ndarray = PrivateAttr()
 
diff --git a/frigate/object_processing.py b/frigate/object_processing.py
--- a/frigate/object_processing.py
+++ b/frigate/object_processing.py
@@ -143,6 +143,9 @@ def update(self, current_frame_time, obj_data):
         bottom_center = (self.obj_data["centroid"][0], self.obj_data["box"][3])
         # check each zone
         for name, zone in self.camera_config.zones.items():
+            # if the zone is not for this object type, skip
+            if len(zone.objects) > 0 and not self.obj_data["label"] in zone.objects:
+                continue
             contour = zone.contour
             # check if the object is in the zone
             if cv2.pointPolygonTest(contour, bottom_center, False) >= 0:


Test patch:
Repository: blakeblackshear/frigate

Issue:
[Support]: Zone 'None' empty
### Describe the problem you are having

If I select to display zone 'None' only then I get an empty list.

![img](https://user-images.githubusercontent.com/117124485/211290724-8c282cea-edd5-41c7-a9e8-66bb37a3a6e6.png)


### Version

0.12.0-0DBF909

### Frigate config file

```yaml
-
```


### Relevant log output

```shell
-
```


### FFprobe output from your camera

```shell
-
```


### Frigate stats

_No response_

### Operating system

Proxmox

### Install method

Docker Compose

### Coral version

USB

### Network connection

Wired

### Camera make and model

_No response_

### Any other information that may be helpful

_No response_


Discussion:
Can you show a screenshot without the zone filter?
![img](https://user-images.githubusercontent.com/117124485/211342764-fd43c6e4-f149-4097-b570-e1beabbb7135.png)


Resolving patch:
diff --git a/frigate/http.py b/frigate/http.py
--- a/frigate/http.py
+++ b/frigate/http.py
@@ -602,8 +602,13 @@ def events():
         # for example a sub label 'bob' would get events
         # with sub labels 'bob' and 'bob, john'
         sub_label_clauses = []
+        filtered_sub_labels = sub_labels.split(",")
 
-        for label in sub_labels.split(","):
+        if "None" in filtered_sub_labels:
+            filtered_sub_labels.remove("None")
+            sub_label_clauses.append((Event.sub_label.is_null()))
+
+        for label in filtered_sub_labels:
             sub_label_clauses.append((Event.sub_label.cast("text") % f"*{label}*"))
 
         sub_label_clause = reduce(operator.or_, sub_label_clauses)
@@ -613,8 +618,13 @@ def events():
         # use matching so events with multiple zones
         # still match on a search where any zone matches
         zone_clauses = []
+        filtered_zones = zones.split(",")
+
+        if "None" in filtered_zones:
+            filtered_zones.remove("None")
+            zone_clauses.append((Event.zones.length() == 0))
 
-        for zone in zones.split(","):
+        for zone in filtered_zones:
             zone_clauses.append((Event.zones.cast("text") % f'*"{zone}"*'))
 
         zone_clause = reduce(operator.or_, zone_clauses)


Test patch:
Repository: blakeblackshear/frigate

Issue:
[Config Support]: #backchannel=0 argument isn't being passed to go2rtc
### Describe the problem you are having

Looks like the #backchannel=0 argument isn't being passed to go2rtc from the Frigate config file. 
I've even added ' ' around the input as I'm aware that Frigate sees # as comments.

This is causing my doorbell button press to not work. 

### Version

0.12.0-0dbf909

### Frigate config file

```yaml
cameras:
  frontdoor:
    ffmpeg:
      inputs:
        - path: 'rtsp://admin:supersecretpassword@192.168.0.25:554/cam/realmonitor?channel=1&subtype=0&#backchannel=0'
          roles:
            - restream
        - path: rtsp://localhost:8554/frontdoor
          roles:
            - record
```


### Relevant log output

```shell
N/A
```


### Frigate stats

_No response_

### Operating system

Debian

### Install method

Docker Compose

### Coral version

CPU (no coral)

### Any other information that may be helpful

_No response_


Discussion:
Yeah we should probably just set that by default since frigate doesn't support 2 way talk (currently). 

Resolving patch:
diff --git a/frigate/restream.py b/frigate/restream.py
--- a/frigate/restream.py
+++ b/frigate/restream.py
@@ -52,7 +52,9 @@ def add_cameras(self) -> None:
                         input.path.startswith("rtsp")
                         and not camera.restream.force_audio
                     ):
-                        self.relays[cam_name] = escape_special_characters(input.path)
+                        self.relays[
+                            cam_name
+                        ] = f"{escape_special_characters(input.path)}#backchannel=0"
                     else:
                         # go2rtc only supports rtsp for direct relay, otherwise ffmpeg is used
                         self.relays[cam_name] = get_manual_go2rtc_stream(


Test patch:
Repository: blakeblackshear/frigate

Issue:
FFprobe "Copy" Button 
### Describe the problem you are having

In 0.12, FFProbe is available directly on the System page for each camera, which is fantastic. The problem is if you use the "Copy" button, instead of actually copying the raw JSON, it copies an encoded-string version of the JSON, which is really hard to read when filing a ticket because double quotes are escaped, as are newlines. See "ffprobe output" below, which is a direct paste after pressing the "Copy" button.

### Version

0.12.0-27A31E7

### Frigate config file

```yaml
N/A
```


### Relevant log output

```shell
N/A
```


### FFprobe output from your camera

```shell
"[\n  {\n    \"return_code\": 0,\n    \"stderr\": {},\n    \"stdout\": {\n      \"programs\": [],\n      \"streams\": [\n        {\n          \"avg_frame_rate\": \"15/1\",\n          \"codec_long_name\": \"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10\",\n          \"display_aspect_ratio\": \"168:95\",\n          \"height\": 1520,\n          \"width\": 2688\n        },\n        {\n          \"avg_frame_rate\": \"0/0\",\n          \"codec_long_name\": \"AAC (Advanced Audio Coding)\"\n        }\n      ]\n    }\n  },\n  {\n    \"return_code\": 0,\n    \"stderr\": {},\n    \"stdout\": {\n      \"programs\": [],\n      \"streams\": [\n        {\n          \"avg_frame_rate\": \"15/1\",\n          \"codec_long_name\": \"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10\",\n          \"display_aspect_ratio\": \"168:95\",\n          \"height\": 360,\n          \"width\": 640\n        }\n      ]\n    }\n  }\n]"
```


### Frigate stats

_No response_

### Operating system

Other Linux

### Install method

Docker Compose

### Coral version

USB

### Network connection

Wired

### Camera make and model

N/A

### Any other information that may be helpful

_No response_


Discussion:

Resolving patch:
diff --git a/frigate/http.py b/frigate/http.py
--- a/frigate/http.py
+++ b/frigate/http.py
@@ -1296,12 +1296,12 @@ def ffprobe():
         output.append(
             {
                 "return_code": ffprobe.returncode,
-                "stderr": json.loads(ffprobe.stderr.decode("unicode_escape").strip())
-                if ffprobe.stderr.decode()
-                else {},
+                "stderr": ffprobe.stderr.decode("unicode_escape").strip()
+                if ffprobe.returncode != 0
+                else "",
                 "stdout": json.loads(ffprobe.stdout.decode("unicode_escape").strip())
-                if ffprobe.stdout.decode()
-                else {},
+                if ffprobe.returncode == 0
+                else "",
             }
         )
 


Test patch:
Repository: blakeblackshear/frigate

Issue:
Should `sub_labels` be included in `api/events/summary` ?
I'm trying to implement `sub_label` support in the card (https://github.com/dermotduffy/frigate-hass-card/issues/900). To do this, I need to fetch the available sub_labels. 

I had assumed they would show up in the event summary information, but they don't. So there are two paths:

* Add `sub_labels` to `api/events/summary` information (this has the advantage that the integration media browser could do drilldowns by sub_label).

* Proxy the `api/sub_labels` call from card -> integration -> Frigate.

Personally, I think the first option is the better one, but there may be a good reason why it's not included in the event summary info?




Discussion:
There's no explicit reason it isn't included in the summary, but how do you figure it would work? Just create a list of all names that are included in that particular day?
> There's no explicit reason it isn't included in the summary, but how do you figure it would work? Just create a list of all names that are included in that particular day?

Exactly. I already need to fetch the event summary on my end (and it's already proxied), so calculating the complete list of sublabels would simply be `uniq`ing the full set of sublabels returned by the summary.
Sounds good to me then, seems consistent with things. Is that something you can put a PR up for? Otherwise I may have some time tomorrow morning. 
> Sounds good to me then, seems consistent with things. Is that something you can put a PR up for?

Absolutely.


Resolving patch:
diff --git a/frigate/http.py b/frigate/http.py
--- a/frigate/http.py
+++ b/frigate/http.py
@@ -111,6 +111,7 @@ def events_summary():
         Event.select(
             Event.camera,
             Event.label,
+            Event.sub_label,
             fn.strftime(
                 "%Y-%m-%d",
                 fn.datetime(
@@ -124,6 +125,7 @@ def events_summary():
         .group_by(
             Event.camera,
             Event.label,
+            Event.sub_label,
             fn.strftime(
                 "%Y-%m-%d",
                 fn.datetime(


Test patch:
Repository: blakeblackshear/frigate

Issue:
[Support]: RTSP password not correctly masked / in log file
### Describe the problem you are having

Password is shown in Log FIle

```
Ffmpeg process crashed unexpectedly for E1ProBabyRoom.
The following ffmpeg logs include the last 100 lines prior to exit.
rtsp://*:*@192.168.1.3:554/h264Preview_01_sub: Protocol not found
Did you mean file:rtsp://hass:Welcome123%21@192.168.1.3:554
```

### Version

0.12.0-e454daf

### Frigate config file

```yaml
Not relevant
```


### Relevant log output

```shell
2023-03-21 20:01:53.982583022  [2023-03-21 20:01:53] watchdog.E1ProBabyRoom         ERROR   : Ffmpeg process crashed unexpectedly for E1ProBabyRoom.
2023-03-21 20:01:53.982672799  [2023-03-21 20:01:53] watchdog.E1ProBabyRoom         ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2023-03-21 20:01:53.982710434  [2023-03-21 20:01:53] ffmpeg.E1ProBabyRoom.detect    ERROR   : rtsp://*:*@192.168.1.3:554/h264Preview_01_sub: Protocol not found
2023-03-21 20:01:53.982783621  [2023-03-21 20:01:53] ffmpeg.E1ProBabyRoom.detect    ERROR   : Did you mean file:rtsp://hass:Welcome123%21@192.168.1.3:554
```

### Operating system

Other Linux

### Install method

Kubernetes

### Coral version

CPU (no coral)

### Network connection

Wireless

### Camera make and model

Reolink E1 Pro

### Any other information that may be helpful

_No response_


Discussion:

Resolving patch:
diff --git a/frigate/util.py b/frigate/util.py
--- a/frigate/util.py
+++ b/frigate/util.py
@@ -722,7 +722,7 @@ def load_labels(path, encoding="utf-8"):
 
 def clean_camera_user_pass(line: str) -> str:
     """Removes user and password from line."""
-    if line.startswith("rtsp://"):
+    if "rtsp://" in line:
         return re.sub(REGEX_RTSP_CAMERA_USER_PASS, "://*:*@", line)
     else:
         return re.sub(REGEX_HTTP_CAMERA_USER_PASS, "user=*&password=*", line)


Test patch:
diff --git a/frigate/test/test_camera_pw.py b/frigate/test/test_camera_pw.py
--- a/frigate/test/test_camera_pw.py
+++ b/frigate/test/test_camera_pw.py
@@ -36,3 +36,14 @@ def test_no_special_char_password(self):
         """Test that no change is made to path with no special characters."""
         escaped = escape_special_characters(self.rtsp_with_pass)
         assert escaped == self.rtsp_with_pass
+
+
+class TestUserPassMasking(unittest.TestCase):
+    def setUp(self) -> None:
+        self.rtsp_log_message = "Did you mean file:rtsp://user:password@192.168.1.3:554"
+
+    def test_rtsp_in_log_message(self):
+        """Test that the rtsp url in a log message is espaced."""
+        escaped = clean_camera_user_pass(self.rtsp_log_message)
+        print(f"The escaped is {escaped}")
+        assert escaped == "Did you mean file:rtsp://*:*@192.168.1.3:554"
Repository: blakeblackshear/frigate

Issue:
Export Recordings API does not accept float values (ex: when using start / end time from event)
**Describe what you are trying to accomplish and why in non technical terms**
I want to use export API to export event clips and they start and end floats (sub point values probably revering to seconds) and API accepts only integers

**Describe the solution you'd like**
/frigate/http.py edited to accept floats 
Starting line 1606 
```python
@bp.route("/export/<camera_name>/start/<start_time>/end/<end_time>", methods=["POST"])
def export_recording(camera_name: str, start_time: float, end_time: float):
    playback_factor = request.get_json(silent=True).get("playback", "realtime")
    exporter = RecordingExporter(
        current_app.frigate_config,
        camera_name,
        float(start_time),
        float(end_time),
        PlaybackFactorEnum[playback_factor]
        if playback_factor in PlaybackFactorEnum.__members__.values()
        else PlaybackFactorEnum.realtime,
    )
    exporter.start()
    return "Starting export of recording", 200
```
Not sure if it that easy though...

**Describe alternatives you've considered**
Truncating clip timestamps to ints.

**Additional context**
I would have tested it myself but while building a core dev container I got some error that it was unable to build Tensor models and it's late


Discussion:
The values are unix timestamps, so as an int it already has seconds-level granularity

Resolving patch:
diff --git a/frigate/http.py b/frigate/http.py
--- a/frigate/http.py
+++ b/frigate/http.py
@@ -1603,8 +1603,14 @@ def vod_event(id):
     )
 
 
-@bp.route("/export/<camera_name>/start/<start_time>/end/<end_time>", methods=["POST"])
-def export_recording(camera_name: str, start_time: int, end_time: int):
+@bp.route(
+    "/export/<camera_name>/start/<int:start_time>/end/<int:end_time>", methods=["POST"]
+)
+@bp.route(
+    "/export/<camera_name>/start/<float:start_time>/end/<float:end_time>",
+    methods=["POST"],
+)
+def export_recording(camera_name: str, start_time, end_time):
     playback_factor = request.get_json(silent=True).get("playback", "realtime")
     exporter = RecordingExporter(
         current_app.frigate_config,


Test patch:
Repository: blakeblackshear/frigate

Issue:
[Config Support]: Disabled Cam with Autotracking still enabled prevents Frigate from starting
### Describe the problem you are having

Camera with onvif: autotracking: True while having the camera enabled: false hinders frigate from starting

Further: disabling autotracking makes it start up fine again.
however if thats the only cam in the config and its disabled there's no need for the PTZ options in the frontend. They get displayed even if no camera with ptz is enabled. Only thing I can do now is to totally remove the onvif: part from my config

### Version

0.13.0-FA2E499

### Frigate config file

```yaml
cam:
    enabled: false
    ffmpeg:
      inputs:
        - path: rtsp://172.17.0.1:8554/cam?mp4
          roles:
            - record
        - path: rtsp://172.17.0.1:8554/cam_low?mp4
          roles:
            - detect
    detect:
      width: 640
      height: 352
    snapshots:
      enabled: True
    zones:
      all:
        coordinates: 229,352,453,352,450,0,236,0
    onvif:
      host: cam.iot
      port: 8080
      user: admin
      password: admin
      autotracking:
        enabled: False
        track:
          - person
        required_zones:
          - all
        return_preset: home
        timeout: 10
```


### Relevant log output

```shell
frigate                    | 2023-09-22 11:28:24.104735693  2023/09/22 11:28:24 [error] 147#147: *16 connect() failed (111: Connection refused) while connecting to upstream, client: ip, server: , request: "GET /api/events?cameras=all&labels=all&zones=all&sub_labels=all&favorites=0&include_thumbnails=0&limit=25 HTTP/1.1", upstream: "http://127.0.0.1:5001/events?cameras=all&labels=all&zones=all&sub_labels=all&favorites=0&include_thumbnails=0&limit=25", host: "server:5000", referrer: "http://server:5000/events"
```


### Frigate stats

_No response_

### Operating system

Debian

### Install method

Docker Compose

### Coral version

USB

### Any other information that may be helpful

_No response_


Discussion:

Resolving patch:
diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.py
--- a/frigate/ptz/autotrack.py
+++ b/frigate/ptz/autotrack.py
@@ -121,6 +121,9 @@ def __init__(
     def run(self):
         while not self.stop_event.wait(1):
             for camera_name, cam in self.config.cameras.items():
+                if not cam.enabled:
+                    continue
+
                 if cam.onvif.autotracking.enabled:
                     self.ptz_autotracker.camera_maintenance(camera_name)
                 else:
@@ -153,6 +156,9 @@ def __init__(
 
         # if cam is set to autotrack, onvif should be set up
         for camera_name, cam in self.config.cameras.items():
+            if not cam.enabled:
+                continue
+
             self.autotracker_init[camera_name] = False
             if cam.onvif.autotracking.enabled:
                 self._autotracker_setup(cam, camera_name)


Test patch:
Repository: blakeblackshear/frigate

Issue:
Catch time zone tzlocal error
### Describe the problem you are having

Im always seeing this message, unfortunately i did exactly what this message is tellimg me.
I'm currently using beta5, but also tested with stable.


The docker-host (debian 12) also uses this timezone.  
```
timedatectl | grep "Time zone"
Time zone: Europe/Vienna (CET, +0100)
```

I configured it in the docker-compose. I also tried a different City, with the same result. 
I also tried to remove this. What am i missing?
```
    environment:
      - TZ="Europe/Vienna"
#      - TZ="Europe/Berlin" 

```

### Version

beta5

### Frigate config file

```yaml
empty default config!
```


### Relevant log output

```shell
zoneinfo._common.ZoneInfoNotFoundError: 'tzlocal() does not support non-zoneinfo timezones like "Europe/Vienna". \nPlease use a timezone in the form of Continent/City'
```


### FFprobe output from your camera

```shell
-
```


### Frigate stats

```json
-
```


### Operating system

Debian

### Install method

Docker Compose

### Coral version

Other

### Network connection

Wired

### Camera make and model

-

### Any other information that may be helpful

-


Discussion:
More information is needed, it is not clear where in frigate this error is occurring
I just See it after atartup in the Logs in the gui. No camera is configure, only a fresh Installation. 
so let's see the full set of logs please
More info was provided in https://github.com/blakeblackshear/frigate/issues/8677

Resolving patch:
diff --git a/frigate/util/builtin.py b/frigate/util/builtin.py
--- a/frigate/util/builtin.py
+++ b/frigate/util/builtin.py
@@ -16,6 +16,7 @@
 import yaml
 from ruamel.yaml import YAML
 from tzlocal import get_localzone
+from zoneinfo import ZoneInfoNotFoundError
 
 from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS
 
@@ -266,7 +267,16 @@ def find_by_key(dictionary, target_key):
 
 def get_tomorrow_at_time(hour: int) -> datetime.datetime:
     """Returns the datetime of the following day at 2am."""
-    tomorrow = datetime.datetime.now(get_localzone()) + datetime.timedelta(days=1)
+    try:
+        tomorrow = datetime.datetime.now(get_localzone()) + datetime.timedelta(days=1)
+    except ZoneInfoNotFoundError:
+        tomorrow = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
+            days=1
+        )
+        logger.warning(
+            "Using utc for maintenance due to missing or incorrect timezone set"
+        )
+
     return tomorrow.replace(hour=hour, minute=0, second=0).astimezone(
         datetime.timezone.utc
     )


Test patch:
Repository: blakeblackshear/frigate

Issue:
[Support]: Amcrest secondary stream 704x480 birdseye ratio
### Describe the problem you are having

Birdseye in 0.13.0-beta6 overrides configuration to match aspect ratio. Amcrest cameras sending (what they call D1), NTSC DVT resolution of 704x480 requires an aspect of 22:15 to avoid empty space in the stream.

### Version

0.13.0-beta6

### Frigate config file

```yaml
birdseye:
  enabled: True
  mode: continuous
  width: 2560
  # height: 1920
  height: 1746
  quality: 5
```


### Relevant log output

```shell
N/A
```


### FFprobe output from your camera

```shell
N/A
```


### Frigate stats

_No response_

### Operating system

Other Linux

### Install method

Docker Compose

### Coral version

Other

### Network connection

Wired

### Camera make and model

Amcrest IP5M*28MM

### Any other information that may be helpful

_No response_


Discussion:

Resolving patch:
diff --git a/frigate/output.py b/frigate/output.py
--- a/frigate/output.py
+++ b/frigate/output.py
@@ -45,6 +45,7 @@ def get_standard_aspect_ratio(width: int, height: int) -> tuple[int, int]:
         (32, 9),  # panoramic cameras
         (12, 9),
         (9, 12),
+        (22, 15),  # Amcrest, NTSC DVT
     ]  # aspects are scaled to have common relative size
     known_aspects_ratios = list(
         map(lambda aspect: aspect[0] / aspect[1], known_aspects)


Test patch: