hikvision - extract thousands of images from camera sd card?

Hi Alex,
First of all, I would like to say a massive thank you for creating this script. It is brilliant.

But, like always someone has to have a problem and it happens to be me. For some reason, the script will not pick up my input and output directories. I followed your video tutorial to the letter, including putting the quotes around each path.
I used F:\extract.pl "F:\datadir0" "F:\jpg"
and I get the error message "Need input directory" "Usage Extract.pl inputdir outputdir at F:\extract.pl in line 8"
The folders are on an external drive, so I tried moving them to a local hard drive but this did not make any difference. I have checked the folder paths etc and they are all correct. I am hoping that you can shed some of your infinite wisdom as to why this would be happening and how to fix it.
Thanks
Brendon
 
Hi,

Delete this line from the script:
Code:
my ($inputDir, $outputDir) = @ARGV;

Replace it with (make sure to use your folders location and forward slash / in the path names):
Code:
my $inputDir = "F:/datadir0";
my $outputDir = "F:/JPG";

Run the script without providing the input and output folders after Extract.pl, so just enter "F:\Extract.pl" and press Enter.

Or, if you don't want to change the script, uninstall ActiveState Perl and install Strawberry Perl 32bit from here Strawberry Perl for Windows
 
Last edited:
Hey, we're so close.
Installed Perl 5.28, but ppm has been decommissioned.
Tried to use CPAN but it couldn't find dmake.
Couldn't figure out dmake on Win64, so uninstalled and installed 5.26.
Input & Output folders didn't work, so I made the change above.

Now I'm getting:
Died at C:\TimeLapse\Extract.pl line 42, <STDIN> line 2.Died at C:\TimeLapse\Extract.pl line 42, <STDIN> line 2.

Line 42 is open (FH,$inputDir . "/index00p.bin") or die;
index00p.bin does exist in our C:\TimeLapse\datadir0 folder.

Any advice?
 
Last edited:
Sorry, I made a mistake in the post above.

Use forward slash / in the directory path
Code:
my $inputDir = "F:/datadir0";
my $outputDir = "F:/JPG";

The input / output folder error is caused by ActiveState Perl. Use Strawberryperl so you don't have to add the input / output directory in the script.
Uninstall ActiveState Perl and install Strawberryperl 32bit (even if your OS is 64bit) from here Strawberry Perl for Windows
Use the original unmodified script, it should be able to work with the input and output folders provided as parameters.
I've tested Strawberryperl on Windows 10 and when I first run the script from cmd it asked me to choose the default program to open the .pl file type. You have to choose Perl Interpreter and check the "Always use this app to open .pl files" box. Then you need to run the script again from the cmd window.
 
Last edited:
I'm glad to hear it works.
The update wasn't there before. I've updated all my previous posts to include the Strawberry Perl solution a couple hours ago, so you have nothing to apologize for.
 
Hi Alex,

Thanks for the script it should hopefully save me hours and hours!!!

One problem however, it seems to be working butloads of the images seem to to be corrupt or unviewable.

Any ideas on what could be causing this?

Thanks,corruptimages.png
 
Hi, and sorry for the late reply. Probably the script fails to find the correct headerSize.
If you can please send me your index00p.bin file and I will try to update the script.
 
I've updated the script and now it automatically finds the headerSize. There's no more need to use a HEX editor to find it or to change anything in the script's code.

I've also added the option to use a date and time interval limit when extracting the images. This saves a lot of time if you have lots of images stored but only want to extract some of them.

This is the updated video tutorial
2019 UPDATE: In the tutorial I've used ActiveState Perl, but the script doesn't work with the latest version. Make sure to download and install Strawberry Perl instead of ActiveState Perl.
Strawberry Perl for Windows



I've tested the script using a lot of different index00p.bin files to see if it fails to find the headerSize. It didn't, but if for some of you the extracted jpg files are corrupted (only half the image loads or doesn't load at all) you can send me your index00p.bin file and I will update the script.

This is amazing! Let me buy you a beer! Saved a lot of time!
 
Hi Alex_N-
We had three cameras that all recorded in the .pic format. The script is genius.
It worked great on the first folder.

When trying to process the other two folders the script starts and asks for the path and then the naming and HANGS.

I let it run all night the other night and instead of extracting, it gives me a list of the pic files, with starting and ending information to the pic files.

perl_output.PNG

At other times if I control+C on the process and don't wait I can sometimes get an error message - I have included those as well.
I made sure to be running Strawberry Perl 32 bit. I tried hard coding the path to the directories - it did not seem to matter. I took a look at the files with the hex viewer, but I don't know enough about the file format to know what I am looking for. Interesting enough the date inside the files show a goofy date - like around the turn of the century 1900. I was hoping you might take a look at the .bin files and see if maybe they are corrupted or something?
 

Attachments

  • error_stopped.PNG
    error_stopped.PNG
    9.6 KB · Views: 9
  • perl_error.PNG
    perl_error.PNG
    12.8 KB · Views: 9
  • task.PNG
    task.PNG
    16.1 KB · Views: 9
Not relevant to the recent ask for help, but for people reading this for G2 (G3) cameras, be advised that they've changed the pic index to an sqlite3 model.

It used to be pic_db_index00 but since latest fw version it's now event_db_index00 for some reason with a different schema.
 
  • Like
Reactions: mollaomer50
Does anyone have solution for the new model?
I can open the SD card and see the files, but when I insert the card on Camere in Status i see error. The Photos are important.
In SD card I have: -backupinfo00.bin..
-bk_pic_segment_db_index_chan1-to 16
-event_db_index00-01
-HIKWS
-hiv0000.mp4
-hiv0000.pic-00111.pic
-index00.bin-01
pic_segment_db_index00000-00111
 
I think you can use the Python script. I've made a video tutorial about using it here hikvision - extract thousands of images from camera sd card?, the only downside is it will not name your files using the date and time of capture. The files will be named Picture-1.jpg Picture-2.jpg...

I don't have a new camera or some file samples from one, so I can't update the Perl script that extracts the files and uses their date and time for the filenames.
 
  • Like
Reactions: Bigo
Thanks mate
Just extracted a 512gb sd over 10000 images all perfect
cheers


I've updated the script and now it automatically finds the headerSize. There's no more need to use a HEX editor to find it or to change anything in the script's code.

I've also added the option to use a date and time interval limit when extracting the images. This saves a lot of time if you have lots of images stored but only want to extract some of them.

This is the updated video tutorial
2019 UPDATE: In the tutorial I've used ActiveState Perl, but the script doesn't work with the latest version. Make sure to download and install Strawberry Perl instead of ActiveState Perl.
Strawberry Perl for Windows



I've tested the script using a lot of different index00p.bin files to see if it fails to find the headerSize. It didn't, but if for some of you the extracted jpg files are corrupted (only half the image loads or doesn't load at all) you can send me your index00p.bin file and I will update the script.
 
Hi Alex,

Thanks for the script it should hopefully save me hours and hours!!!

One problem however, it seems to be working butloads of the images seem to to be corrupt or unviewable.

Any ideas on what could be causing this?

Thanks,View attachment 52043
i found if i pulled them of the sd i had file corruption
i copied the whole sd to hard drive and then extracted to same hard drive no errors at all
 
Hi,
I have a SD card in the camera and I can access this via the interface using a browser.
Will the script work in this setup?
I do not know the path of the SD card, so how do I do this?

Thanks
 
Put the card in an external reader and run the script - you'll need to install python - but look at the guide hikvision - extract thousands of images from camera sd card?

Good luck

Dave
My challenge is that the camera is difficult to access physically (sitting high on a pole), so I want to this via the LAN cable.
I can access the camera via LAN, no problem, but I am still limited by only 100 pictues per download.

Any solutions to this?