-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ability to download recorded videos #97
Comments
Thanks for the example. Do you know of an example Home Assistant integration that allows you to download files? I'm not sure I've seen anything like that before (or to show video clips). One problematic thing is that the native files that Dahua produce are .dav files. DAV is a modified mp4 format and it's not going to play without a conversion. I most likely won't be able to support this but will keep an eye out if I think it can be done easily. |
I've just confirmed the ability to download MP4 files from the Amcrest AD410 doorbell SD-Card. You can capture "NewFile" events from the camera, where the data contains the filename. (Note that there will also be a newfile event for the snapshot, same format as above, but .jpg extension) To download this file, remove all the backslashes from the filename and issue this command: There is a general purpose HASS Downloader integration. I tried to use this downloader service to issue the above http command but it failed with a 401 (authentication) error. My guess is that it only tries basic authentication and doesn't retry with digest. BTW - I have an old Dahua NVR that has been updated with the latest firmware and it provides a new option to download files in MP4 format. It may be converting DAV to MP4 on the fly, but I will do some testing to see. It might be possible to create a shell command to run "curl --digest -u admin:password/http://...etc" and pass the parsed filename to it. Or we could look at the downloader code and see what it would take for a PR to use digest. BTW - I would like to have the ability to stream recorded files directly from the camera SD-Card or NVR rather than download them. This command should allow it: rtsp://admin:password@<ip>:554/mnt/sd/2021-10-04/001/dav/10/10.56.56-10.57.44[M][0@0][0].mp4 But when I tested this using VLC network stream, it ignored the file and just streamed the live video with no errors. Weird. EDIT: quick look at downloader source - it's simply using: To support Digest, it would need an option such as: But in order to provide new options like this, someone has to also write the new UI config flow to add them. EDIT 2: Feature Request submitted... https://community.home-assistant.io/t/downloader-integration-lacks-authentication-options/344244 |
Other than my AD410 doorbell, none of my Dahua cameras have an SD-Card as they record only on the NVR. Unfortunately, I discovered that there is no "NewFile" event raised when a motion event occurs and the video is recorded to the NVR. This seems to only occur if an SD_Card is installed. So if the OP wants to be able to download video from the SD-Card and not the NVR, there is a way forward that should not require any changes to the Dahua integration. |
More discovery... the DAV files recorded on the Dahua NVR are from the constant stream of each camera channel. The recordings are written as individual hour-long DAV files. If you use the NVR Backup to USB drive facility, you will see these hour-long recordings which can be saved as DAV (or MP4 in the newer firmware). Here is an example of the NVR filepath/name created: You can search the NVR for available files, but it's tricky since it takes 3 separate commands which require a session object id that is temporary...
I was not successful using the http RPC_Loadfile command to directly download this file. It immediately fails with a "file incomplete" error. Not that I wanted a huge hour long DAV file that would have to be converted and extracted by the desired time slice. Bottom line - a facility to download recorded videos from the NVR would be very complicated and unwieldly in my view. Just not worth it. On the other hand, accessing them from the camera's SD-Card is much simpler given the specific filename obtained from the "NewFile" event. |
Hi guys, Prerequisite: u have to enable ffmpeg in your configuration.yaml
|
@blademckain that's really cool. And yes, it's pretty complicated to build into the integration. Will keep this open for now and I'll think about it some more. |
Have you already been able to think about it a little :-)? |
@rroller Not sure if this helps but the native Nest integration can show recent video recordings on media source page of home assistant. Xbox integration does that as well for my recorded game clips. |
Tapo integration algo does that: https://github.com/JurajNyiri/HomeAssistant-Tapo-Control |
@rroller , i've already used that one (https://github.com/arthar360/TaniDVR ) with a rtsp mini server to stream the video from a old dahua/intelbras DVR into home assistant, maybe it helps |
This would be pretty useful to retrieve the associated file with the last event when possible, as camera snapshots will inevitably lag. |
Hey @blademckain is your solution still working? Trying to copy your automation but I can get it working. Probably something easy I'm missing but I'm an idiot at these things. Template variable error: 'dict object' has no attribute 'event' when rendering '{{ '.dav' in trigger.event.data.data.File }}' Edit: ok so stupid as I said. The problem is of course (?) I don't get the NewFile event from the cameras. How do you get this? I get VideoMotion and so on but no NewFile |
in the https://github.com/arthar360/TaniDVR repo, are a plugin that converts dhav to mkv video, maybe it helps even better |
It would be nice to get the events in a list with snapshots and clips, like frigate and their lovelace card. |
It's not trivial to do this due to the way the recordings are stored. It's basically one file per hour that the Dahua NVR saves and the events are then viewed in their software by opening this file at a specific position. Also the video format is a bit special but luckily it can be sliced using ffmpeg into smaller clips without having to reencode them. I setup the NVR to copy the hourly recordings to my HA server. I have also built a python script that I ran using systemd to slice these recordings using the event data in HA. The slices are then stored in a location where HA can access them through the media browser. So this way the events have their corresponding clips available I can publish the repository if you are interested. |
Dahua API to download recorded videos from cctv/nvr given start dateTime and end dateTime in ubuntu ? |
Is your feature request related to a problem? Please describe.
At the moment there is no home assistant integration that can interact with the dahua camera to view the recorded videos.
It would certainly be innovative to have a quick and easy way to access recorded videos
Describe the solution you'd like
Using API
4.11.13 Download Media File between Times
you can download the videos
Additional context
a working example here
https://mlog.club/article/3576624
The text was updated successfully, but these errors were encountered: