Created
March 12, 2018 23:20
-
-
Save anonymous/10cd235949ae354cb49cb3564bd722c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Splits a ".pic" file created by a Hikvision camera | |
# into single jpeg files | |
if (! (${file}=$ARGV[0]) ) { | |
print "Usage: $0 filename\n"; exit 1; | |
} | |
open FILE, ${file}; | |
while (<FILE>){ | |
${jpeg} .= $_; | |
} | |
close ${file}; | |
${index}=0; | |
while ( index(${jpeg}, "\xFF\xD8") != -1 ) { | |
$start = index(${jpeg}, "\xFF\xD8"); | |
$end = index(${jpeg}, "\xFF\xD9"); | |
${singlejpeg} = substr(${jpeg}, $start, $end); | |
${jpeg} = substr(${jpeg}, $end+1); | |
open (OUTFILE, ">${file}_${index}.jpg"); | |
print OUTFILE ${singlejpeg}; | |
close OUTFILE; | |
${index}++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment