Hello Guest, if you are reading this it means you have not registered yet. Please take a second, Click here to register, and in a few simple steps you will be able to enjoy our community and use our OpenViX support section.
Results 1 to 15 of 15

Thread: IP Camera snapshot/video html code

  1. #1
    zYx's Avatar
    Title
    Member
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    5
    Thanked 8 Times in 6 Posts

    IP Camera snapshot/video html code

    Hi there,

    I'm trying to work out how to get my IP cam picture diplayed on the LCD.

    The following is the code I use with my IP cam to display all my CCTV cameras on my G19 LCD screen thanks to LCDhost. I was wondering if I could make it work with LCD4Linux:



    HTML Code:
    <html>
    <head>
    <style type="text/css">
    <!--
    body{
    margin: 0; 
    padding: 0;
    }
    --></style>
    </head>
    <body>
     <tr>
        <td align="center" valign="middle" border="0"><span style="text-align:center;"><img width="320" height="240" src="http://88.77.66.55:4444/snapshot.cgi?user=username&pwd=password&t=" onload='setTimeout(function() {src = src.substring(0, (src.lastIndexOf("t=")+2))+(new Date()).getTime()}, 1000)' onerror='setTimeout(function() {src = src.substring(0, (src.lastIndexOf("t=")+2))+(new Date()).getTime()}, 5000)' alt=''" /></span></td>
      </tr>
    </body>
    </html>

  2. #2
    Walt's Avatar
    Title
    Senior Member
    Join Date
    Jan 2014
    Posts
    366
    Thanks
    65
    Thanked 46 Times in 43 Posts
    Great idea. Would like to know this myself.

  3. #3

    Title
    ViX Beta Tester
    Join Date
    Jun 2014
    Location
    UK
    Posts
    642
    Thanks
    157
    Thanked 318 Times in 173 Posts
    You can put a URL into the show picture config, so it should work if you put in:
    http://88.77.66.55:4444/snapshot.cgi...wd=password&t=

    Not sure if this will refresh though so you'll need to test - I've only checked with a static image. The alternative is the www-internet converter which can be refreshed...

  4. #4
    zYx's Avatar
    Title
    Member
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    5
    Thanked 8 Times in 6 Posts
    I'm not at home now so I can't check, but do you think if I use a few screens, will the snapshot refresh every time the screen changes?

    It would be nice to just be able to use any html code

  5. #5

    Title
    ViX Beta Tester
    Join Date
    Jun 2014
    Location
    UK
    Posts
    642
    Thanks
    157
    Thanked 318 Times in 173 Posts
    You can put a URL into the show picture config, so it should work if you put in:
    http://88.77.66.55:4444/snapshot.cgi...wd=password&t=

    Not sure if this will refresh though so you'll need to test - I've only checked with a static image. The alternative is the www-internet convertor

  6. #6
    zYx's Avatar
    Title
    Member
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    5
    Thanked 8 Times in 6 Posts
    Weird. I thought it wasn't working at first, but it looks like it does. I wonder if I can use a video stream instead :P
    Last edited by zYx; 28-12-14 at 19:52.

  7. #7

    Title
    ViX Beta Tester
    Join Date
    Jun 2014
    Location
    UK
    Posts
    642
    Thanks
    157
    Thanked 318 Times in 173 Posts
    excellent - i'm not sure it can stream a video, but a 1 frame a second image would be good enough

    (not sure what happened with the dupe post!)

  8. #8
    zYx's Avatar
    Title
    Member
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    5
    Thanked 8 Times in 6 Posts
    I'm not sure how this refreshing supposed to work here, but the screen refreshes every 5 seconds. It's OK for the time being.

    Thanks for the tip anyway. Why didn't I try it before? :P

    I haven't tried leaving the IP cam screen on for long, but I did manage to view my cams at 2-4 fps with "quick update" option selected.

  9. #9
    Rob van der Does's Avatar
    Title
    ViX Beta Tester
    Join Date
    Apr 2010
    Location
    The Netherlands & France
    Posts
    36,262
    Thanks
    1,720
    Thanked 9,461 Times in 6,675 Posts
    Quote Originally Posted by pembo View Post
    You can put a URL into the show picture config, so it should work if you put in:
    http://88.77.66.55:4444/snapshot.cgi...wd=password&t=
    I tried this for my IP-cam, and although this works fine when used in a browser (so address and user/pass are fine), I get no picture at
    all in L4L. Any idea?

    Help asked via PM will be ignored.
    The forum is there for help and all will benefit from your questions.
    NO CARD SHARING TALK WILL BE TOLERATED, LAN OR WAN, IN OPEN FORUM OR PM !

    English is not my native tongue.
    I apologise for all my grammar, spelling and idiom errors.

  10. #10

    Title
    ViX Beta Tester
    Join Date
    Jun 2014
    Location
    UK
    Posts
    642
    Thanks
    157
    Thanked 318 Times in 173 Posts
    You'll need a url to provide an image snapshot from the cam and not a stream

  11. #11
    Rob van der Does's Avatar
    Title
    ViX Beta Tester
    Join Date
    Apr 2010
    Location
    The Netherlands & France
    Posts
    36,262
    Thanks
    1,720
    Thanked 9,461 Times in 6,675 Posts
    Yeah, as I said: in the webbrowser this works fine, so URL/user/pass are fine. And refreshing browser gives me the next snapshot.
    Apparently just L4L doesn't know how to handle this.

    Help asked via PM will be ignored.
    The forum is there for help and all will benefit from your questions.
    NO CARD SHARING TALK WILL BE TOLERATED, LAN OR WAN, IN OPEN FORUM OR PM !

    English is not my native tongue.
    I apologise for all my grammar, spelling and idiom errors.

  12. #12

    Title
    ViX Beta Tester
    Join Date
    Jun 2014
    Location
    UK
    Posts
    642
    Thanks
    157
    Thanked 318 Times in 173 Posts
    It's just an image and not an HTML response with an image inside it?
    If you need to do this, the alternative is to use wget and cron to grab the image (say every 10 seconds or so) to save it locally, then link to the local image in LCD4Linux.

  13. #13
    Rob van der Does's Avatar
    Title
    ViX Beta Tester
    Join Date
    Apr 2010
    Location
    The Netherlands & France
    Posts
    36,262
    Thanks
    1,720
    Thanked 9,461 Times in 6,675 Posts
    Quote Originally Posted by pembo View Post
    It's just an image and not an HTML response with an image inside it?
    Yes, you're right; it's a web page with an image as (the only) contents.

    Quote Originally Posted by pembo View Post
    If you need to do this, the alternative is to use wget and cron to grab the image (say every 10 seconds or so) to save it locally, then link to the local image in LCD4Linux.
    This sounds like you know exactly how to do this. You care to share some knowledge with a layman?

    Help asked via PM will be ignored.
    The forum is there for help and all will benefit from your questions.
    NO CARD SHARING TALK WILL BE TOLERATED, LAN OR WAN, IN OPEN FORUM OR PM !

    English is not my native tongue.
    I apologise for all my grammar, spelling and idiom errors.

  14. #14

    Title
    ViX Beta Tester
    Join Date
    Jun 2014
    Location
    UK
    Posts
    642
    Thanks
    157
    Thanked 318 Times in 173 Posts
    You could try first just grabbing the image url out of the HTML page, paste this into your browser and see if this refreshes the link. As the browser caches the page, you might need to stick a ?a=1 at the end, then ?a=2, ?a=3, etc just to avoid the cache whilst you test this works.

  15. #15
    zYx's Avatar
    Title
    Member
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    5
    Thanked 8 Times in 6 Posts
    Quote Originally Posted by Rob van der Does View Post
    I tried this for my IP-cam, and although this works fine when used in a browser (so address and user/pass are fine), I get no picture at
    all in L4L. Any idea?
    The best way to check the url of your IP camera snaphot is to click on the snapshot icon in your IP webif and then check its url.

    Did you try that URL in your browser first?

    Update: I have four IP cameras, two are the same make and the other two are two different makes. All of them have the very same URL structure.

    Update 2: Now I see there's more posts here :P

    Update 3: I use this bit of code n cron:

    HTML Code:
    <?
    $oldfilename = 'snapshot.cgi?user=user&pwd=password';
    $newfilename = date('Ymd_Hi', time() - 3600).".jpg";
    $newfilename2 = date('Ymd_Hi', time() - 3600).".jpg";
            define('BUFSIZ', 4095);
            $url = 'http://55.66.77.88:99999/snapshot.cgi?user=user&pwd=password';
            $rfile = fopen($url, 'r');
            $lfile = fopen(basename($url), 'w');
            while(!feof($rfile))
                    fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
            fclose($rfile);
            fclose($lfile);
            rename($oldfilename,$newfilename);
    
    $SourceFile = $newfilename;
    $DestinationFile = $newfilename; 
    $WaterMark = date('d.m.Y H:i', time() - 3600)." ";
    
    watermarkImage ($SourceFile, $WaterMark, $DestinationFile);
    
    function watermarkImage ($SourceFile, $WaterMark, $DestinationFile) { 
       list($width, $height) = getimagesize($SourceFile);
       $image_p = imagecreatetruecolor($width, $height);
       $image = imagecreatefromjpeg($SourceFile);
       imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height); 
       $color = imagecolorallocate($image_p, 255, 0, 255);
       $font = 'visitor2.ttf';
       $font_size = 11; 
       imagettftext($image_p, $font_size, 0, 10, 470, $color, $font, $WaterMark);
       if ($DestinationFile<>'') {
          imagejpeg ($image_p, $DestinationFile, 100); 
       } else {
          header('Content-Type: image/jpeg');
          imagejpeg($image_p, null, 100);
       };
       imagedestroy($image); 
       imagedestroy($image_p); 
    };
    ?>
    
    
    
    <img src="<?=$newfilename2?>" border="0"></img>
    I'm using it for slightly different purposes (time lapse) but you get an idea. The code is downloading a picture from the camera, saves it as "snapshot.cgi?user=user&pwd=password" file name and then renames it according to a date it was taken. Then a water mark with current time and date is applied.
    Last edited by zYx; 31-12-14 at 18:33.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.