0lly
Posts: 77
Joined: Sun Mar 02, 2014 5:07 pm

Re: RPi Cam Web Interface

Tue Apr 14, 2015 12:18 pm

btidey wrote:Now incorporates changes from pyjamasam (thanks) which means the main preview image is a mjpeg stream rather than image fetches.
FF no updating previewimage
IE 11 crashes...
btidey wrote: css tweak included to hopefully resolve problem with input of settings from some browsers.
works now

Sephiron
Posts: 13
Joined: Fri Mar 27, 2015 11:10 am

Re: RPi Cam Web Interface

Tue Apr 14, 2015 1:19 pm

btidey wrote: The current scheduler checks the media at management intervals (default every hour) and removes material that is older then the Purge limits. 0 the default means no automatic purging. Setting, for example, PurgeVideo_Hours to 98 means that videos are retained for 1 week and then removed. The thinking here was not so much memory protection, more about automating clean up of old material without having to think about it and the time limit then gives a clear retention criteria.

If we want an additional criteria based on memory usage then it would need an additional scheduler setting like 'Purge_onLowMemory' set in say MB which could still check at management intervals and would remove oldest files till free space was above the set limit. An alternative would be to set the Max memory to be used for media and then behave in a similar way to keep usage approximately below that number. Although that would need to be adjusted to suit the media requirements it may be better if external mounts is used or shared media is used between different cameras. It would also allow separate criteria for images, videos and lapses if thought desirable.
Would doing something like this break anything I don't know about? Can similar functionality be added to upcoming updates?
The idea here is to first perform the normal purge, then check how much memory is used, if more than desired percentage, then start purging oldest files until it is enough. ie. if maxSpaceAvailable is 96, then it will start purging files until there is at least 4% of free memory space on the disk.

Code: Select all

function purgeFiles($videoHours, $imageHours, $lapseHours, $maxSpaceAvailable) {
      global $logFile;
      $purgeCount = 0;
      if ($videoHours > 0 || $imageHours > 0) {
         $files = scandir(MEDIA_PATH);
         $currentHours = time() / 3600;
         foreach($files as $file) {
            if(($file != '.') && ($file != '..') && (substr($file, -7) == '.th.jpg')) {
               $fType = substr($file,-12, 1);
               $purgeHours = 0;
               switch ($fType) {
                  case 'i': $purgeHours = $imageHours;
                     break;
                  case 't': $purgeHours = $lapseHours;
                     break;
                  case 'v': $purgeHours = $videoHours;
                     break;
               }
               if ($purgeHours > 0) {
                  $fModHours = filemtime(MEDIA_PATH . "/$file") / 3600;
                  if ($fModHours > 0 && ($currentHours - $fModHours) > $purgeHours) {
                     deleteFile($file);
                     $purgeCount++;
                  }
               }
            } 
         }
      }
      exec("df -h /dev/root", $tsz);
      $spaceUsed = intval(str_replace("%", "", explode(" ", $tsz[0])[3]));
      while($spaceUsed > $maxSpaceAvailable){
        $files = scandir(MEDIA_PATH);
        if(count($files) == 0){
          break;
        }
        $filename = $files[0];
        $lowestTime = filetime(MEDIA_PATH . "/$filename");
 
        foreach($files as $file){
          if(($file != '.') && ($file != '..')&&(substr($file,-7)== '.th.jpg')){
            $fType = substr($file,-12,1);
            $fModTime = filetime(MEDIA_PATH . "/$file");
            if($fModTime < $lowestTime){
              $filename = $file;
              $lowestTime = $fModTime;
            }
          }
        }
        deleteFile($filename);
        $purgeCount++;
      }
      if($purgecount > 0){
        writeLog("Purged $purgeCount Files");
      }
   }

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Tue Apr 14, 2015 5:39 pm

Sephiron wrote: Would doing something like this break anything I don't know about? Can similar functionality be added to upcoming updates?
The idea here is to first perform the normal purge, then check how much memory is used, if more than desired percentage, then start purging oldest files until it is enough. ie. if maxSpaceAvailable is 96, then it will start purging files until there is at least 4% of free memory space on the disk.
Thanks for sharing that. Something like that would work, particularly in a dedicated camera single SD card environment and it would be a useful addition.

Few comments.

I'm not sure about df output with external mounted media storage. I suspect that needs to be df -h /var/www/media to make sure the free space is done for the actual filing system in use. Anybody confirm that is the case?

Similarly, if the system is used for other purposes then setting absolute max storage may be more suitable for some and this avoids getting free space using df.

Maybe what is required is the ability to set it either way so user chooses which works for them.

I think the purge can be optimised a bit during this part of the cycle by building an array of files sorted by time outside of the purge loop.

The loop needs to update $maxSpaceAvailable otherwise it deletes everything!

I noticed a bug in the original code in $lapseHours is not in the OR statement.
Last edited by btidey on Tue Apr 14, 2015 6:32 pm, edited 1 time in total.

rahlquist
Posts: 149
Joined: Tue Jan 21, 2014 1:02 pm

Re: RPi Cam Web Interface

Tue Apr 14, 2015 6:04 pm

btidey wrote: I thought we had already incorporated all those changes already in the latest version, which does support V3 annotation, text sizing, custom colours. Is there something we have missed?
Ooops sorry missed the size down below (figured it would be near the annotate) and since the annotate said string length was still 32 I thought maybe you folks hadn't gotten to this yet. Thanks!

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Tue Apr 14, 2015 6:30 pm

rahlquist wrote:
btidey wrote: I thought we had already incorporated all those changes already in the latest version, which does support V3 annotation, text sizing, custom colours. Is there something we have missed?
Ooops sorry missed the size down below (figured it would be near the annotate) and since the annotate said string length was still 32 I thought maybe you folks hadn't gotten to this yet. Thanks!
Yes. It's down below as that is where all the V3 stuff went when we had v2 and v3. v2 is now abandoned. It would be nice to re-arrange the grouping of settings to make it a bit easier to find stuff as the list is quite long, maybe with sub-groups.

Theoretically v3 annotation takes up to a 256 character string in the MMAL interface but it seems to cracking up if using more than 60 so I think there may be some other limits deeper inside.

morticiaskeeper
Posts: 101
Joined: Mon Aug 27, 2012 6:05 pm

Re: RPi Cam Web Interface

Tue Apr 14, 2015 8:41 pm

Updated to V5.1.2.

Parameter adjustments work fine in Chrome on Android & iOS, but the livestream doesn't appear on iOS in either Chrome or Safari. Just the word LOADING in red.

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Tue Apr 14, 2015 9:21 pm

morticiaskeeper wrote:Updated to V5.1.2.

Parameter adjustments work fine in Chrome on Android & iOS, but the livestream doesn't appear on iOS in either Chrome or Safari. Just the word LOADING in red.
That doesn't sound good. We folded in the switch to a MJPEG stream rather than the continuous fetch of individual images. It has been working fine on my Windows Chrome and Firefox for a couple of days.

If you press the capture buttons are they working?

Edit: Apparently it's a known issue on Apple systems to do with line endings.

Streaming php now has a 'fix' for this.

Thanks to pyjamasam and spikedrba for jumping on this.

MatsHelge
Posts: 6
Joined: Thu Mar 27, 2014 6:32 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 4:27 am

Hi, I've been succesfull in couple of projects with the CamWebInterface, but now I've run into a weird problem and could use some help.

I installed the latest version of the CamWebInterface to my Pi and tested it for a few weeks every now and then and it ran smoothly. A Couple of days ago I rigged my camera to work as a motion detection security cam, saving the video files on my NAS and this is when the system started to act out.

I followed the (viewtopic.php?p=531344#p531344) instructions on NAS saving and it really does save the images and videos on NAS, but after a while it just gives an error:

Code: Select all

Error in RaspiMJPEG: Could not open/create video-file
Restart RaspiMJPEG (./RPi_Cam_Web_interface_Installer.sh start) or the whole RPi.
The NAS folder is a public folder without password protection and I can't think of any reason why it shouldn't work. Maybe you folks can?

My NAS is a Seagate Central 4TB and I'm using a LAN cable to connect my RPi to my local network.

Thanks guys!

Mats

0lly
Posts: 77
Joined: Sun Mar 02, 2014 5:07 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 4:59 am

post the result from your nas

Code: Select all

cat /etc/exports

0lly
Posts: 77
Joined: Sun Mar 02, 2014 5:07 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 5:06 am

btidey wrote: Edit: Apparently it's a known issue on Apple systems to do with line endings.

Streaming php now has a 'fix' for this.

Thanks to pyjamasam and spikedrba for jumping on this.
I get the same under Windows, livepreview is not updating here.
Only after pressing F5 (refresh page) i get one update.

morticiaskeeper
Posts: 101
Joined: Mon Aug 27, 2012 6:05 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 6:31 am

Live preview not working on iOS Chrome or Safari.

Image recording works fine when buttons pressed in Chrome.

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 7:30 am

morticiaskeeper wrote:Live preview not working on iOS Chrome or Safari.

Image recording works fine when buttons pressed in Chrome.
Have you done the update?

It is also important to make sure the new javascript is reloaded in the browser often it gets cached and a hard refresh is needed to force a reload. On a windows system that would be Shift F5, not sure what iOS equivalent would be.

MatsHelge
Posts: 6
Joined: Thu Mar 27, 2014 6:32 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 8:18 am

0lly wrote:post the result from your nas

Code: Select all

cat /etc/exports
Hi, I don't understand what you're asking? I checked there is no /etc/exports -file "no such file or directory". Please if you could tell me more about this, what is it that I'm looking for here, some kind of a log-file?

Thanks

Mats

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 9:27 am

MatsHelge wrote: I followed the (viewtopic.php?p=531344#p531344) instructions on NAS saving and it really does save the images and videos on NAS, but after a while it just gives an error:

Code: Select all

Error in RaspiMJPEG: Could not open/create video-file
Restart RaspiMJPEG (./RPi_Cam_Web_interface_Installer.sh start) or the whole RPi.
That error message would seem to indicate you are using an earlier version of raspimjpeg. Later versions don't exit when experiencing an error opening a capture file on the filing system. This doesn't explain why you are getting errors in the first place but it does help keep the system going when encountering a temporary glitch.

0lly
Posts: 77
Joined: Sun Mar 02, 2014 5:07 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 9:52 am

MatsHelge wrote:
0lly wrote:post the result from your nas

Code: Select all

cat /etc/exports
Hi, I don't understand what you're asking? I checked there is no /etc/exports -file "no such file or directory". Please if you could tell me more about this, what is it that I'm looking for here, some kind of a log-file?
Login in your nas using putty via telnet/ssh as root
The exports contains all nfs-shares.

0lly
Posts: 77
Joined: Sun Mar 02, 2014 5:07 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 10:00 am

btidey wrote: Have you done the update?
yes and the debugger from FF displays the correct file.
Attachments
script.JPG
script.JPG (34.94 KiB) Viewed 2604 times

morticiaskeeper
Posts: 101
Joined: Mon Aug 27, 2012 6:05 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 10:34 am

btidey wrote:
morticiaskeeper wrote:Live preview not working on iOS Chrome or Safari.

Image recording works fine when buttons pressed in Chrome.
Have you done the update?

It is also important to make sure the new javascript is reloaded in the browser often it gets cached and a hard refresh is needed to force a reload. On a windows system that would be Shift F5, not sure what iOS equivalent would be.
I ran the update script again this morning. Did a full shutdown of the iPad and rebooted.

Still no livestream :-( All the buttons work well, image capture and recording work, just no livestream on Chrome and Safari.

Edit. Another full shutdown, then installed Puffin and Photon browsers. Still no livestream.

Gary Littlemore
Posts: 327
Joined: Thu Oct 11, 2012 11:52 am
Location: Cheshire, UK

Re: RPi Cam Web Interface

Wed Apr 15, 2015 12:05 pm

"Feature Request"

I'd like to be able to boot the 'RPi Cam Web Interface' as normal and be able to configure a timelapse job with the following, runtime X minutes, taking a picture every X milliseconds, once the runtime X minutes has completed it automatically safely shuts down and only does this again once it’s reconfigured again. So the next boot after the job has been ran it boots as normal. Not sure if this is going to be possible, I'm looking to setup up the job and then boot a pi remotely and the job run.
3b+, 2b, b+, b, Zero & Zero-W

User avatar
DougieLawson
Posts: 36546
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RPi Cam Web Interface

Wed Apr 15, 2015 12:09 pm

Gary Littlemore wrote:"Feature Request"

I'd like to be able to boot the 'RPi Cam Web Interface' as normal and be able to configure a timelapse job with the following, runtime X minutes, taking a picture every X milliseconds, once the runtime X minutes has completed it automatically safely shuts down and only does this again once it’s reconfigured again. So the next boot after the job has been ran it boots as normal. Not sure if this is going to be possible, I'm looking to setup up the job and then boot a pi remotely and the job run.
You should be able to do most of that stuff by driving the camera from a Python program with Picamera. For "X milliseconds" you probably want to switch to video recording (up to 90fps is possible).
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 12:58 pm

morticiaskeeper wrote: I ran the update script again this morning. Did a full shutdown of the iPad and rebooted.

Still no livestream :-( All the buttons work well, image capture and recording work, just no livestream on Chrome and Safari.

Edit. Another full shutdown, then installed Puffin and Photon browsers. Still no livestream.
I've posted a question back to originators of MJPEG mode. If we can't resolve this we may have to contemplate reverting to the original mode or making it optional, although the latter is not nice.

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 1:09 pm

Gary Littlemore wrote:"Feature Request"

I'd like to be able to boot the 'RPi Cam Web Interface' as normal and be able to configure a timelapse job with the following, runtime X minutes, taking a picture every X milliseconds, once the runtime X minutes has completed it automatically safely shuts down and only does this again once it’s reconfigured again. So the next boot after the job has been ran it boots as normal. Not sure if this is going to be possible, I'm looking to setup up the job and then boot a pi remotely and the job run.
You can do this today within context of RPi Cam by using the PIPE controls from other programs like a bash script or python. For example, assuming the lapse delay is set up then a bash script which does
echo -n 'tl 1' >/var/www/FIFO
sleep 20m
echo -n 'tl 0' >/var/www/FIFO

would start the time lapse wait 20 minutes and then stop it.

As mentioned if you want to get picture closer than about a second then you are better using a slow fps video. Same technique could be used for starting and stopping that.

If you actually want to initiate the whole process from the web interface by manually pushing a button then that is a separate request and one maybe best done by a general run script button rather than making it specific to just one use.

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 1:42 pm

btidey wrote:
I've posted a question back to originators of MJPEG mode. If we can't resolve this we may have to contemplate reverting to the original mode or making it optional, although the latter is not nice.
pyjamasam came back with following useful info.
The following browsers are working
OS X
Chrome: Version 42.0.2311.82 beta (64-bit) (latest)
Safari: Version 8.0.5 (10600.5.17) (latest)
Firefox: 36.0.4

Windows 7
Chrome: Version 42.0.2311.82 beta-m (latest)
Firefox: 12.0, 36.0.4

IOS
Safari: IOS 8.3

Browsers that aren't working
OS X
Firefox: 37.0.1 (latest) - shows a single frame but doesn't update after that

Windows 7
IE: 10.0.9200.16635 - hangs the browser
Firefox: 37.0.1 (latest) - shows a single frame but doesn't update after that

IOS
Chrome: 41.0.2272.58 - never shows anything but the "loading" image

I'll do some more digging and see what I can come up with with respect to Firefox and IE. My guess is they are related problems.

chris.
I'm using Windows 7 Firefox 37.01 and Chrome 42.0.2311.90 m and it's fine on those as well.

btidey
Posts: 1625
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 2:45 pm

Sephiron wrote: Would doing something like this break anything I don't know about? Can similar functionality be added to upcoming updates?
The idea here is to first perform the normal purge, then check how much memory is used, if more than desired percentage, then start purging oldest files until it is enough. ie. if maxSpaceAvailable is 96, then it will start purging files until there is at least 4% of free memory space on the disk.
I have added a space based purge into scheduler now. It works in addition to the time based purge so both may be used together.

Set up of space purging can be either to keep a minimum space free based on filing system, or to limit the maximum space used by media. In either casee the level can be set in GB or as a % of filing system size. To use % just put a % after the number. E.g. 10% on a 16GB fs means 1.6GB.

Obviously take a bit of care here; getting the settings inappropriate can end up deleting all the media like a delete All. Also if you have any valuable stuff captured then download it first just in case there are bugs!
Attachments
purgespace.jpg
purgespace.jpg (22.4 KiB) Viewed 2474 times

pyjamasam
Posts: 2
Joined: Mon Mar 17, 2014 7:09 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 2:47 pm

I just threw up a pull request with changes that should make the mjpeg preview function better in a wider range of browsers, but sadly IE doesn't look like its going to happen. It doesn't like any mjpeg stream I can find online anywhere.

Also chrome on IOS is a bit of an outlier. It doesn't work either (though safari on IOS does).

chris.

0lly
Posts: 77
Joined: Sun Mar 02, 2014 5:07 pm

Re: RPi Cam Web Interface

Wed Apr 15, 2015 2:56 pm

btidey wrote: pyjamasam came back with following useful info.
Browsers that aren't working
Windows 7
IE: 10.0.9200.16635 - hangs the browser
Firefox: 37.0.1 (latest) - shows a single frame but doesn't update after that
.
I can confirm that it does not run with them.
I'm back to Firefox 36.0.4

Return to “Camera board”