How to get FTP to overwrite picture name each time?

Joined
Nov 11, 2014
Messages
16
Reaction score
0
I've got FTP working but I need the camera to overwrite the uploaded file name each time to avoid loading up my server with too many files. And how do I get it to use the same file name each time?
thanks! Camera is a 2CD2032-I
 

LittleBrother

Pulling my weight
Joined
Sep 16, 2014
Messages
480
Reaction score
119
I don't think you can. There's very little flexibility with FTP on this. I wrote a standalone app that manages the files, puts them in properly dated folders and renames them according to my preferred criteria because the camera gives no such options. It just piles everything into the same root folder, so I just grab them from that folder and name and place them where I want.

If you do want a single file only that is always named just one thing, but continually updated from the camera, you could write a script for example in powershell to run on your PC (assuming you've got one in place) and instead of FTP it just pulls a file from the camera on a specified interval and then you only ever have one image, but it's always the most recent one.
 
Joined
Nov 11, 2014
Messages
16
Reaction score
0
Thank you for your reply! What you are describing is exactly what I want to do. Unfortunately I have zero knowledge of how to write a script in power shel as you described. I'm not sure of what direction I should go at this point.
 

LittleBrother

Pulling my weight
Joined
Sep 16, 2014
Messages
480
Reaction score
119
Thank you for your reply! What you are describing is exactly what I want to do. Unfortunately I have zero knowledge of how to write a script in power shel as you described. I'm not sure of what direction I should go at this point.
Where is your FTP server; on what hardware? Do you have a PC running 24/7 that you think you could put this with? If so I can outline the steps to get powershell to pull an image off the camera at an interval of your choosing, and really it's not too tricky. First we should see if anybody has any other input on how to make FTP on these hikvisions behave better, though. The placing of all files into one folder seems unbelievably silly, but I see no way around it using the options under configuration.
 
Joined
Nov 11, 2014
Messages
16
Reaction score
0
My server is a paid hosted account under my domain name. I've run FTP before and I do know how to set that up. I am running a 24 hr pc (Windows XP) that I can run the script on. If I could get a file placed on this pc's hard drive then I can FTP it to my server using other software easily. I just need to get a picture file into a directory that is overwritten each time to avoid filling up my hard drive. Also the name needs to stay the same each time so that my FTP software can find it.
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,689
Reaction score
14,057
Location
USA
That should be really easy. I don't know anything about powershell either, but it would be like a 5 minute project to build a Windows Service in C# that would run in the background and save a picture to a location on disk at an interval. It would be significantly more complicated, but the service could also FTP the picture, too. I haven't found a really good FTP library for .NET yet, but there is some built-in functionality that works but isn't fun to use.

I'm going to be pretty busy for a few days but I may be able to squeeze that in somewhere.
 
Joined
Nov 11, 2014
Messages
16
Reaction score
0
Any help at all would be very much appreciated! PM me if you need specific details. I basically only need a script to grab a jpg photo, name it something and then download it into a local folder on my hard drive. It needs to keep the same filename each time, therefore overwriting the old file. That's about it. I can go from there. Thank you very much again as I need this badly to even be able to use this camera.
 

LittleBrother

Pulling my weight
Joined
Sep 16, 2014
Messages
480
Reaction score
119
Here is a walkthrough to get you started. I have written these steps while confirming they work on my machine. Lots of text here, but only because I'm thorough :)

With your specific requirement in mind, as opposed to taking the FTP file that is being deposited and renaming it, another possible approach is this one. Confirmed as working on 5.2.0 firmware, and should work on some earlier ones as well. This is an authenticated approach, which is necessary to grab images on 5.2.0 (earlier it wasn't necessary to authenticate to pull the jpg).

1) Go to this address: http://admin:12345@192.168.1.150:80/Streaming/channels/1/picture

- for this example I'm using the default admin and 12345 password, but you can make another account on the camera with less permissions that can do this
- change 192.168.1.150 to whatever your camera's IP address is
- note the specification of port 80. You can leave that out, as port 80 is default, but if you change the TCP port you can put a different one in
- When you visit that URL you should see a JPG pulled. Unlike the FTP setup you can't specify its image quality (there may be a way with variations on the URL but in very brief fiddling I didn't find one that worked well)

Assuming step 1 worked, go to step 2:

2) Install Power Shell in your system if it's not already there. It is installed by default in modern versions of windows. If you don't have it on XP you can google how to install. It's a free microsoft product

3) Create a folder called c:\powerimages (or whatever, it doesn't matter what!). Within that folder create a new text file, give it an extension of .ps1. Call the file something like imagepull.ps1

4) Put exactly this into imagepull.ps1, changing only where you see a word encapsulated with < >. Then save.

$url = "http://<ip address>:<TCP port>/Streaming/channels/1/picture"
$wc = New-Object System.Net.WebClient
$wc.Credentials = New-Object System.Net.NetworkCredential("<username>", "<password>");
$wc.DownloadFile($url, "C:\powerimages\snapshot.jpg")

5) You now have a powershell script that when executed pulls an image from the camera and names it snapshot.jpg. It will overwrite previous snapshot.jpg if there is one.

6) With your powershell window open go:

c: <enter>
cd powerimages <enter>
.\imagepull.ps1 <enter>

Notice how you probably received an error message about permissions? That's because powershell isn't setup to allow even locally created scripts to run. Fix that by typing:

Set-ExecutionPolicy RemoteSigned <enter>


Now try again. Is the script working properly?

Just had another idea. If it's STILL not working properly, google "download .net", to make sure you have a recent version of .net running, since this script leverages that. Assuming your XP machine is being used for anything though chances are it's already got a version on there that will work here.


7) if it is, now you can right-click the imagepull.ps1 within your windows explorer and say "run with powershell"


Assuming all the above is working for you, let me know and then the final step will be to get your machine to automatically run this script on the interval you specify, which you'll do with windows scheduled tasks, as they can be set to run 24/7 on whichever interval you like, specifically with this syntax:

powershell -file c:\powerimages\imagepull.ps1 -WindowStyle Hidden

One caveat there is that even with windowstyle hidden your system may still have a brief pop up every time it runs. If so, and that is unacceptable, you'll need to create a second user account on your system and specify that account for the windows scheduler to run under. That way, since you're logged in as John Doe, and the other user account that the windows scheduled tasks is running is Jane Doe, you never see what she's doing, thus the powershell runs without you seeing a pop up.
 
Last edited by a moderator:

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,689
Reaction score
14,057
Location
USA
I recommend doing what LittleBrother suggested. I had no idea powershell scripts could use the .NET framework like that.

I have one thing possibly worth mentioning. I've noticed in C# apps that the WebClient takes a significant amount of time to automatically determine proxy configuration, which typically serves no purpose except to add a couple seconds of delay to establishing the first network connection. I bet the same problem affects your powershell script, and if so you can likely fix it with $webclient.Proxy = $null
 
Joined
Nov 11, 2014
Messages
16
Reaction score
0
What a great script and I thank you very much for your efforts! I did try it but I am having problems with downloading powershell. Thus I think it's in my best interest to purchase a new desktop pc before I spend anymore time with my current old XP setup. I'll look into picking one up tomorrow if possible and then I will continue forward. You have been more than helpful and I am extremely grateful. I'm also optimistic that we can get this issue resolved. Thanks again!
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,689
Reaction score
14,057
Location
USA
Do yourself a big favor and research what kind of PC you need. There is an enormous difference in speed and useful life span when you compare a $500 all-in-one with some celeron CPU, and a $500 refurbished business class system with a 3 year next business day warranty and an i7-4770 CPU.
 

LittleBrother

Pulling my weight
Joined
Sep 16, 2014
Messages
480
Reaction score
119
I imagine you can get this to run on XP, but that OS tells me your PC is indeed in need of an upgrade anyway ;)

bp2008, I didn't know powershell could do this until pretty recently, either!
 

fenderman

Staff member
Joined
Mar 9, 2014
Messages
36,907
Reaction score
21,295
+1 on @bp2008's suggestion....dont buy local, pick a a refurb that is usually a few months old..if that... business class windows 8.1 or 7 pro....like the hp elitedesk 800 g1 http://www.ebay.com/sch/i.html?_odkw=dell+3020&_sop=15&_from=R40|R40&LH_BIN=1&_osacat=171957&_from=R40&_trksid=p2045573.m570.l1313.TR7.TRC0.A0.H0.Xhp+elitedesk&_nkw=hp+elitedesk&_sacat=171957
the usdt (ultra slim desk top) has no room for expansion but the SFF and tower do...
Also look at the dell optiplex 3020 and 9020....great deals on ebay or the dell outlet (when they have a sale). If you are not doing any video processing or heavy cpu tasks an i3 will suffice...Pop an SSD in there and it will fly for years...
For my daily use pc, have an i5 first gen and with an ssd it just fly's i cannot justify replacing it...
 
Last edited by a moderator:
As an eBay Associate IPCamTalk earns from qualifying purchases.
Joined
Nov 11, 2014
Messages
16
Reaction score
0
I appreciate all of the good advice about selecting a new PC. I think I have settled on a refurbished off business lease Dell 745 tower. It has Windows 7 Professional. Here are the specs;
Intel Core 2 Duo processor
1.86GHz, 2MB Cache


4GB DDR2 SDRAM system memory (expandable to 8GB)
Gives you the power to handle most power-hungry applications and tons of multimedia work


1TB SATA hard drive
Store 666,000 photos, 285,000 songs or 526 hours of HD video and more


DVD/CD-RW drive
Watch movies, and read and write CDs in multiple formats


10/100/1000Mbps Ethernet
Connect to a broadband modem with wired Ethernet


Integrated Intel Graphics Media Accelerator 3000


I think this will be more than enough for my somewhat modest needs.
any input is welcomed!
 
Last edited by a moderator:

LittleBrother

Pulling my weight
Joined
Sep 16, 2014
Messages
480
Reaction score
119
That's a fairly old PC. Not to say it won't work for you, but as long as you're paying in the $200 price range it seems fine. For surfing the net, with a clean windows install, it will be fine, though. I second, third, and fourth fenderman's suggestion about an SSD. I have a small one onto which my operating system is installed and a larger mechanical drive for a lot of data. Putting the OS on an SSD makes an unreal difference. I have a dual core celeron desktop at home and with its ssd it's much quicker than my quad core i5 laptop, which has a mechanical. I can boot from a cold start to the windows 8.1 login screen in under 20 seconds (8.1 boots quicker than 7 anyway, though). There are other tricks I've not bothered with that can bring boot times under 10 seconds. Partly that is windows 8.1, partly it's an SSD.

You can always get an SSD later, though, and their prices are coming down fast.
 

fenderman

Staff member
Joined
Mar 9, 2014
Messages
36,907
Reaction score
21,295
@Flyingvranch I would not get that machine unless its being offered for 100 or less, even then i would stay away. That processor is at least 8 years old..launched in 06....good chance the machine has been running since then...there is no value there...you can get a machine that is just a few months old for cheap this is 255 for (add another 2gb ram for cheap if need be)http://outlet.lenovo.com/outlet_us/itemdetails/10B6X002US/445
with 4gb ram http://outlet.lenovo.com/outlet_us/itemdetails/10B4X026CC/445 $273
with a modern haswell i3 http://outlet.lenovo.com/outlet_us/itemdetails/10B6X003US/445 $290

windows 7 home system http://outlet.lenovo.com/outlet_us/itemdetails/57RF0499/445 $232
I prefer the business models though..
 
Joined
Nov 11, 2014
Messages
16
Reaction score
0
Well thanks for y'all's concern but I already ordered it and its on its way. I'll get it Tuesday and check back here when I get it set up. I'm pretty sure it will do just fine. By the way I paid $180 for it. Not too bad. I chose it because it comes with Win 7 professional and it has a three year warranty. So we will see......
 

fenderman

Staff member
Joined
Mar 9, 2014
Messages
36,907
Reaction score
21,295
I would send it right back to them and get something good with your hard earned money..even at 180 there are way better deals around than an 8 year old pc...
Most of the business systems that come with 8.1 pro also allow a downgrade to windows 7 or just leave 8.1 and install classic shell you get the best of both worlds....you should also consider power consumption vs a modern system ...if you are going to leave the system on 24/7 as a server or to perform the scripts in your original posts...depending on where you live it could easily add up to 20-50 or more dollars a year...
Here is an example http://www.ebay.com/itm/ThinkCentre-M72e-SFF-Desktop-Pentium-G2020-2-90-GHz-4GB-RAM-500GB-HDD-Win-7-Pro-/231347300323?pt=Desktop_PCs&hash=item35dd5fa7e3
200 dollars for a system hat is less than two years old...
 
As an eBay Associate IPCamTalk earns from qualifying purchases.
Joined
Nov 11, 2014
Messages
16
Reaction score
0
Y'all have my interest going concerning the SSD. I wonder how big of a SSD drive I would need to install the Win7 Pro operating system on? Also concerning power requirements, would the desktop use less overall electricity if the operating system is on the SSD while data is on the original drive and the pc is on 24 hrs?
 

fenderman

Staff member
Joined
Mar 9, 2014
Messages
36,907
Reaction score
21,295
If its just windows 7 and several programs you can get away with 64...however being that the 128 drives are 70 dollars, i would get 128 to have some headroom. Go with crucial, intel or samsung, the others are not as reliable.
http://www.amazon.com/dp/B00KFAGD88/ref=twister_B00KG8HLLC
http://www.amazon.com/Intel-Solid-State-Drive-Retail/dp/B00F0RD5H8/ref=sr_1_10?s=pc&ie=UTF8&qid=1415976176&sr=1-10&keywords=ssd
As far as power consumption there wont be any significant savings...the performance difference is night and day though..
 
As an Amazon Associate IPCamTalk earns from qualifying purchases.
Top