billw
Posts: 403
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 5:26 pm

boomlikethat wrote: Then it would load your settings by default, but it may get overwritten on any updates.
Just to clear this up:
Any change to a file made in ~/.pikrellcam will not be overwritten by an update.
Likewise, any edit or adding of a file in pikrellcam/scripts will not be overwritten.

But if you edit almost any other file in the src, www, or compile your own binary, you will effectively
be making a branch of the distribution and will have trouble doing a git pull. If you do a "git pull origin"
and get errors, see my post:
viewtopic.php?p=794547#p794547

Look at the ~/pikrellcam/.gitignore file to see a list of things that git does not track. If you
modify anything or anything in a directory not in that list you will no longer be in sync
with git. At that point a "git pull" will give errors and you will have to fix according to my post.
But a "git fetch" will appear to work, but in fact will not update over any changes you have made
and will not get you a new pikrellcam binary. That's why I recommend a "git pull" so you will
know if you are not in sync. Worst case would be you have to clean up and start over with a
git clone. If you have to do that, first save anything you have customized in
~/pikrellcam/scripts and then copy the files back in after the new git clone. Every config file
in ~/.pikrellcam/ will be safe and you can leave them alone if you have to do a new git clone.

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 5:47 pm

billw wrote:
boomlikethat wrote:
I copied your preview-save code, and I indeed get full-camera stills (with vectors and all that), which is a good start. Now it's just the motion-area only thumbs I cannot get.
From the webpage stop pikrellcam. Then in a terminal window run:

Code: Select all

pikrellcam -v
You may be able to see some additional error messages from the script that are not showing up
in the log.
And be sure you are really running the latest pikrellcam. I really need to get some version
numbers in that program! Umm, for now I guess look at the pikrellcam binary executable size.
The latest binary size from git should be: 122460.
EDIT: I mean run pikrellcam -v from a terminal on the Pi, either a window, console terminal,
or ssh terminal.
@billw

Thanks. I should be running the latest, as I deleted and reinstalled it.

Here are the results from pikrelcam -v. Looks like I messed something up. I changed the video filename parameters, and the "Bad config file option: filename" is different that what I did for the video (changed it to video_filename $N_%F_%H.%M.%S.mp4):

Bad config file option: filename %F_%H.%M.%S_$N.jpg

mmalcam_config_parameter_set: sharpness 0 [config set (not camera)]
mmalcam_config_parameter_set: contrast 0 [config set (not camera)]
mmalcam_config_parameter_set: brightness 50 [config set (not camera)]
mmalcam_config_parameter_set: saturation 0 [config set (not camera)]
mmalcam_config_parameter_set: iso 0 [config set (not camera)]
mmalcam_config_parameter_set: shutter_speed 0 [config set (not camera)]
mmalcam_config_parameter_set: exposure_compensation 0 [config set (not camera)]
mmalcam_config_parameter_set: video_stabilisation false [config set (not camera)]
mmalcam_config_parameter_set: raw_capture false [config set (not camera)]
mmalcam_config_parameter_set: rotation 0 [config set (not camera)]
mmalcam_config_parameter_set: exposure_mode auto [config set (not camera)]
mmalcam_config_parameter_set: image_effect none [config set (not camera)]
mmalcam_config_parameter_set: hflip off [config set (not camera)]
mmalcam_config_parameter_set: vflip off [config set (not camera)]
mmalcam_config_parameter_set: crop 0 0 65536 65536 [config set (not camera)]
mmalcam_config_parameter_set: metering_mode average [config set (not camera)]
mmalcam_config_parameter_set: white_balance auto [config set (not camera)]
mmalcam_config_parameter_set: color_effect false 128 128 [config set (not camera)]

2015-07-27 13:39:47 ==== PiKrellCam started ====
using FIFO: /home/pi/pikrellcam/www/FIFO
using mjpeg: /run/pikrellcam/mjpeg.jpg
execl:[/home/pi/pikrellcam/scripts-dist/_init /home/pi/pikrellcam /home/pi/pikrellcam/media /run/pikrellcam/mjpeg.jpg /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log]
execl:[/home/pi/pikrellcam/scripts/startup /home/pi/pikrellcam /home/pi/pikrellcam/media /tmp/pikrellcam.log]
circular buffer allocate: 26.25 MBytes (35 seconds at 6.0 Mbits/sec)
top status area: x:0 y:0 dx:640 dy:47
inform area: x:0 y:47 dx:640 dy:273
adj_control area: x:0 y:273 dx:640 dy:47
bottom status area: x:0 y:320 dx:640 dy:32
sunrise/sunset times: valid dawn/dusk times: valid
dawn: 7:21
sunrise: 7:47
sunset: 21:28
dusk: 21:54

Any ideas? I'm going to try changing it to "filename $N_%F_%H.%M.%S.jpg" and look at it again. I'd like to be able to keep the naming the way I did, but if not, I can deal with that. Thanks for being patient with this noob.

billw
Posts: 403
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 6:06 pm

boomlikethat wrote: Any ideas? I'm going to try changing it to "filename $N_%F_%H.%M.%S.jpg" and look at it again. I'd like to be able to keep the naming the way I did, but if not, I can deal with that. Thanks for being patient with this noob.
If the program says bad config then it should fall back to using the default which should work, but
maybe there's a problem there.
But at least you need to keep "pikrellcam -v" running until it does a motion detect (push somebody
in front of the camera if you have to :) ) so we can see all the debug plus possible error output.

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 6:25 pm

billw wrote:
boomlikethat wrote: Any ideas? I'm going to try changing it to "filename $N_%F_%H.%M.%S.jpg" and look at it again. I'd like to be able to keep the naming the way I did, but if not, I can deal with that. Thanks for being patient with this noob.
If the program says bad config then it should fall back to using the default which should work, but
maybe there's a problem there.
But at least you need to keep "pikrellcam -v" running until it does a motion detect (push somebody
in front of the camera if you have to :) ) so we can see all the debug plus possible error output.
Ask, and you shall receive :D

Just got this:

Bad config file option: filename %N_%F_%H.%M.%S.jpg

mmalcam_config_parameter_set: sharpness 0 [config set (not camera)]
mmalcam_config_parameter_set: contrast 0 [config set (not camera)]
mmalcam_config_parameter_set: brightness 50 [config set (not camera)]
mmalcam_config_parameter_set: saturation 0 [config set (not camera)]
mmalcam_config_parameter_set: iso 0 [config set (not camera)]
mmalcam_config_parameter_set: shutter_speed 0 [config set (not camera)]
mmalcam_config_parameter_set: exposure_compensation 0 [config set (not camera)]
mmalcam_config_parameter_set: video_stabilisation false [config set (not camera)]
mmalcam_config_parameter_set: raw_capture false [config set (not camera)]
mmalcam_config_parameter_set: rotation 0 [config set (not camera)]
mmalcam_config_parameter_set: exposure_mode auto [config set (not camera)]
mmalcam_config_parameter_set: image_effect none [config set (not camera)]
mmalcam_config_parameter_set: hflip off [config set (not camera)]
mmalcam_config_parameter_set: vflip off [config set (not camera)]
mmalcam_config_parameter_set: crop 0 0 65536 65536 [config set (not camera)]
mmalcam_config_parameter_set: metering_mode average [config set (not camera)]
mmalcam_config_parameter_set: white_balance auto [config set (not camera)]
mmalcam_config_parameter_set: color_effect false 128 128 [config set (not camera)]

2015-07-27 14:23:02 ==== PiKrellCam started ====
using FIFO: /home/pi/pikrellcam/www/FIFO
using mjpeg: /run/pikrellcam/mjpeg.jpg
execl:[/home/pi/pikrellcam/scripts-dist/_init /home/pi/pikrellcam /home/pi/pikrellcam/media /run/pikrellcam/mjpeg.jpg /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log]
execl:[/home/pi/pikrellcam/scripts/startup /home/pi/pikrellcam /home/pi/pikrellcam/media /tmp/pikrellcam.log]
circular buffer allocate: 26.25 MBytes (35 seconds at 6.0 Mbits/sec)
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
camera_component_create: mmal_component_enable failed. Status: Out of resources
Segmentation fault

I do get the .mp4, and stills of the entire camera area. Filenames match my modifications, no fallback to any default on those. No thumbs of just the motion-area.

Jasimo
Posts: 51
Joined: Mon Apr 27, 2015 11:50 am

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 6:42 pm

billw wrote:
boomlikethat wrote:
Jasimo wrote:Hi,
need help again ;-)
I just setup the regions for my cam and i try to save this, but after a stop/start my setting for the regions are gone. Could someone pls explain the load/save functionality.
I want my regions to load at startup.
rgs
Jan
@Jasimo,

Here's what I did. After I created all the regions, I typed a name (I made it easy, I made it "1") in the box to the left for "Save", and then clicked "Save".

If I needed to start/stop, or reboot the Pi, I typed in "1" in the box next to the "Load" button, then clicked "Load". That works.

Now, if you look in the ~/.pikrellcam folder, you'll see the "motion-regions.conf" (the default regions filename) and any others (in my case, "motion-regions-1.conf"). I'm guessing you could rename the file you made to the default name.

Then it would load your settings by default, but it may get overwritten on any updates.
Yes, you can type in "default" as the name and that should work. Or you can give it any custom
name you want. It can be "1" as suggested or any name that means something if you have
multiple Pi setups. Names like backyard, window, etc. Then for each pi, put in
~/.pikrellcam/at-commands.conf a startup motion regions load depending on Pi:

Code: Select all

daily start "@motion load_regions window"
Eventually I'm going to add a way to list on the OSD the custom regions you have saved,
but for not just look in ~/.pikrellcam to see regions you have saved, names
like: motion-regions-window.conf
thanks boomlikethat and billw I got it working with your help.

billw
Posts: 403
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 6:45 pm

boomlikethat wrote: circular buffer allocate: 26.25 MBytes (35 seconds at 6.0 Mbits/sec)
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
camera_component_create: mmal_component_enable failed. Status: Out of resources
Segmentation fault

I do get the .mp4, and stills of the entire camera area. Filenames match my modifications, no fallback to any default on those. No thumbs of just the motion-area.
The command line pikrellcam failed because another pikrellcam is still running. If you
did hit the stop button from the web page and still get that error. Do a killall from the terminal
before running pikrellcam -v:

Code: Select all

killall -9 pikrellcam
pikrellcam -v

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 7:15 pm

billw wrote:
boomlikethat wrote: circular buffer allocate: 26.25 MBytes (35 seconds at 6.0 Mbits/sec)
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
camera_component_create: mmal_component_enable failed. Status: Out of resources
Segmentation fault

I do get the .mp4, and stills of the entire camera area. Filenames match my modifications, no fallback to any default on those. No thumbs of just the motion-area.
The command line pikrellcam failed because another pikrellcam is still running. If you
did hit the stop button from the web page and still get that error. Do a killall from the terminal
before running pikrellcam -v:

Code: Select all

killall -9 pikrellcam
pikrellcam -v
Ok, did that. Here's what I'm getting after killall and pikrellcam -v:

[email protected] ~ $ pikrellcam -v
Bad config file option: filename %N_%F_%H.%M.%S.jpg

mmalcam_config_parameter_set: sharpness 0 [config set (not camera)]
mmalcam_config_parameter_set: contrast 0 [config set (not camera)]
mmalcam_config_parameter_set: brightness 50 [config set (not camera)]
mmalcam_config_parameter_set: saturation 0 [config set (not camera)]
mmalcam_config_parameter_set: iso 0 [config set (not camera)]
mmalcam_config_parameter_set: shutter_speed 0 [config set (not camera)]
mmalcam_config_parameter_set: exposure_compensation 0 [config set (not camera)]
mmalcam_config_parameter_set: video_stabilisation false [config set (not camera)]
mmalcam_config_parameter_set: raw_capture false [config set (not camera)]
mmalcam_config_parameter_set: rotation 0 [config set (not camera)]
mmalcam_config_parameter_set: exposure_mode auto [config set (not camera)]
mmalcam_config_parameter_set: image_effect none [config set (not camera)]
mmalcam_config_parameter_set: hflip off [config set (not camera)]
mmalcam_config_parameter_set: vflip off [config set (not camera)]
mmalcam_config_parameter_set: crop 0 0 65536 65536 [config set (not camera)]
mmalcam_config_parameter_set: metering_mode average [config set (not camera)]
mmalcam_config_parameter_set: white_balance auto [config set (not camera)]
mmalcam_config_parameter_set: color_effect false 128 128 [config set (not camera)]

2015-07-27 15:12:36 ==== PiKrellCam started ====
using FIFO: /home/pi/pikrellcam/www/FIFO
using mjpeg: /run/pikrellcam/mjpeg.jpg
execl:[/home/pi/pikrellcam/scripts-dist/_init /home/pi/pikrellcam /home/pi/pikrellcam/media /run/pikrellcam/mjpeg.jpg /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log]
execl:[/home/pi/pikrellcam/scripts/startup /home/pi/pikrellcam /home/pi/pikrellcam/media /tmp/pikrellcam.log]
circular buffer allocate: 26.25 MBytes (35 seconds at 6.0 Mbits/sec)
top status area: x:0 y:0 dx:640 dy:47
inform area: x:0 y:47 dx:640 dy:273
adj_control area: x:0 y:273 dx:640 dy:47
bottom status area: x:0 y:320 dx:640 dy:32
sunrise/sunset times: valid dawn/dusk times: valid
dawn: 7:21
sunrise: 7:47
sunset: 21:28
dusk: 21:54
command_process: motion show_regions toggle
command_process: motion load_regions 1
regions config file: /home/pi/.pikrellcam/motion-regions-1.conf
Video record: /home/pi/pikrellcam/media/videos/0_2015-07-27_15.12.55.mp4.h264 ...
Event add [motion preview save] period=0
Event func -> [motion preview save] period=0
event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/0_2015-07-27_15.12.55.jpg
Event add [motion preview save] period=0
Event func -> [motion preview save] period=0
event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/0_2015-07-27_15.12.55.jpg
Event add [motion preview save] period=0
Event func -> [motion preview save] period=0
event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/0_2015-07-27_15.12.55.jpg
Event add [motion preview save] period=0
Event func -> [motion preview save] period=0
event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/0_2015-07-27_15.12.55.jpg
Event add [motion preview save] period=0
Event func -> [motion preview save] period=0
event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/0_2015-07-27_15.12.55.jpg
Event add [motion preview save] period=0
Event func -> [motion preview save] period=0
event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/0_2015-07-27_15.12.55.jpg
Event add [motion preview save] period=0
Event func -> [motion preview save] period=0
event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/0_2015-07-27_15.12.55.jpg
Event add [motion preview save] period=0
Event func -> [motion preview save] period=0
event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/0_2015-07-27_15.12.55.jpg
Video motion record stopped.
execl:[(MP4Box -fps 24 -add /home/pi/pikrellcam/media/videos/0_2015-07-27_15.12.55.mp4.h264 /home/pi/pikrellcam/media/videos/0_2015-07-27_15.12.55.mp4 ; rm /home/pi/pikrellcam/media/videos/0_2015-07-27_15.12.55.mp4.h264)]
Event add [video saved notify] period=0
Event add [motion area thumb] period=0
Event add [preview save command] period=0
Event add [preview dispose] period=0
Event func -> [motion area thumb] period=0
execl:[/home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/0_2015-07-27_15.12.55.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log 60 60 466 234]
AVC-H264 import - frame size 1920 x 1080 at 24.000 FPS
/home/pi/pikrellcam/scripts-dist/_thumb: line 40: convert: command not found
child exit: ret=0 pid=0 Resource temporarily unavailable
Event func -> [preview save command] period=0
execl:[/home/pi/pikrellcam/scripts/preview-save /run/pikrellcam/0_2015-07-27_15.12.55.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log 60 60 466 234]
/home/pi/pikrellcam/scripts/preview-save: line 83: [: YO: integer expression expected
/home/pi/pikrellcam/scripts/preview-save: line 95: convert: command not found
child exit: ret=0 pid=0 Resource temporarily unavailable
Event func -> [preview dispose] period=0
event_preview_dispose(); removing /run/pikrellcam/0_2015-07-27_15.12.55.jpg
AVC Import results: 505 samples - Slices: 12 I 493 P 0 B - 0 SEI - 12 IDR
Saving to /home/pi/pikrellcam/media/videos/0_2015-07-27_15.12.55.mp4: 0.500 secs Interleaving
Event func -> [video saved notify] period=09/100)
child exit: ret=0 pid=3004 Success
command_process: quit

billw
Posts: 403
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 7:39 pm

boomlikethat wrote: Event func -> [motion area thumb] period=0
execl:[/home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/0_2015-07-27_15.12.55.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log 60 60 466 234]
AVC-H264 import - frame size 1920 x 1080 at 24.000 FPS
/home/pi/pikrellcam/scripts-dist/_thumb: line 40: convert: command not found
child exit: ret=0 pid=0 Resource temporarily unavailable
Looks like you have no convert command. Is the imagemagick package installed?

Code: Select all

apt-get update
apt-get install imagemagick
Looks like I need to add run time checks for expected commands and log a message for that.

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 8:16 pm

billw wrote:
boomlikethat wrote: Event func -> [motion area thumb] period=0
execl:[/home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/0_2015-07-27_15.12.55.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log 60 60 466 234]
AVC-H264 import - frame size 1920 x 1080 at 24.000 FPS
/home/pi/pikrellcam/scripts-dist/_thumb: line 40: convert: command not found
child exit: ret=0 pid=0 Resource temporarily unavailable
Looks like you have no convert command. Is the imagemagick package installed?

Code: Select all

apt-get update
apt-get install imagemagick
Looks like I need to add run time checks for expected commands and log a message for that.
You know, that's what jbeale suggested as well. But I typed in what I thought he said, apt-get install imagmagik (no e). Now it's installing. I'll let you know, thanks!

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 8:38 pm

boomlikethat wrote:
billw wrote:
boomlikethat wrote: Event func -> [motion area thumb] period=0
execl:[/home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/0_2015-07-27_15.12.55.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log 60 60 466 234]
AVC-H264 import - frame size 1920 x 1080 at 24.000 FPS
/home/pi/pikrellcam/scripts-dist/_thumb: line 40: convert: command not found
child exit: ret=0 pid=0 Resource temporarily unavailable
Looks like you have no convert command. Is the imagemagick package installed?

Code: Select all

apt-get update
apt-get install imagemagick
Looks like I need to add run time checks for expected commands and log a message for that.
You know, that's what jbeale suggested as well. But I typed in what I thought he said, apt-get install imagmagik (no e). Now it's installing. I'll let you know, thanks!

...and now thumbs are working! Thanks billw and jbeale!

toadleyb
Posts: 21
Joined: Sat Jan 04, 2014 11:05 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 10:09 pm

toadleyb wrote:Awesome piece of software. I have been using Raspimjpeg for quite a while and just start using this about a week ago. Couple of questions.

I can't seem to get it to generate thumbnails. I followed the post earlier in the thread to set it up. I copied the preview-save to the scripts directory. Opened the file and uncommented the appropriate commands and added the line to pikrellcam.conf to run preview save. Exactly what lines do I need to uncomment in the preview-save script to get it to save thumbnails? I do have it succesfully emailing me via the preview save script so I know the script is running.

Also I am getting a lot of false detects. I have the camera in my kitchen and in the detects I keep getting there is no noticeable motion. The only thing I see is very faint light changes. Can someone explain in noob terms changing the motion settings to get the appropriate detection.

If I go wander around in front of the camera instead of getting one long video of me I get several short videos with different portions of my wandering. I have the motion gap setting at 5 and from what I understand in reading the file this means if it continues to sense motion within 5 seconds it will continue to record the same video until it does not sense motion for 5 seconds and then it will end after whatever setting you have set for post gap. Am I correct?

I don't understand at all what vectors are. I assume the regions are simply to highlight the areas you want it to detect motion and it will not look for motion anywhere else.

I am using this more as just a learning experience than as an actual security cam. Although my apartment did get broken into a couple of years ago in the middle of the day and I wish I had this then!

Thanks for the help and the great software.
I have solved 99% of these problems by simply doing a completely clean install of Raspbian and then a clean install of pikrellcam. There must have been something in my install that it did not like.

I was still having some problems with not getting thumbnails but thanks to a post from jbeale realized I needed to manually install imagemagick before it would work.

The only thing I can't get working now is the email. With the newest software do I want to edit preview-save in the scripts directory or the one in the scripts-dist directory? I tried editing the one in the scripts directory and it is not working. I had this working before the clean install. I can email manually from the command line so I know that is working.

Thanks again for all the help.

billw
Posts: 403
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 11:06 pm

toadleyb wrote:
I have solved 99% of these problems by simply doing a completely clean install of Raspbian and then a clean install of pikrellcam. There must have been something in my install that it did not like.

I was still having some problems with not getting thumbnails but thanks to a post from jbeale realized I needed to manually install imagemagick before it would work.

The only thing I can't get working now is the email. With the newest software do I want to edit preview-save in the scripts directory or the one in the scripts-dist directory? I tried editing the one in the scripts directory and it is not working. I had this working before the clean install. I can email manually from the command line so I know that is working.

Thanks again for all the help.
If you've eone a clean install from a recent git clone the packages imagemagick and mpack (the emailer)
should both be installed by the installer.
Thumbs are now done automatically so you shouldn't have to do anything for that.
To get the emailing you have to edit preview-save in the scripts directory and not the one
in the scripts-dist directory. In the preview-save script uncomment the two lines:

Code: Select all

mpack -s [email protected]$HOSTNAME $PREVIEW_JPEG $MY_EMAIL
echo "mpack -s [email protected]$HOSTNAME $PREVIEW_JPEG $MY_EMAIL" >> $LOG_FILE
and make sure the MY_EMAIL line has your correct email address.
Finally, in pikrellcam.conf, this line must be set and not commented out:

Code: Select all

on_motion_preview_save $C/preview-save  $F $m $P $G
If all that doen't work, post your log file around the line where it does an execl of preview-save.
Make sure the email address reported in the log is correct and then xxx it out before posting
it here. If the mpack command is failing you may have to resort to running pikrellcam -v in
a terminal to see if there is additional error output, but if you can run it from the command
line it should be running OK.

toadleyb
Posts: 21
Joined: Sat Jan 04, 2014 11:05 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jul 27, 2015 11:21 pm

Thanks again for the really quick response billw. I missed the change in the pikrellcam.conf file. I changed that and everything is working great. Awesome software.

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

another simple thumbnail page

Tue Jul 28, 2015 5:55 am

Ok, here's another version of a simple thumbnail page. The header shows disk use and total event count, plus link to main page. Each thumbnail image is a link to the .mp4 video in the media/videos/ directory, labelled with time & date, and video file size in MB. I'm not sure of a simple way to report the time duration of the video. I can't simply take the file-modification time difference between thumbnail and video, because I think the thumbnail could come from any point in the video.

Image

Code: Select all

<?php
// display JPEG images in directory in name order, with clickable links
function showGallery( $pathToVideo, $pathToThumbs )
{
  $output = "";
  $dir = opendir( $pathToThumbs );  // open the directory
  $a=array();  // hold filenames in array so we can sort them in order
  while (false !== ($fname = readdir($dir)))  // loop through directory
  { if (substr($fname, -4) == '.jpg') // select only *.jpg filenames
    { $a[]=$fname; } // add this filename to the array
  }
  closedir( $dir ); // close the directory, all done reading
  $counter = 0;     // count how many images total so far
  rsort($a);         // sorts the array of filenames in-place, in reverse order (newest at top)

  foreach($a as $fname){
      $vname = rtrim($fname, ".th.jpg") . ".mp4"; // filename X.th.jpg becomes X.mp4
      $tFile = "{$pathToThumbs}{$fname}"; // full pathname of thumbnail image
      $vFile = "{$pathToVideo}{$vname}";  // full pathname of video file
      $vSize = round(filesize($vFile) / (1024*1024) ); // filesize in MB
      $fModTime = filemtime($tFile);
      $fDate = @date('m/d', $fModTime);
      $fTime = @date('H:i:s', $fModTime);

      $output .= "<fieldset style=\"display:inline; padding:2px; vertical-align:middle;\">";
      $output .= "$fDate &nbsp;<b>$fTime</b>";
      $output .= "<div style=float:right>{$vSize}M</div><br>";
      $output .= "<a href=\"{$vFile}\">";
      $output .= "<img src=\"{$tFile}\" border=\"0\" /></a>";
      $output .= "</fieldset> ";
      $counter += 1;
  }
  $fModFirst = filemtime("{$pathToThumbs}{$a[0]}");
  $fDur = ($fModFirst - $fModTime) / 3600;
  $hours = number_format($fDur,1);  // hours with 1 decimal place
  echo "<html><head><title>Thumbnails</title></head><body><center>";
  diskSpace($pathToVideo);  // print disk usage
  echo "<big><big><b> &nbsp; &nbsp; &nbsp;<a href=index.php>PiKrellCam</a></b></big> &nbsp; &nbsp; ";
  echo "{$counter} events in {$hours} hours</big></center><hr>";

  echo $output;  // send out the completed HTML web page
  echo "</body> </html>"; // end of HTML file
}
function diskSpace( $vdir ){ // http://www.thecave.info/display-disk-free-space-percentage-in-php/
  $df = disk_free_space($vdir); // total free
  $dt = disk_total_space($vdir); // total on disk
  $du = sprintf('%.0f',($dt - $df) / (1024*1024));;  // total used (Mbytes)
  $dp = sprintf('%.1f',(($dt - $df) / $dt) * 100); // percent used
  echo "{$du} MB &nbsp;(${dp} %)";
}
showGallery("media/videos/","media/thumbs/");  // video and thumbnail directories
?>
Slightly different version, including current time, at
https://raw.githubusercontent.com/jbeal ... thumbs.php
Last edited by jbeale on Tue Jul 28, 2015 2:22 pm, edited 1 time in total.

Jasimo
Posts: 51
Joined: Mon Apr 27, 2015 11:50 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jul 28, 2015 7:53 am

Hi,
I think it would be fine to have an option to delete files in videos/stills etc which are older then x days. I know this can be done by a cron job, but it would be fine to have this also in the GUI somewhere. Just an idea for the next update.
Keep up the good work on this fine pice of code.
rgs
Jan

toadleyb
Posts: 21
Joined: Sat Jan 04, 2014 11:05 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jul 28, 2015 12:56 pm

I assume this is using htaccess for the password. (I am at work right now and can't SSH in).

I use an incognito tab normally to login and when I close it it clears the password. Each time I open a new window it prompts for the password. I inadvertently accessed it from a normal window yesterday and it no longer prompts for a password. This is using Chrome. I have turned off the setting for Chrome to run in the background and closed the browser. I have even rebooted and it still does not prompt for a password. I really don't want my co-workers having access to my security cam. I have cleared the browsing history so at least the URL does not autofill.

How can I clear this password from my browser?

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: another simple thumbnail page

Tue Jul 28, 2015 1:05 pm

jbeale wrote:Ok, here's another version of a simple thumbnail page. The header shows disk use and total event count, plus link to main page. Each thumbnail image is a link to the .mp4 video in the media/videos/ directory, labelled with time & date, and video file size in MB. I'm not sure of a simple way to report the time duration of the video. I can't simply take the file-modification time difference between thumbnail and video, because I think the thumbnail could come from any point in the video.

Image

Code: Select all

<?php
// display JPEG images in directory in name order, with clickable links
function showGallery( $pathToVideo, $pathToThumbs )
{
  $output = "";
  $dir = opendir( $pathToThumbs );  // open the directory
  $a=array();  // hold filenames in array so we can sort them in order
  while (false !== ($fname = readdir($dir)))  // loop through directory
  { if (substr($fname, -4) == '.jpg') // select only *.jpg filenames
    { $a[]=$fname; } // add this filename to the array
  }
  closedir( $dir ); // close the directory, all done reading
  $counter = 0;     // count how many images total so far
  rsort($a);         // sorts the array of filenames in-place, in reverse order (newest at top)

  foreach($a as $fname){
      $vname = rtrim($fname, ".th.jpg") . ".mp4"; // filename X.th.jpg becomes X.mp4
      $tFile = "{$pathToThumbs}{$fname}"; // full pathname of thumbnail image
      $vFile = "{$pathToVideo}{$vname}";  // full pathname of video file
      $vSize = round(filesize($vFile) / (1024*1024) ); // filesize in MB
      $fModTime = filemtime($tFile);
      $fDate = @date('m/d', $fModTime);
      $fTime = @date('H:i:s', $fModTime);

      $output .= "<fieldset style=\"display:inline; padding:2px; vertical-align:middle;\">";
      $output .= "$fDate &nbsp;<b>$fTime</b>";
      $output .= "<div style=float:right>{$vSize}M</div><br>";
      $output .= "<a href=\"{$vFile}\">";
      $output .= "<img src=\"{$tFile}\" border=\"0\" /></a>";
      $output .= "</fieldset> ";
      $counter += 1;
  }
  $fModFirst = filemtime("{$pathToThumbs}{$a[0]}");
  $fDur = ($fModFirst - $fModTime) / 3600;
  $hours = number_format($fDur,1);  // hours with 1 decimal place
  echo "<html><head><title>Thumbnails</title></head><body><center>";
  diskSpace($pathToVideo);  // print disk usage
  echo "<big><big><b> &nbsp; &nbsp; &nbsp;<a href=index.php>PiKrellCam</a></b></big> &nbsp; &nbsp; ";
  echo "{$counter} events in {$hours} hours</big></center><hr>";

  echo $output;  // send out the completed HTML web page
  echo "</body> </html>"; // end of HTML file
}
function diskSpace( $vdir ){ // http://www.thecave.info/display-disk-free-space-percentage-in-php/
  $df = disk_free_space($vdir); // total free
  $dt = disk_total_space($vdir); // total on disk
  $du = sprintf('%.0f',($dt - $df) / (1024*1024));;  // total used (Mbytes)
  $dp = sprintf('%.1f',(($dt - $df) / $dt) * 100); // percent used
  echo "{$du} MB &nbsp;(${dp} %)";
}
showGallery("media/videos/","media/thumbs/");  // video and thumbnail directories
?>
@jbeale:

Just tried this. Nice job!

billw
Posts: 403
Joined: Tue Sep 18, 2012 8:23 pm

Re: another simple thumbnail page

Tue Jul 28, 2015 2:12 pm

jbeale wrote:Ok, here's another version of a simple thumbnail page. The header shows disk use and total event count, plus link to main page. Each thumbnail image is a link to the .mp4 video in the media/videos/ directory, labelled with time & date, and video file size in MB. I'm not sure of a simple way to report the time duration of the video. I can't simply take the file-modification time difference between thumbnail and video, because I think the thumbnail could come from any point in the video.
Looking good! The only way I know to get an accurate video time is to decode the mp4. avconv -i or
ffmpeg -i can do it for you and will extract a Duration field. But for each video this takes time and
for a page full of videos it can slow the load time. Otherwise it's just an estimate based on file
size and that's really no better than just reporting file size. So for now I think leaving it at file
size is good enough. I found this page if you want to think about a real time (you can use avconv -i
instead of the ffmpeg -i in the examples):
http://stackoverflow.com/questions/4966 ... -using-php

billw
Posts: 403
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jul 28, 2015 2:20 pm

toadleyb wrote:I assume this is using htaccess for the password. (I am at work right now and can't SSH in).

I use an incognito tab normally to login and when I close it it clears the password. Each time I open a new window it prompts for the password. I inadvertently accessed it from a normal window yesterday and it no longer prompts for a password. This is using Chrome. I have turned off the setting for Chrome to run in the background and closed the browser. I have even rebooted and it still does not prompt for a password. I really don't want my co-workers having access to my security cam. I have cleared the browsing history so at least the URL does not autofill.

How can I clear this password from my browser?
It's not using htaccess now and the current password option is weak. But using htaccess
is an important todo and should happen soon.

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

Re: another simple thumbnail page

Tue Jul 28, 2015 3:40 pm

billw wrote:Looking good! The only way I know to get an accurate video time is to decode the mp4. avconv -i or
ffmpeg -i can do it for you and will extract a Duration field. But for each video this takes time and
for a page full of videos it can slow the load time
I agree. If exact file duration is important, I think it's better to save that information somewhere when the file is originally recorded, but that' s a slippery slope that leads to a full database... I think file size is probably good enough, obviously you can get the exact time by watching the video. Mostly the number tells me if it was a single event, or there was more activity (probably not showing in the single thumbnail) that extended the record time.
For viewing remotely over a limited-bandwidth link (or on my phone, which won't play the videos) maybe there should be another page which links to a full-sized still frame, instead of the video.

mrlinux2u
Posts: 214
Joined: Sat Sep 24, 2011 8:38 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jul 28, 2015 4:14 pm

1st of All to billw (and jbeale) congratulations on an excellent program - much better than using motion on it's own.

Now to my problem, every now and then PiKrellCam will start deleting videos that have been created (either motion triggered or manually triggered) just as they've been converted to mp4.

PiKrellCam will display the fact that an mp4 file has been created, but as soon as you goto look at it, it's been deleted, (I can see the h264 file being saved if I ssh into my Pi). It seems to happen after PiKrellCam has been running for a number of hours (not sure how many as I haven't timed the issue), but I can re-produce the problem. Restarting PiKrellCam / rebooting the Pi seems to fix it for a while. BTW, the

I've checked the log file and the mp4box command seems to run OK (see below) :

Example of manual recording..

execl:[(MP4Box -quiet -fps 5 -add /home/pi/pikrellcam/media/videos/manual_2015-07-28_16.53.36_0.mp4.h264 /home/pi/pikrellcam/media/videos/manual_2015-07-28$
event_preview_dispose(); removing /run/pikrellcam/manual_2015-07-28_16.53.36_0.jpg

Example of motion based recording..

execl:[(MP4Box -quiet -fps 5 -add /home/pi/pikrellcam/media/videos/motion_2015-07-28_16.45.32_55.mp4.h264 /home/pi/pikrellcam/media/videos/motion_2015-07-2$
execl:[/home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/motion_2015-07-28_16.45.32_55.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tm$
convert /run/pikrellcam/motion_2015-07-28_16.45.32_55.jpg -crop 1188x677+1+15 -resize 200x200 /home/pi/pikrellcam/media/thumbs/motion_2015-07-28_16.45.32_5$
execl:[/home/pi/pikrellcam/scripts/preview-save /run/pikrellcam/motion_2015-07-28_16.45.32_55.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /$
event_preview_dispose(); removing /run/pikrellcam/motion_2015-07-28_16.45.32_55.jpg

Has anyone else notice this problem happening, and if so is there a solution?

Cheers, and many thanks in advance.

Paul

Addition to my original message above, I've just noticed an error message that's just shown up in the Pi's shell, which may explain why the mp4's aren't appearing :

Error importing /home/pi/motion/pics/cam2/media/videos/motion_2015-07-28_17.20.33_3.mp4.h264: BitStream Not Compliant

And below, an example of when an mp4 does get created successfully :
Saving to /home/pi/motion/pics/cam2/media/videos/motion_2015-07-28_17.18.22_1.mp4: 0.500 secs Interleaving

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jul 28, 2015 5:05 pm

I have not had the mp4 conversion error you report (have been running PiKrellCam 24/7 for a week or so). This is a wild guess, but if the power supply is marginal, it might cause some bitstream errors during record, and create the .mp4 file conversion error. Do you know you have a solid 5V input to the RPi with power supply rated for 1A or more, and good quality USB power cable ? When recording video from the camera and/or using wifi, it uses more power than doing most other things.
It seems to happen after PiKrellCam has been running for a number of hours (not sure how many as I haven't timed the issue), but I can re-produce the problem. Restarting PiKrellCam / rebooting the Pi seems to fix it for a while.
This is often the case with power supply problems. Something heats up, the +5V supply level sags past some threshold, and the errors start. The Pi has a built-in self-resetting fuse which can affect this (voltage drop across the fuse depends on the temperature, and once it has been tripped it's never quite as good as it originally was in terms of resistance or voltage drop).
Last edited by jbeale on Tue Jul 28, 2015 5:11 pm, edited 1 time in total.

mrlinux2u
Posts: 214
Joined: Sat Sep 24, 2011 8:38 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jul 28, 2015 5:09 pm

jbeale wrote:I have not had the mp4 conversion error you report (have been running PiKrellCam 24/7 for a week or so). This is a wild guess, but if the power supply is marginal, it might cause some bitstream errors during record, and create the .mp4 file conversion error. Do you know you have a solid 5V input to the RPi with power supply rated for 1A or more, and good quality USB power cable ? When recording video from the camera and/or using wifi, it uses more power than doing most other things.
@jbeale,

Thanks for the quick replay.

I'm using the official Raspberry Pi 2A power supply (only had it 3 weeks) so I don't think it's power supply (but I could be wrong).

However, I've got another camera module I can try (just in case), I'll change it round later today and post my findings.

Cheers

Paul

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jul 28, 2015 5:14 pm

Not familiar with the official supply; hopefully comes with a good USB cord. I think many of the "low voltage" problems were due to cheap thin-conductor cables with too much voltage drop at the current drawn by R-Pi. But if not power supply, then I'm out of guesses (unless you've relocated your media directory to something external on a flaky network link)

mrlinux2u
Posts: 214
Joined: Sat Sep 24, 2011 8:38 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jul 28, 2015 5:29 pm

jbeale wrote:Not familiar with the official supply; hopefully comes with a good USB cord. I think many of the "low voltage" problems were due to cheap thin-conductor cables with too much voltage drop at the current drawn by R-Pi. But if not power supply, then I'm out of guesses (unless you've relocated your media directory to something external on a flaky network link)
The Pi-supply has a fixed good quality usb cord and is better than most power supplies I've used on my collection of Pi's. As for the media directory, I've tried placing it on a samba share (very stable connection), and using the default location on the SD card. I'm a bit stumped myself why this happening, but I'll keep trying to find a solution.

Cheers

Paul

Return to “Camera board”