File encoding for /cgi-bin/loadfile.cgi

Have some questions or having issues with your IP Camera(s), Post them here for the mods and other users to assist you with.
Post Reply
astone
Posts: 1
Joined: Tue Jan 26, 2021 1:05 pm

File encoding for /cgi-bin/loadfile.cgi

Post by astone »

I'm attempting to download a media file between times using the amcrest HTTP API.
/cgi-bin/loadfile.cgi

I am successfully making the request and getting back the file using the following endpoint:

Code: Select all

http://172.27.8.14/cgi-bin/loadfile.cgi?action=startLoad&channel=1&startTime=2021-01-26%2000:10:00&endTime=2021-01-26%2000:10:30&subtype=0
The file that comes back seems to be the appropriate size but I can't find a way to play it.
I assume the file is in DAV or AVI format but that doesn't seem to be the case.

I have attempted to use the Amcrest Smart Player, VidCoder, and now I'm attempting to use FFmpeg.

How can I use this file from the API request?!

Image

Code: Select all


ffprobe.exe -i "loadfile (5).cgi"
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'loadfile (5).cgi':
Metadata:
creation_time : 2021-01-25T23:00:00.000000Z
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
Duration: 00:05:00.10, start: 0.000000, bitrate: 4237 kb/s
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), none, 1920x1080, 4194 kb/s, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
Metadata:
creation_time : 2021-01-25T23:00:00.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 16000 Hz, mono, fltp, 31 kb/s (default)
Metadata:
creation_time : 2021-01-25T23:00:00.000000Z
handler_name : SoundHandler
When I attempt to use ffmpeg I get lots of these

Code: Select all


[h264 @ 000002d43a341a40] Invalid NAL unit size (1402382542 > 10260).
[h264 @ 000002d43a341a40] Error splitting the input into NAL units.
jack7
Posts: 904
Joined: Tue May 29, 2018 7:46 pm

Re: File encoding for /cgi-bin/loadfile.cgi

Post by jack7 »

I've not used loadfile before, but you might try the HandBrake program to see is you can transcode to a readable file.
GaryOkie
Posts: 418
Joined: Mon Apr 27, 2020 7:23 pm

Re: File encoding for /cgi-bin/loadfile.cgi

Post by GaryOkie »

So what device are you trying to get files from? If it's an Amcrest camera with not-so-old firmware, it should be MP4. If Dahua, it's DAV.

To confirm what format the device is configured to record media in, run:
<ip_addr>/cgi-bin/configManager.cgi?action=getConfig&name=Record[0].Format

I have no idea why you are getting a file named with CGI extension. Try renaming it to DAV and see if any Dahua s/w can view it, like SmartPSS. If it can, this s/w can convert it to MP4. FFMPEG didn't use to support DAV viewing or conversion, but I haven't tried it lately. It might be able to now.

For what it's worth, I've tried to use loadfile to get files directly from AD110 SD-Card but found the API support for it flaky as heck and tends to take it offline or freeze it.
User avatar
Revo2Maxx
Site Admin
Posts: 5907
Joined: Sat Jun 15, 2019 3:05 pm

Re: File encoding for /cgi-bin/loadfile.cgi

Post by Revo2Maxx »

This is an old Thread, However there are some that are asking in current time. So if they happen to get to this thread. If you look at the file in the Download Dir, Right click and choose to play it in VLC if you have it installed on your machine anyway.. It will play as listed with VLC..

Also as GaryOkie as posted rename the file to .dav and it will play in VLC or Smart Player..
Be Safe.
cradrew
Posts: 1
Joined: Tue Mar 12, 2024 7:04 am

Re: File encoding for /cgi-bin/loadfile.cgi

Post by cradrew »

For what it's worth three years later, I have found my software version (V2.820.00AC000.0.R, Build Date: 2022-03-25) to return a bunch of concatenated JFIF files in response to a loadfile.cgi request.

After splitting up (with a separate script) the returned file into its component, individual JFIF files, I see that they span the time interval specified and come in sets of three in which sets the images are one second apart, e.g. 15:01:01, 15:01:02, 15:01:03; 15:02:33, 15:02:34, 15:02:35...

The interval between triplets is not constant and I don't know what controls that.

Overall, the loadfile.cgi experience is pretty poor and undocumented. I've about exhausted my hacking skills and not completed what I set out to do.
User avatar
Revo2Maxx
Site Admin
Posts: 5907
Joined: Sat Jun 15, 2019 3:05 pm

Re: File encoding for /cgi-bin/loadfile.cgi

Post by Revo2Maxx »

What controls the time is in the cameras WebUI under snapshots. However keep in mind if you happen to change the time from anything over 1 second anytime you try to pull a 1 second image it won't work. In other words. You can pull an image every 30 seconds by a scripts if it was setup for 1 second in the WebUI. However if you setup for 30 seconds, if you script fires off the command you would get the first one, However once the system found an issue with any type of delay your image will be empty until it happens to fall on that right time again. However keeping it at 1 second the image fires off almost every time unless there is some large packet drop and or image didn't save because of some other error within the cameras.
Be Safe.
Post Reply