blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
19.1k stars 1.74k forks source link

[Support]: Unable to access index of recordings #4092

Closed weitheng closed 2 years ago

weitheng commented 2 years ago

Describe the problem you are having

Unable to access index of http://FRIGATE_URL/media/frigate/recordings/ to view the list of recording files, only able to see Frigate Cameras Dashboard. http://FRIGATE_URL/clips/ works fine though

Version

0.11.1-2EADA21

Frigate stats

No response

Operating system

Proxmox

Install method

Docker Compose

Coral version

USB

Network connection

Wired

Any other information that may be helpful

No response

NickM-27 commented 2 years ago

Viewing http://<frigate_host>:5000/recordings/ works for me showing:

[
{ "name":"2022-03", "type":"directory", "mtime":"Wed, 11 May 2022 21:24:26 GMT" },
{ "name":"2022-04", "type":"directory", "mtime":"Thu, 05 May 2022 23:34:35 GMT" },
{ "name":"2022-05", "type":"directory", "mtime":"Mon, 06 Jun 2022 03:11:49 GMT" },
{ "name":"2022-06", "type":"directory", "mtime":"Fri, 29 Jul 2022 22:39:51 GMT" },
{ "name":"2022-07", "type":"directory", "mtime":"Sat, 20 Aug 2022 08:05:13 GMT" },
{ "name":"2022-08", "type":"directory", "mtime":"Sat, 10 Sep 2022 19:13:59 GMT" },
{ "name":"2022-09", "type":"directory", "mtime":"Tue, 11 Oct 2022 21:33:34 GMT" },
{ "name":"2022-10", "type":"directory", "mtime":"Sat, 15 Oct 2022 12:10:54 GMT" }
]
weitheng commented 2 years ago

I am referring to this. From the documentation, it says that I should be able to find all the recording at this address http://FRIGATE_URL/media/frigate/recordings/

Screenshot 2022-10-15 at 16 20 03
NickM-27 commented 2 years ago

It's talking about the folder structure itself on the host, not through the web browser.

weitheng commented 2 years ago

So, there's no way to see a list of recording files?

NickM-27 commented 2 years ago

So, there's no way to see a list of recording files?

You can view them on your hosts file system. The recordings files directly are considered "internal metadata" by frigate and not really meant to be interacted with by the user directly. We have many APIs available for creating specific recordings: https://docs.frigate.video/integrations/api#get-vodyear-monthdayhourcameramasterm3u8

weitheng commented 2 years ago

So, there's no way to see a list of recording files?

You can view them on your hosts file system. The recordings files directly are considered "internal metadata" by frigate and not really meant to be interacted with by the user directly. We have many APIs available for creating specific recordings: https://docs.frigate.video/integrations/api#get-vodyear-monthdayhourcameramasterm3u8

I see. Thanks for the link, but doesn't seem like I am able to download the video file and view it as .m3u8 is a playlist file. In any case, I tried this url https://HA_URL/api/frigate/<client-id>/clips/front_door-1624599978.427826-976jaa.mp4 given in this section, but I keep getting a 404: Not Founderror, I have already checked the event-id but it still doesn't work. Any ideas?

NickM-27 commented 2 years ago

You're trying to mix HA and frigate APIs which doesn't work. It would need to be

https://HA_URL:5000/api/clips/front_door-1624599978.427826-976jaa.mp4 assuming you have port 5000 exposed for the frigate addon

weitheng commented 2 years ago

You're trying to mix HA and frigate APIs which doesn't work. It would need to be

https://HA_URL:5000/api/clips/front_door-1624599978.427826-976jaa.mp4 assuming you have port 5000 exposed for the frigate addon

I do not have frigate installed on my HA as an add-on, it is installed on a separate device. Even when I tried it with my frigate instance url, it still doesn't work, getting a Not Found error. And I believe there should be nothing wrong with the url in my previous post, as I am able to use this alternative url just fine https://HA_URL/api/frigate/frigate1/notifications/1624599978.427826-976jaa/front_door/clip.mp4. Although this url contains the camera name, however it seems that it is ignored, as I get footage from other cameras (essentially this means that it doesn't care about the camera_name, but only the event-id in this url.

What I am trying to achieve is to get footage from a camera that I have specified. I thought this url https://HA_URL/api/frigate/<client-id>/clips/front_door-1624599978.427826-976jaa.mp4 (written in the docs) would have worked given I am able to achieve the result I want for the snapshot url for which I am able to specify the camera it should be getting the snapshot from - http://FRIGATE_URL:5000/clips/front_door-{{trigger.payload_json["after"]["id"]}}.jpg

NickM-27 commented 2 years ago

And I believe there should be nothing wrong with the url in my previous post, as I am able to use this alternative url just fine https://HA_URL/api/frigate/frigate1/notifications/1624599978.427826-976jaa/front_door/clip.mp4.

That URL is provided by the HA integration which is an entirely different API to frigate itself.

https://github.com/blakeblackshear/frigate-hass-integration/blob/5f31ea867ab914cc6280ffb9d74fe05b461fb6ae/custom_components/frigate/views.py#L260

Although this url contains the camera name, however it seems that it is ignored, as I get footage from other cameras (essentially this means that it doesn't care about the camera_name, but only the event-id in this url.

What I am trying to achieve is to get a footage from a camera that I have specified. I thought this url https://HA_URL/api/frigate/<client-id>/clips/front_door-1624599978.427826-976jaa.mp4 (written on the docs) would have given similar result for the snapshot url for which I am able to specify the camera it should be getting the snapshot from - http://FRIGATE_URL:5000/clips/front_door-{{trigger.payload_json["after"]["id"]}}.jpg

Again, that URL is not from the docs at all. The docs I linked are referencing frigates API which in your case (no addon) would be http://<frigate IP>:5000/api/events/<event_id>/clip.mp4

NickM-27 commented 2 years ago

Realized the url I put previously was not right and probably added some confusion

weitheng commented 2 years ago

So, there's no way to specify which camera in the URL? And also, the url I used can be found here https://github.com/blakeblackshear/frigate-hass-integration/blob/5f31ea867ab914cc6280ffb9d74fe05b461fb6ae/tests/test_views.py#L372 -- seems like there's no point in specifying the camera name as it is ignored?

NickM-27 commented 2 years ago

So, there's no way to specify which camera in the URL?

Event id is specific to a single event so there's no need to specify the camera.

And also, the url I used can be found here https://github.com/blakeblackshear/frigate-hass-integration/blob/5f31ea867ab914cc6280ffb9d74fe05b461fb6ae/tests/test_views.py#L372 -- seems like there's no point in specifying the camera name as it is ignored?

Yes, that's from the integration API which has a layer on top of the frigate API (and the frigate API is what is in the docs). The integration API just asks for the camera name always.

weitheng commented 2 years ago

Event id is specific to a single event so there's no need to specify the camera.

Obviously event id is unique and specific to a single event. However, I have multiple cameras on frigate, and when I use this MQTT message as a trigger frigate/events and this https://HA_URL/api/frigate/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/front_door/clip.mp4 to retrieve the footage, many times I get a footage from a camera that is different from what I specified on the automation. This happens when an object moves from one camera's frame to another camera's frame within a few seconds. I have used this condition template {{ trigger.payload_json['after']['camera'] == 'front_door' }} to filter out footage that is not from the camera that I specified, but this is still not ideal, as some footage even though captured by Frigate are not retrieved using this automation because they are missed. Scenario:-

  1. front_door automation got triggered by the MQTT message
  2. But the event-id is for the next camera (foyer) -> automation is stopped as the condition is not fulfilled,
  3. conditions for foyer automation is fulfilled
  4. I only receive 1 of 2 footage I am supposed to receive

Yes, that's from the integration API which has a layer on top of the frigate API (and the frigate API is what is in the docs). The integration API just asks for the camera name always.

Seems to me that it's a bug, because what's the point of it asking for camera name if the camera name is not passed to anywhere or used. What's the point of the API asking for the camera name if this is the case as it only needs the event-id to work?

Is there any way to get the latest footage from a specific camera? I see that there's a way to do that with the snapshot using Frigate API, I don't see why this is not available for footage

NickM-27 commented 2 years ago

Seems to me that it's a bug, because what's the point of it asking for camera name if the camera name is not passed to anywhere or used. What's the point of the API asking for the camera name if this is the case as it only needs the event-id to work?

A bug is something not working as intended, meanwhile this is working as it is supposed to.

I agree it is somewhat unintuitive, but this API in the integration predates my contributions so I don't know for sure. Odds are that the camera name used to be needed, but it isn't needed any more. The integration API wasn't updated to remove the camera name from the path since that would be a big breaking change.

As you pointed out, an object on each camera has its own event and thus own event id. Frigate does not have the ability to pull footage from multiple cameras into a single clip.

Is there any way to get the latest footage from a specific camera? I see that there's a way to do that with the snapshot using Frigate API, I don't see why this is not available for footage

Yes, you can use http://<frigate ip>:5000/api/<camera_name>/start/<int:start_ts>/end/<int:end_ts>/clip.mp4 to get the footage during a given time. The start and end times for the event are included in get MQTT events payload

weitheng commented 2 years ago

As you pointed out, an object on each camera has its own event and thus own event id. Frigate does not have the ability to pull footage from multiple cameras into a single clip.

My intention is not to have Frigate pull footage from multiple cameras and stitch them into a single clip, but to make sure that no footage are missed when my automations run. Right now some footage are missed due to one object moving from one camera's frame to another, as a result even though I have 2 separate automations for those 2 cameras to retrieve the footage and send to Telegram, I am only receiving one footage from 1 of 2 cameras. It seems to me it's either Frigate not sending out the MQTT event message fast enough, thus the newer MQTT event message overrides the previous MQTT event message before it had the chance to be sent out to my MQTT broker in HA, or it's just HA receiving MQTT message too slowly.

Because when one object moves from one camera's frame to another camera's frame, the 2 automations I run are receiving the same event-id, even though there should be 2 event-ids from motion triggered in 2 cameras. When I check the footage that have been recorded on frigate, the 2 footage have indeed been recorded, so the question is why is there only 1 event-id received by HA even though there should be 2? My automations are set to run on queued, so I have already ruled out the possibility of the older event-id being overwritten if it indeed has been received by HA's MQTT broker.

If possible can you please try this (triggering 2 cameras immediately one after another) and let me know if you received the 2 footage you are supposed to be receiving using automations from HA with this mqtt message frigate1/events as a trigger for both automations?

Yes, you can use http://<frigate ip>:5000/api/<camera_name>/start/<int:start_ts>/end/<int:end_ts>/clip.mp4 to get the footage during a given time. The start and end times for the event are included in get MQTT events payload

I tried using this url, but I am only able to receive footage 5 out of 50 times as often times I get None for the end times in the url.

The reason why I asked for way to pull the latest footage from a specific camera (like how we can do that with snapshot here), then I would be able to design an automation in HA to retrieve the latest footage from the camera I specified when motion has been detected on that camera, instead of relying on trying to get the right event-id, which right now seems to be hit or miss when motion is detected immediately one after another on 2 cameras.

NickM-27 commented 2 years ago

I tried it and it works just fine moving between my cameras, video is shown of the event. I do have a separate automation for each camera so there's no way for the events to get mixed up, not sure how your automation is setup.

I tried using this url, but I am only able to receive footage 5 out of 50 times as often times I get None for the end times in the url.

If you're not waiting until the event is over then you'll need to define your own end time

The reason why I asked for way to pull the latest footage from a specific camera (like how we can do that with snapshot here), then I would be able to design an automation in HA to retrieve the latest footage from the camera I specified when motion has been detected on that camera, instead of relying on trying to get the right event-id, which right now seems to be hit or miss when motion is detected immediately one after another on 2 cameras.

The latest footage is very undefined. How much footage? Also the most recent 10 second segment won't be immediately available which might be confusing. This latest footage isn't as simple as it's being made out to be.

weitheng commented 2 years ago

I tried it and it works just fine moving between my cameras, video is shown of the event. I do have a separate automation for each camera so there's no way for the events to get mixed up, not sure how your automation is setup.

Here are my setup for the 2 automations, please enlighten me what I am doing wrong here. Please note that I put a delay before retrieving + sending the photo & video as I notice the files will only be ready after the events have passed a few seconds later and whatever Frigate needs to do to get the file ready.

description: ""
mode: queued
trigger:
- platform: mqtt
topic: frigate/events
condition:
- condition: state
entity_id: binary_sensor.front_door_all_occupancy
state: "on"
- condition: template
value_template: "{{ trigger.payload_json['after']['camera'] == 'front_door' }}"
action:
- delay:
hours: 0
minutes: 0
seconds: 8
milliseconds: 0
enabled: true
- parallel:
- service: telegram_bot.send_photo
data:
url: >-
http://FRIGATE_URL:5000/clips/front_door-{{trigger.payload_json["after"]["id"]}}.jpg
caption: "{{trigger.payload_json[\"after\"][\"label\"]}}"
timeout: 1000
- delay:
hours: 0
minutes: 0
seconds: 22
milliseconds: 0
enabled: true
- service: telegram_bot.send_video
data:
url: >-
https://HA_URL/api/frigate/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/front_door/clip.mp4
caption: "{{trigger.payload_json[\"after\"][\"label\"]}}"
timeout: 2000
max: 2

2nd camera

description: ""
mode: queued
trigger:
- platform: mqtt
topic: frigate/events
condition:
- condition: state
entity_id: binary_sensor.garage_all_occupancy
state: "on"
- condition: template
value_template: "{{ trigger.payload_json['after']['camera'] == 'garage' }}"
action:
- delay:
hours: 0
minutes: 0
seconds: 8
milliseconds: 0
enabled: true
- parallel:
- service: telegram_bot.send_photo
data:
url: >-
http://FRIGATE_URL:5000/clips/garage-{{trigger.payload_json["after"]["id"]}}.jpg
caption: "{{trigger.payload_json[\"after\"][\"label\"]}}"
timeout: 1000
- delay:
hours: 0
minutes: 0
seconds: 22
milliseconds: 0
enabled: true
- service: telegram_bot.send_video
data:
url: >-
https://HA_URL/api/frigate/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/garage/clip.mp4
caption: "{{trigger.payload_json[\"after\"][\"label\"]}}"
timeout: 2000
max: 2

The latest footage is very undefined. How much footage?

By latest I would assume just one, the most recent (just like how the snapshot works now, just 1 most recent snapshot).

Also the most recent 10 second segment won't be immediately available which might be confusing. This latest footage isn't as simple as it's being made out to be.

Correct me if I am wrong, the recording files (obtained through this way https://HA_URL/api/frigate/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/garage/clip.mp4) right now are also not immediately made available isn't it? There's a few seconds delay for the event to end, and for Frigate to encode the file etc., no?

NickM-27 commented 2 years ago

I would not use camera name as a condition but rather as trigger filter. This way the automation won't even trigger. Since you have queued mode you don't want the latency of unrelated triggers interfering.

You can see how I setup my automations in this guide I wrote https://github.com/blakeblackshear/frigate/discussions/2898

Correct me if I am wrong, the recording files (obtained through this way https://HA_URL/api/frigate/frigate1/notifications/{{trigger.payload_json["after"]["id"]}}/garage/clip.mp4) right now are also not immediately made available isn't it? There's a few seconds delay for the event to end, and for Frigate to encode the file etc.?

Frigate doesn't encode or decode recordings files, they are just streamed directly into a file. However, frigate does this in segments (~10 seconds by default) and the segment file will be written to memory until it is finished at which point that file is moved to storage (and then it will able to be included in the clip.mp4 and other endpoints)

weitheng commented 2 years ago

I would not use camera name as a condition but rather as trigger filter. This way the automation won't even trigger. Since you have queued mode you don't want the latency of unrelated triggers interfering.

You can see how I setup my automations in this guide I wrote #2898

Correct me if I am wrong, the recording files (obtained through this way https://HA_URL/api/frigate/frigate1/notifications/{{trigger.payload_json["after"]["id"]}}/garage/clip.mp4) right now are also not immediately made available isn't it? There's a few seconds delay for the event to end, and for Frigate to encode the file etc.?

Frigate doesn't encode or decode recordings files, they are just streamed directly into a file. However, frigate does this in segments (~10 seconds by default) and the segment file will be written to memory until it is finished at which point that file is moved to storage (and then it will able to be included in the clip.mp4 and other endpoints)

Your guide helped a lot! Now my automations run way better. Thanks!