+ Post New Thread
Results 1 to 6 of 6
How do you do....it? Thread, Help with Webcam page in Technical; Ok, so it's not directly related to the camera but here goes. My IP camera's up and running FTP'ing jpgs ...
  1. #1

    Join Date
    Aug 2009
    Location
    Lincoln
    Posts
    4
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Help with Webcam page

    Ok, so it's not directly related to the camera but here goes.

    My IP camera's up and running FTP'ing jpgs directly to the server, there is no onsite PC and I don't want to involve the use of one. The script on the webpage is replacing the image every 3 seconds however the snapshots come through at irregular intervals, no way to change that so no replies telling me to reconfigure the camera (trust me) i'm stuck with what i'm getting sent.

    My problem is I'm not to great at scripting and have used and amended a script from willing webcams. What's happening is the 3 second update frequently hit a half uploaded jpg and so 1 in 3 updates show a blank screen.

    What I need is a script that will check the file to update and if not available will display (not update) the previous jpg.

    Altering the frequency of update doesn't help 'cause of the irregular send from the camera.

    Any Ideas

  2. #2

    Join Date
    Oct 2009
    Location
    Scotland
    Posts
    1
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hi,

    Not sure about the scripting but some webcams have the option to upload tempory files which won't overwright the file until it is fully uploaded.

  3. #3

    Join Date
    Aug 2009
    Location
    Lincoln
    Posts
    4
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Thanks for the reply but it doesn't really help.

    I'm happy enough with what the camera sends, it loads and replaces into a file on the server. The problem is the script i'm using then uses that file to update the image on the page. My script replaces the image every 3 seconds whether or not there's an complete image available. I need something that checks to see if the file is complete, if not don't replace and check again next time.

  4. #4
    SteveBentley's Avatar
    Join Date
    Jun 2007
    Location
    Yorkshire
    Posts
    1,431
    Thank Post
    119
    Thanked 263 Times in 189 Posts
    Rep Power
    72
    Assuming this is JavaScript/DHTML, I don't think you'll be able to query the file size or any other useful properly to find out whether it is fully uploaded. I think the best compromise might be to alter the script to show the image previous to the most recent one, which should have uploaded.

  5. #5

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,403
    Thank Post
    637
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    319
    Do you have any server-side scripting capabilities on the web server, e.g. PHP?

    My thinking is this:

    1. Point the image to a PHP script (bear with me)
    2. The PHP script will check if the real image on disk is complete (using getimagesize() for example, it should fail if image is not valid)
    3. Set the content-type to image/jpeg
    4. If image valid from step (2) then respond with the image
    5. If not valid, then respond with another image that simply says 'Please wait...'
    Last edited by webman; 5th November 2009 at 04:09 PM.

  6. Thanks to webman from:

    mike_preston (6th November 2009)

  7. #6

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,641
    Thank Post
    514
    Thanked 2,443 Times in 1,891 Posts
    Blog Entries
    24
    Rep Power
    831
    The way I'd do it would be a php script which checks the md5 hash of the uploaded file, compares it to the one which will be displayed, if it is not the same, then it overwrites the one to display with the uploaded one. If it is the same, it just displays.

    Example PHP code.
    Code:
    $file1 = 'path/to/file'; //New file
    $file2 = 'path/to/file'; //Old file
    
    $md51 = md5_file($file1);
    $md52 = md5_file($file2);
    
    if(md51 == md52){
    unlink($file2);
    link($file1,$file2);
    }
    Or something similar.

  8. Thanks to localzuk from:

    mike_preston (6th November 2009)

SHARE:
+ Post New Thread

Similar Threads

  1. Webcam Driver Help, Please!
    By tmcd35 in forum Hardware
    Replies: 4
    Last Post: 17th October 2009, 09:39 PM
  2. Webcam problems
    By Little-Miss in forum Hardware
    Replies: 1
    Last Post: 16th May 2009, 10:09 PM
  3. Yet another webcam query
    By LeMarchand in forum Hardware
    Replies: 9
    Last Post: 3rd April 2009, 03:38 PM
  4. Need a Webcam for my laptop
    By richard in forum Hardware
    Replies: 8
    Last Post: 27th June 2007, 08:22 AM
  5. cctv-webcam
    By callumtuckey in forum General Chat
    Replies: 5
    Last Post: 11th June 2007, 08:16 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •