starkillerOG / reolink_aio

Reolink NVR/camera API PyPI package
MIT License
79 stars 16 forks source link

request_vod_files does not return VOD files #77

Closed jrukavina closed 2 months ago

jrukavina commented 2 months ago

Describe the bug I am trying to find recorded video files and download them from Reolink Duo 3 PoE camera. Calling request_vod_files on a camera gets me search results indicating that it indeed found some recordings in the searched time period but I does not actually return those recordings (filenames).

The result i get looks something like this: ([<VOD_search_status: year 2024, month 8, days (30,)>], [])

The second list should contain VOD_files.

To Reproduce This is the code: host = Host(ip, username, password, port=80) ret = await host.request_vod_files(channel=0, start=dt.now() - timedelta(days=2), end=dt.now(), status_only=False, stream='sub') print(ret)

Expected behavior ret should contain a list of VOD_search_status and VOD_files

Environment: Reolink Duo 3 PoE

starkillerOG commented 2 months ago

You can not return more files than 1 day at a time, otherwise the camera just does not respond with the file names.

jrukavina commented 2 months ago

@starkillerOG thank you very much, this works now that I have reduced the search time window!

I have also managed to download the file using the StreamReader in typings.VOD_download. Could you take a look if I am downloading the file as intended? Is there a function in your library which could do the actual download for me or do i need to use aiohttp.StreamReader myself? This is the code, download is a bit slow but I am guessing it could be sped up by downloading chunks in parallel:

ret = await host.download_vod(files[0].file_name) chunk_size = 1024 * 16 # 16 KB with open(ret.filename, 'wb') as f: while True: chunk = await ret.stream.read(chunk_size) # Adjust chunk size if necessary if not chunk: break f.write(chunk)

starkillerOG commented 2 months ago

This would indeed work, but a nicer option is to use get_vod_source with VodRequestType.PLAYBACK:

get_vod_source(channel, files[0]. file_name, request_type = VodRequestType.PLAYBACK)

that will return the URL from which you can directly get the mp4 file.