[SOLVED]Control Page Refreshing Image Help

Posted on
Sun Dec 01, 2013 9:21 pm
rob_hut offline
Posts: 30
Joined: May 04, 2009

[SOLVED]Control Page Refreshing Image Help

I am using a xx39a Airsight camera, the only stream I can seem to get from it is http://[IPADDRESS]/cgi-bin/videostream.cgi?user=[USERNAME]&pwd=[PASSWORD] which is a videostream.

apparently I may be able to use rtsp://[IPADDRESS]:[PORT]/live/av0?user=[USERNAME]&passwd=[PASSWORD] as well

I am attempting to embed this into a control page. I can point a refreshing image (I run a server, and on a specific page I set the src attribute of an image to this URL) to it but in the log I get : index.php returned type text/html (image required).

Id there a way to embed a video on a control page? that would be the most amazing to be able to directly embed a videostream!!! Is there a way using htaccess and or php header directives to fool the system? Make it thinks its a png not a videostream? Im grasping here

Any thoughts? Ive tried setting up securityspy cameras, but when I do it crashes/locks up my system, thats another story for another post..

Cheers!

Posted on
Mon Dec 02, 2013 4:49 pm
matt (support) offline
Site Admin
User avatar
Posts: 16352
Joined: Jan 27, 2003
Location: Texas

Re: Control Page Refreshing Image Help

For this I would recommend using SecuritySpy (or Evocam). They both have built in HTTP servers that can return JPEG image snapshots of the video feed which Indigo can use. Some IP cameras also provide a JPEG image URL too. But Indigo doesn't currently support video streams, so trying to point directly to the video feed isn't going to work. I agree it would be nice if it did...

Image

Posted on
Mon Dec 02, 2013 5:38 pm
ckeyes888 offline
Posts: 1762
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Control Page Refreshing Image Help

+100 on Touch handling video streams. It would be a huge improvement.

Carl

Posted on
Tue Dec 03, 2013 12:59 pm
rob_hut offline
Posts: 30
Joined: May 04, 2009

Re: Control Page Refreshing Image Help

So this wasnt easy, but I made it work, here's how.

Using Security Spy (SS) I set up cameras to take images at a regular interval, and movies and images when triggered by motion. I run a server so I set the images to be save at a specific location available via the intranet.

Now the issue arises where I cannot control the names of the image files. Meaning, I cant tell SS to save the image at a specific location and just name it 'Living_Room.jpg'. It gets put into a dated folder, with the name of the camera name and timestamp (ie: 1969-01-31 00-00-00 LivingRoom.jpg) I get the logic, however a little more control would be nice.

Now we have the fact that Indigo control pages will only accept an image URL. So I created a webpage at the URL location respective to a folder for each camera location name with the code below (index.php). So Indigo is set for each control page item to look at that URL location, at the index.php file.

Code: Select all
<?php
  $dir        = "/path/to/dir/with/images/for/location";
  // we only want to look at these files       
  $pattern    = '\.(jpeg|jpg|png|gif)$'; 
  $newstamp   = "";         
  $newname    = "";
  // lets start looking!
  if ($handle = opendir($dir)) {               
    while (false !== ($fname = readdir($handle)))  {           
      if (ereg('^\.{1,2}$',$fname)) continue;           
      if (! ereg($pattern,$fname)) continue;
      // if current file is newer, store it           
      $timedat = filemtime("$dir/$fname");           
      if ($timedat > $newstamp) {
        $newstamp = $timedat;
        $newname = $fname;
      }
    }
  }
  closedir ($handle);
  // set the path to most recent file
  $fileLocation = date("Y-m-d") . "/" . $newname;
  // redirect to the most recent image
  header("Location:".$fileLocation);
?>


This means that when the control page searches for the image at index.php, it actually gets redirected to the most recent image file.

You can expand this further to create web pages with all the images in a slideshow, and all the movies in a gallery (which Ill do at some point).

I would also recommend using .htaccess to only allow access from the local intranet.
Code: Select all
<FilesMatch "\.(gif|jpe?g|png|php)$">
    Order deny,allow
    Deny from all
    Allow from 10.0
    Allow from 192.168
    Allow from 10.1
</FilesMatch>


I hope this helps some people!

Posted on
Fri Dec 13, 2013 1:01 pm
rjs104 offline
Posts: 51
Joined: Jun 21, 2013

Re: Control Page Refreshing Image Help

Hi,

I'm liking the idea of this PHP script, but I can't get it to work. My PHP programming skills are very basic though.

On my system I get this error:

"Warning: opendir(/my path/inserted/here) [function.opendir]: failed to open dir: Permission denied in /Library/WebServer/Documents/index.php on line 14"

All the conceivable places I've made the file permissions such that everyone has read and write access, thinking that might be a problem.

Any ideas to try?

Cheers,

Richard.

Posted on
Fri Dec 13, 2013 3:32 pm
rob_hut offline
Posts: 30
Joined: May 04, 2009

Re: Control Page Refreshing Image Help

perhaps post the code you are using? if the dir is 755 it should be fine. try setting it to 777 and see if that works though you may not want to leave it that way.

sometimes, it helps to use PHP to create the directory, before you try to use it. That way the script that is using it (PHP) is the same group that is trying to use it. Sometimes this helps Look up mkdir

This should be pretty straight forward...

Posted on
Fri Dec 13, 2013 3:39 pm
rjs104 offline
Posts: 51
Joined: Jun 21, 2013

Re: Control Page Refreshing Image Help

Hi Rob,

Thanks for your reply. I'm obviously being a bit thick, so apologies. What do you mean by setting the dir to 755 or 777?

The code I'm using is an exact copy of the one you posted above, with the only change that I've put my path to a given camera folder in the $dir variable at the top.

Should I change more, or is it quite important where the index.php is located relative to this path?

Sorry for the questions!

R

Posted on
Fri Dec 13, 2013 6:52 pm
rob_hut offline
Posts: 30
Joined: May 04, 2009

Re: Control Page Refreshing Image Help

Whatever dir you make, the index file should be in that folder. So in the case of being on a Mac make sure your webserver is turned on in the system prefs.
/Library is different than ~/Library. The former is the Library of the whole system where the latter is your user profiles Library. You want something like: /Library/WebServer/Documents/CameraFolder where CameraFolder is your directory. I set up each camera with its own directory. So if my folder name is Camera, the path will look like this: /Library/WebServer/Documents/Camera. To find the folder in the finder, make finder the active application then use the key strike [shift+command+g] then type in: /Library/WebServer/Documents then hit return. Create your folder, then select your folder, then Get Info on the folder Finder > File > Get Info OR command+i Then down at the bottom you should see settings and permissions. so you and staff can read & write, and everyone else can read.
You can do this via the Terminal.app as well.
Code: Select all
/Users/roberthuttinger$ cd /Library/WebServer/Documents/
/Users/roberthuttinger$ ls
PoweredByMacOSX.gif      PoweredByMacOSXLarge.gif   index.html.en
/Users/roberthuttinger$ sudo mkdir Cameras
Password: <your_user_password>
/Users/roberthuttinger$ chmod 755 Cameras
/Users/roberthuttinger$ ls -tail
total 72
6319811 drwxr-xr-x  6 root  wheel    204 Dec 13 19:50 .
9396671 drwxr-xr-x  2 root  wheel     68 Dec 13 19:50 Cameras
6319814 -rw-r--r--  1 root  wheel     44 Oct 23 14:02 index.html.en
6319812 -rw-r--r--  1 root  wheel   3726 Aug 25 00:30 PoweredByMacOSX.gif
6319813 -rw-r--r--  1 root  wheel  31958 Aug 25 00:30 PoweredByMacOSXLarge.gif
6319809 drwxr-xr-x  5 root  wheel    170 Aug 25 00:30 ..

Posted on
Fri Dec 13, 2013 7:02 pm
rob_hut offline
Posts: 30
Joined: May 04, 2009

Re: Control Page Refreshing Image Help

a more precise example
Code: Select all
// this is where the images are being sent from securityspy
  $dir = "/Library/WebServer/Documents/Security/Lounge/".date('Y-m-d') . "/";         
$pattern = '\.(jpg|png|gif|jpeg)$'; // check only file with these ext.         
$newstamp = 0;           
$newname = "";

if ($handle = opendir($dir)) {               
       while (false !== ($fname = readdir($handle)))  {           
         // Eliminate current directory, parent directory           
         if (ereg('^\.{1,2}$',$fname)) continue;           
         // Eliminate other pages not in pattern           
         if (! ereg($pattern,$fname)) continue;           
         $timedat = filemtime("$dir/$fname");           
         if ($timedat > $newstamp) {
            $newstamp = $timedat;
            $newname = $fname;
          }
         }
        }
closedir ($handle);
$newLoc = date("Y-m-d") . "/" . $newname;
header('Location: '.$newLoc);
exit();

Posted on
Sat Dec 14, 2013 10:11 am
rjs104 offline
Posts: 51
Joined: Jun 21, 2013

Re: Control Page Refreshing Image Help

Hi Rob,

This really helps clarify things for me - I shall give it a go when I'm back in front of my system at home.

Many thanks!

Richard.

Posted on
Sun Dec 15, 2013 5:16 am
rjs104 offline
Posts: 51
Joined: Jun 21, 2013

Re: Control Page Refreshing Image Help

Yep - that all works now.

Brilliant!!! Great stuff!

Many thanks for your help.

R

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests