Open cylinderStudio opened 9 years ago
I'll look into it
My own camera went awol so I can't test here. Could you please install the module from temporary branch issue3 and see if it works?
npm install fvdm/nodejs-foscam#issue3
Unfortunately that didn't work for me.
I noticed in the snapshot() method that you're using fs.writeFile(). Right now, I'm accessing my Foscams by direct http requests to the cameras, and I see the same truncated/corrupt file issue when using fs.writeFile(). When using the node 'request' module for my requests, and using fs.createWriteStream() in the code below, it saves the image correctly. Could that fs.writeFile() be the problem here, as well?
request.get('http://192.168.1.2:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=camAdmin&pwd=myPassword).pipe(fs.createWriteStream('images/save.jpg'));
I'll check it out
I found the problem, fs.createWriteStream
is indeed the solution. My camera had a lower resolution than your 720p, the filesize might have been just within range for fs.writeFile
.
Can you please retry? I'm flying blind without a camera to test on and the code is kind of ancient :fearful:
Yes that should work
OK, installing from the same...
npm install fvdm/nodejs-foscam#issue3
I'm still getting a corrupt image, 345 bytes.
hmz :cry:
Bummer! It must be something related to this model of Foscam. Using the code below, the rotation doesn't occur either:
var cam = require('foscam')
cam.setup({
host: '192.168.1.2',
port: 88,
user: 'myUsername',
pass: 'myPassword'
})
// start rotating left
cam.control.decoder('left', function() {
// stop rotation
cam.control.decoder('stop left', function() {
// take a picture and store it on your computer
cam.snapshot('path/save.jpg', console.log)
})
})
What do you get when you open the 345 bytes file in a plain text editor?
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>404 - Not Found</title>
</head>
<body>
<h1>404 - Not Found</h1>
</body>
</html>
Ah that explains a lot. Can you provide the HTML of one of the web interface pages that has those control buttons?
Yep, emailing now.
I have a Foscam FI9831W which appears to function well, as I can login and changes settings, check the live feed of it at 720p. The library loads fine in my NodeJS application, but the snapshot() method takes a picture and saves it as a JPEG with 344 bytes that's damaged or truncated and can't be opened.