Release Foscam HD - Video feed with camera controls, and motion/sound detection preview
Okay, I figured it out. At first I thought it was related to the stream.readline() code and found that my devices are sending 3 HTTP headers (instead of 2) to get the length of data required for the JPEG image. This wasn't always reliable so I kept the while loop in there until it read "Content-Length:#####" that quixers had implemented so it should work for the other models as well. I added some additional verbose logging and this is the result:

Code:
06:38:54 T:6352  NOTICE: script.foscam v0.0.2: Stream Readline: --ThisString
06:38:54 T:6352  NOTICE: script.foscam v0.0.2: Stream Readline: Content-type:image/jpeg
06:38:54 T:6352  NOTICE: script.foscam v0.0.2: Stream Readline: Content-Length:17450
06:38:54 T:6352  NOTICE: script.foscam v0.0.2: Stream JPEG Read Size: 17450
06:38:54 T:6352  NOTICE: script.foscam v0.0.2: Stream Readline:
06:38:54 T:6352  NOTICE: script.foscam v0.0.2: Snapshot C:\Users\mjordan\AppData\Roaming\Kodi\userdata\addon_data\script.foscam\snapshots\snapshot.1440585534.21.jpg

The true issue turned out how we were writing to the file. I changed the following from:

Code:
if frame:
  filename = os.path.join(self.path, "snapshot.{0}.jpg".format(time.time()))
  open(filename, 'w').write(frame)

To this and everything started working again. I don't see anymore foreign errors in the code!

Code:
if frame:
  filename = os.path.join(self.path, "snapshot.{0}.jpg".format(time.time()))
  with open(filename, 'wb') as jpeg_file:
       jpeg_file.write(frame)

Now to find the best way to get multiple cameras working. Time to tryout Leopold's branch for this next...
Reply


Messages In This Thread
RE: Foscam HD - by George - 2014-03-27, 17:30
RE: Foscam HD - Video feed with camera controls, and motion/sound detection preview - by maikito26 - 2015-08-26, 13:11
Logout Mark Read Team Forum Stats Members Help
Foscam HD - Video feed with camera controls, and motion/sound detection preview1