kerbys
Posts: 3
Joined: Thu Nov 21, 2013 9:12 am

Re: RPi Cam Web Interface

Fri Jan 24, 2014 9:47 am

doh! Go this all working last night, was tweaking it this morning! Then hit the record button as i was getting some fast play back problems, I then was reminded as its frieday work provide us with bacon sandwiches. I rush upstairs (It is bacon!) Come back down to a crashed PI! No way of rebooting it!

Going to try and get someone to pass by and reboot the pi!

This opens up the question of can i redirect where recordings go?
Ideal setup would be.

1) have a couple of cameras running (next week going to buy 2 more Pi's and cameras)
2) The pi's i would like to respond to movement detection to send a push notification (pushover) with a link to the video file/feed.
3) use a seperate linux VM to detect movement i see you can use cam.php however that is a still image? Will this still work?

4) i would like one of the pi's to also resond to a gpio action (front doorbell) This way can see whos at the door without having to move away from a tv show marathon to someone who wants to sell double glazed windows when im clearly already using them!


Anyone else doing something simular?


EDIT : Back on now, building a linux VM to see if i get that to monitor it.

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

Re: RPi Cam Web Interface

Fri Jan 24, 2014 12:33 pm

poing wrote:Good catch, writing to the log file that much will also kill the SD card.
This was my concerns and why one of my first changes wast to move the apache logs to a mount point on my sever (so they write to a physical hd).

kerbys
Posts: 3
Joined: Thu Nov 21, 2013 9:12 am

Re: RPi Cam Web Interface

Fri Jan 24, 2014 2:35 pm

kerbys wrote:doh! Go this all working last night, was tweaking it this morning! Then hit the record button as i was getting some fast play back problems, I then was reminded as its frieday work provide us with bacon sandwiches. I rush upstairs (It is bacon!) Come back down to a crashed PI! No way of rebooting it!

Going to try and get someone to pass by and reboot the pi!

This opens up the question of can i redirect where recordings go?
Ideal setup would be.

1) have a couple of cameras running (next week going to buy 2 more Pi's and cameras)
2) The pi's i would like to respond to movement detection to send a push notification (pushover) with a link to the video file/feed.
3) use a seperate linux VM to detect movement i see you can use cam.php however that is a still image? Will this still work?

4) i would like one of the pi's to also resond to a gpio action (front doorbell) This way can see whos at the door without having to move away from a tv show marathon to someone who wants to sell double glazed windows when im clearly already using them!


Anyone else doing something simular?


EDIT : Back on now, building a linux VM to see if i get that to monitor it.

apple1554
Posts: 8
Joined: Fri Jan 03, 2014 2:49 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 2:46 pm

Is it possible to control exposure and framerate manually instead of going by these "exposure mode" profiles?

JonesThePi
Posts: 21
Joined: Tue Oct 23, 2012 1:08 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 3:28 pm

Thank you @silvanmelchior for developing this. It has provided an excellent starting point to learn about the RPi Cam and ever more about the RasPi.

A couple of gremlins which have been raised before in this thread that I cannot resolve.

First, I have redirected jpg & mp4 saves to a Samba share by editing /etc/rc.local. For previewing I have edited /var/www/preview.php. Files save ok, I can see the file list in the preview screen and I can also delete files from here, but for some reason I cannot view them using the latest version of Chrome (404 not found error). I have tried many combinations of path after <img src= unsuccessfully.

Second, I have written a python script which sends commands into the pipe /var/www/FIFO. This script works when sending echo 'ro 180' > /var/www/FIFO but will not work for echo 'em night' > /var/www/FIFO. The latter also does not work from the command line while the former does.

Both issues occur on 2 separate RPi and RPi Cam setups. Any ideas please...

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 3:42 pm

Can you try changing to -ex night and the start/stop the video? I had several occasions where that suddenly made -ex night active.

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 3:43 pm

apple1554 wrote:Is it possible to control exposure and framerate manually instead of going by these "exposure mode" profiles?
You can control ISO and shutter speed with raspistill (not sure about raspivid) but I don't think these are implemented in raspimjpeg.

JonesThePi
Posts: 21
Joined: Tue Oct 23, 2012 1:08 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 4:11 pm

poing wrote:Can you try changing to -ex night and the start/stop the video? I had several occasions where that suddenly made -ex night active.
Saw the earlier post suggesting this and have just tried again, but it doesn't work for me.

Can anyone confirm that echo 'em night' > /var/www/FIFO does work for them?

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 4:35 pm

JonesThePi wrote:
poing wrote:Can you try changing to -ex night and the start/stop the video? I had several occasions where that suddenly made -ex night active.
Saw the earlier post suggesting this and have just tried again, but it doesn't work for me.
OK, then it has probably to do with my 'phone' implementation of the website and slow WiFi. Thanks for clarifying.

silvanmelchior
Posts: 76
Joined: Mon Nov 25, 2013 5:56 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 4:59 pm

I updated the installer, so logging for cam_pic.php and for status_mjpeg.php (reloaded all 3 seconds by website to get status) is disabled now. Just download and run the installer again to get the result. Thanks, jbeale for the instructions!

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 6:04 pm

silvanmelchior wrote:I updated the installer, so logging for cam_pic.php and for status_mjpeg.php (reloaded all 3 seconds by website to get status) is disabled now. Just download and run the installer again to get the result. Thanks, jbeale for the instructions!
Great you're 'alive and kicking'. Any chance 'true manual mode' aka '-ss' and '-ISO' will be implemented?

kyle2k
Posts: 84
Joined: Tue Feb 19, 2013 2:47 pm

Re: RPi Cam Web Interface

Fri Jan 24, 2014 9:02 pm

Hi,

I have just done a fresh install of raspian and the RPI web cam interface and when viewing from chromium on my laptop the cpu load has gone up to 80% and the action buttons have lost the writing on them but still seem to function ok.

Has anyone else tested this latest release?

I will continue to experiment and report back.

Also many thanks to jbeale for his motion.conf that saves pictures and video :D

User avatar
jbeale
Posts: 3707
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: RPi Cam Web Interface

Fri Jan 24, 2014 9:30 pm

I just tried the latest version (from today) and with the web page open on another system, "top" on the R-Pi reports a load average around 1.4, and as high as 2.3 when motion is detected and MP4Box is converting the .h264 file. With motion running but no webpage open, load average is 1.14 on my R-Pi (which is not OC'd, still running at the default 700 MHz speed). Then I set arm_freq=800 in /boot/config.txt and I see load average around 0.95 with web page on and motion running, and up to 1.35 when MP4Box runs. You can cut down CPU usage by using a lower MJPEG resolution as set in the raspimjpeg call in /etc/rc.local and this does not affect the recorded full-HD video resolution.
kyle2k wrote:Also many thanks to jbeale for his motion.conf that saves pictures and video :D
You're welcome! After a while the list of images/video will quickly run off the screen, due to the <p> .. </p> tags around each item so they are double-spaced.
So I just removed the <p> tags in the echo "..." line that lists file names and filesizes in /var/www/preview.php and get a much more useful display.

Code: Select all

          if(($file != '.') && ($file != '..')) {
            $fsz = round ((filesize("media/" . $file)) / (1024 * 1024));
            echo "<a href='preview.php?file=$file'>$file</a> ($fsz MB) ";
I also got rid of the large Preview and Files headers, to save some more room on the page for the data.

If you're viewing JPEGs auto-captured by 'motion' they will be 512x288 (unless you changed the default) and they will appear squished (too tall) in the webpage because the preview image is set to 480x360 in /var/www/preview.php because that assumes you are viewing captured 4:3 ratio, 5MP full-frame stills instead. So I prefer to change that to be 512x288 as well.

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Sat Jan 25, 2014 10:34 pm

Yes, we have jbeale back! Your account and all your posts were suddenly gone this morning.

User avatar
jbeale
Posts: 3707
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: RPi Cam Web Interface

Sat Jan 25, 2014 11:43 pm

Nice to be back! Very unsettling to find my account gone and no record I existed here, as of this morning. A glitch in the database apparently to blame. Price of fixing it was apparently reverting to last backup, meaning the previous some-hours' worth of posts really are gone for good.

Back on topic... monitoring the 'top' command while the R-Pi is running raspimjpeg and apache with motion detection on, the numbers don't seem to add up. 'motion' takes around 25% of CPU and apache2 (when nothing is connected) is 0.3% for each of several processes, raspimjpeg and 'top' itself is about 1%, sshd is 0.3% but the rest is 0.0%. Despite this, the overall CPU load average shows around 0.77 so I don't understand how that all adds up. Is there some OS overhead that is counted against the total, but doesn't show up as a process? Whatever it is, it seems to account for about half of the total CPU.

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: RPi Cam Web Interface

Sun Jan 26, 2014 7:39 am

Load average is acually cpu run queue. It tells how many jobs there were that wanted CPU usage.
That is not exactly the same thing that cpu usage percentage, which tells the amount of time the cpu was busy.

So for example if there is high burst of work at certain time so that cpu is not able to do it all and tasks are put in the queue, the load average goes up. But if that "burst" is short, cpu usage percentage can stay low.

I have seen big mismatches with these numbers when there are a lot of interrupts from the USB and network. Those are very short, so cpu percentage stays low, but they can happen at the same time, so work queue (=load average) goes up.

For example:

Code: Select all

$ w
 09:38:25 up 366 days, 19:09,  1 user,  load average: 1,20, 0,69, 0,46
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
pi        pts/0    192.168.254.222  09:38    0.00s  1.27s  0.04s w
$ vmstat 1 
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0  11716  46020  44368  98860    0    0     0     1    0    1  5 11 79  5
 0  0  11716  45996  44364  98860    0    0     0     0 9068 1831  2 12 86  0
 1  0  11716  45996  44364  98860    0    0     0     0 9060 1846  0  9 91  0



kyle2k
Posts: 84
Joined: Tue Feb 19, 2013 2:47 pm

Re: RPi Cam Web Interface

Sun Jan 26, 2014 11:57 am

Hi all,

Good to see the forum back to usual.

Just to update on my earlier post, I have found that my problem of high cpu load on the remote viewing device and action buttons without text only happens when I'm using Chromium on my laptop or Chrome on my Nexus 7.

All is working fine when using Firefox on both systems and I can happily live with that.

bigspottycat
Posts: 2
Joined: Mon Jan 27, 2014 8:46 am

Re: RPi Cam Web Interface

Mon Jan 27, 2014 9:19 am

@silvanmelchior - this is fantastic. Great work!
@jbeale - thanks for all your comments - very helpful.

I've customised the preview.php page so that it now shows each video as a thumbnail under a date heading for each day (see screenshot). I've also added the delete and download buttons to each video so I can delete or download individual videos more easily. Having all videos load on one page probably won't suit everyone but I find it more usable (it also means that I can have multiple vidoes playing at the same time!). If anyone is interested, here's the code:

Code: Select all

<!DOCTYPE html>
<html>
  <head>
    <title>RPi Cam Download</title>
    <style>
        .thumbnail {display:inline-block; padding: 1em;}
    </style>
  </head>
  <body>
    <p><a href="index.html">Back to Live Feed</a></p>
    <?php
      if(isset($_GET["delete"])) {
        unlink("media/" . $_GET["delete"]);
      }
 /*
      if(isset($_GET["delete_all"])) {
        $files = scandir("media");
        foreach($files as $file) unlink("media/$file");
      }
      else if(isset($_GET["file"])) {
        if(substr($_GET["file"], -3) == "jpg") echo "<img src='media/" . $_GET["file"] . "' width='480' height='360'>";
        else echo "<video width='640' height='360' controls><source src='media/" . $_GET["file"] . "' type='video/mp4'>Your browser does not support the video tag.</video>";
        echo "<p><input type='button' value='Download' onclick='window.open(\"download.php?file=" . $_GET["file"] . "\", \"_blank\");'> ";
        echo "<input type='button' value='Delete' onclick='window.location=\"preview.php?delete=" . $_GET["file"] . "\";'></p>";
      }
*/
    ?>
    <?php
      $files = scandir("media");
      if(count($files) == 2) echo "<p>No videos/images saved</p>";
      else {
        foreach($files as $file) {
        
          if(substr($file, -3) == "jpg") echo "<img src='media/" . $file . "' width='256' height='144'>";
          else {
              if(($file != '.') && ($file != '..')) {

                $minute=(substr($file, -8, -6));
                $hour=(substr($file, -10, -8));
                $day=(substr($file, -13, -11));
                $month=(substr($file, -15, -13));
                $year=(substr($file, -19, -15));
                $date=$day.'/'.$month.'/'.$year;
                if($currentdate!=$date) echo "<h3>$date</h3>";
                $currentdate=$date;
                $time=$hour.':'.$minute;
                $fsz = round ((filesize("media/" . $file)) / (1024 * 1024));
                echo "<div class='thumbnail'>$time ($fsz MB)<br><video width='256' height='144' controls><source src='media/" . $file . "' type='video/mp4'>Your browser does not support the video tag.</video><p><input type='button' value='Delete' onclick='window.location=\"preview.php?delete=" . $file . "\";'><input type='button' value='Download' onclick='window.open(\"download.php?file=" . $file . "\", \"_blank\");'></div>";
              }
          }
        }
        echo "<hr><br><p><input type='button' value='Delete all' onclick='if(confirm(\"Delete all?\")) {window.location=\"preview.php?delete_all\";}'></p>";
      }
    ?>
  </body>
</html>

I've only tested it on Chromium but I find it works well. My php is a bit rusty but it seems to work!
Attachments
screenshot.png
customised preview page
screenshot.png (61.83 KiB) Viewed 6885 times

HeikoG
Posts: 12
Joined: Wed Oct 16, 2013 11:53 am

Re: RPi Cam Web Interface

Mon Jan 27, 2014 9:31 am

With the latest version if have a lot of records (every 10 sec) in Apache's errorlog. 404 file xxx not found.
I looked at the html and php code but i don't find the reason.

HeikoG
Posts: 12
Joined: Wed Oct 16, 2013 11:53 am

Re: RPi Cam Web Interface

Tue Jan 28, 2014 7:03 pm

@bigspottycat

I like your preview. But there is a mistake in the PHP code:

PHP Notice: Undefined variable: currentdate in /var/www/preview.php on line 44, referer: http://192.168.1.116/preview.php

bigspottycat
Posts: 2
Joined: Mon Jan 27, 2014 8:46 am

Re: RPi Cam Web Interface

Tue Jan 28, 2014 7:57 pm

@HeikoG - I told you my php was rusty!

I think I found a better way to do it anyway. Try this instead:

Code: Select all

<!DOCTYPE html>
<html>
  <head>
    <title>RPi Cam Download</title>
    <style>
        .thumbnail {display:inline-block; padding: 1em;}
    </style>
  </head>
  <body>
    <p><a href="index.html">Back to Live Feed</a></p>
    <?php
      if(isset($_GET["delete"])) {
        unlink("media/" . $_GET["delete"]);
      }
      if(isset($_GET["delete_all"])) {
        $files = scandir("media");
        foreach($files as $file) unlink("media/$file");
      }
      if(isset($_GET["delete_date"])) {
        $files = scandir("media");
        foreach($files as $file) 
        {
            if(date("d/m/Y", filemtime("media/".$file)) == $_GET["delete_date"])
            {
                unlink("media/$file");
            }
        }
      }
 /*
      else if(isset($_GET["file"])) {
        if(substr($_GET["file"], -3) == "jpg") echo "<img src='media/" . $_GET["file"] . "' width='480' height='360'>";
        else echo "<video width='640' height='360' controls><source src='media/" . $_GET["file"] . "' type='video/mp4'>Your browser does not support the video tag.</video>";
        echo "<p><input type='button' value='Download' onclick='window.open(\"download.php?file=" . $_GET["file"] . "\", \"_blank\");'> ";
        echo "<input type='button' value='Delete' onclick='window.location=\"preview.php?delete=" . $_GET["file"] . "\";'></p>";
      }
*/
    ?>
    <?php
      $files = scandir("media");
      $file_count = count($files);#
      $used = intval ((1-(disk_free_space("media")/disk_total_space("media")))*100);
      if($file_count == 2) echo "<p>No videos/images saved</p>";
      else {
        echo "<h1>$file_count videos (disk $used% full)</h1>";
        $currentdate=NULL;
        foreach($files as $file) {
            
          if(substr($file, -3) == "jpg") echo "<img src='media/" . $file . "' width='256' height='144'>";
          else {
              if(($file != '.') && ($file != '..')) {

                $date = date("d/m/Y", filemtime("media/".$file));
                if($currentdate!=$date) echo "<br><hr><h3>$date <input type='button' value='Delete all on $date' onclick='if(confirm(\"Delete all videos recorded on $date?\")) {window.location=\"preview.php?delete_date=" . $date . "\";}'></h3>";
                $currentdate=$date;
                $time = date("H:i", filemtime("media/".$file));
                $fsz = round ((filesize("media/" . $file)) / (1024 * 1024));
                echo "<div class='thumbnail'>$time ($fsz MB)<br><video width='256' height='144' controls><source src='media/" . $file . "' type='video/mp4'>Your browser does not support the video tag.</video><p><input type='button' value='Delete' onclick='window.location=\"preview.php?delete=" . $file . "\";'><input type='button' value='Download' onclick='window.open(\"download.php?file=" . $file . "\", \"_blank\");'></div>";
              }
          }
        }
        echo "<hr><br><p><input type='button' value='Delete all' onclick='if(confirm(\"Delete all?\")) {window.location=\"preview.php?delete_all\";}'></p>";
      }
    ?>
  </body>
</html>

Hope this helps!

07/02/2014 *UPDATE*

@oke
You are quite right - I accidentally removed the 'delete all' functionality! I have update the code above to correct this and also added a 'delete by date' button and a total videos count with free disk space as a percentage.
Last edited by bigspottycat on Fri Feb 07, 2014 5:51 am, edited 2 times in total.

samir_sogay
Posts: 17
Joined: Tue Jun 18, 2013 9:05 am

Re: RPi Cam Web Interface

Wed Jan 29, 2014 9:24 am

Firstly, congratulations for a brilliant piece of software capable of full hd video with motion detection. I have a couple of queries. I am living in a country with 50 Hz supply and with default video fps of 30 in raspimjpeg, I see some moving bands on the video (in fluorescent light). To confirm the fps issue, i tried 2 video capture with raspivid, one with 30 fps and one with 25. One with 25 is perfect while one with 30 is banding. Is there a way I can change the default fps for raspimjpeg to 25? Also, is there a permanent way to rotate the video by 90 degrees rather than send piped commands (as my case is made that way). Note: I cannot use /etc/rc.local as I use manual start.

itsmedoofer
Posts: 428
Joined: Wed Sep 25, 2013 8:43 am
Location: Canterbury, Kent, UK
Contact: AOL

Re: RPi Cam Web Interface

Thu Jan 30, 2014 11:45 am

Firstly much kudos to silvanmelchior for a fantastic installation, this really should be a sticky or separate page somewhere !!!

Secondly @bigspottycat, tried your preview page but it didn’t seem to like FireFox, I got the preview images but no buttons, any ideas ?

Regards,
Martin.
Last edited by itsmedoofer on Thu Jan 30, 2014 8:50 pm, edited 1 time in total.

oke
Posts: 2
Joined: Thu Jan 30, 2014 7:14 pm
Location: Finland

Re: RPi Cam Web Interface

Thu Jan 30, 2014 7:31 pm

[quote="bigspottycat"]@silvanmelchior - this is fantastic. Great work!
@jbeale - thanks for all your comments - very helpful.
-------------------------------------------------------------------------------------------------------------
I've customised the preview.php page so that it now shows each video as a thumbnail under a date heading for each day (see screenshot). I've also added the delete and download buttons to each video so I can delete or download individual videos more easily. Having all videos load on one page probably won't suit everyone but I find it more usable (it also means that I can have multiple vidoes playing at the same time!). If anyone is interested, here's the code:
------------------------------------------------------------------------------------------------------------

Thank You for the alternate preview.php. I changed the picture size smaller to 192x108 and
the video size bigger to 384x216. They suit better to my eyes.

Anyhow the Delete all -button is not working. It asks for the confirmation but then nothing happens.
The files remain. Tested with Firefox and Chrome on OS X computer. I do not now how to repair.

Can You please check this part of Your code?

Regards, Oke

-------------------------------------------------------------

Delete all problem is now solved on alternate preview.php.
I compared the two codes and removed /* and */ without
even knowing their function. But now it works.
Last edited by oke on Fri Jan 31, 2014 10:20 pm, edited 1 time in total.

simonk1969
Posts: 1
Joined: Sun Sep 02, 2012 3:03 pm

Re: RPi Cam Web Interface

Thu Jan 30, 2014 9:09 pm

Can someone take a look and this screen shot and advise what might be causing this error that appears when opening the webpage.

'The page at 192.168.0.106 says: Error:RaspiMJPEG terminated'

Thanks
Simon
Attachments
Capture.PNG
Capture.PNG (29.93 KiB) Viewed 6621 times

Return to “Camera board”