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

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Nov 01, 2017 5:09 am

"Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details."

I do not recall seeing this error message on any install. I usually install PiKrellCam on a fresh clean Raspbian system and that's what works for me. 8GB SD cards are pretty cheap... I presume it is possible if you currently using, or have ever previously installed either nginx or another webserver on a Pi, there could be some conflicts with some system resources (ports, directories, file access permissions etc) preventing the PiKrellCam install from working as intended.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Nov 04, 2017 3:46 pm

There's an upgrade to V4.1 that has loop recording with loop diskusage percent limit.
Still & timelapse jpegs are included in media diskfree checking.
pikrellcam.conf has new on_motion_enable, on_loop_end and on_manual_end.
Fixed the video hang when pre-capture or other times are changed in the OSD.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Nov 05, 2017 6:29 pm

Thanks billw as always for this update. Regarding this line: "Still & timelapse jpegs are included in media diskfree checking."
Is there anything built-in to pikrellcam that does automatic archiving of stills & video to the /home/pi/pikrellcam/media/archive folder?

On some of my older installations I have a file ~/pikrellcam/scripts/pk-archive.sh as below that does this when called from my crontab, but I don't see this script file in the current distribution (?)

Code: Select all

#!/bin/bash
_ARCHIVE_OLDER_DAYS="-1 Days"

# Move _ARCHIVE_OLDER_DAYS stills and video to that date's archive folder
echo "archive_still day `date --date="$_ARCHIVE_OLDER_DAYS" +'%F'`"  > /home/pi/pikrellcam/www/FIFO
echo "archive_video day `date --date="$_ARCHIVE_OLDER_DAYS" +'%F'`"  > /home/pi/pikrellcam/www/FIFO

# if used space is over threshold, delete old files and directories to save storage space until threshold reached
# this keeps as much as possible files present
_USED_SPACE=`df  | grep sda1 | awk '{print $5}' |  sed -e "s/\%//g"`
# echo "used space: $_USED_SPACE%"

_USED_SPACE_LIMIT=80    # percent

if [[ ( "$_USED_SPACE" > "$_USED_SPACE_LIMIT" ) ]] ; then
 echo -e "used space over $_USED_SPACE_LIMIT%, deleting old files..."

 _LOOP=0;

 while [[ ( "$_USED_SPACE" > "$_USED_SPACE_LIMIT" )  && ( "$_LOOP" < "100" ) ]] ; do
  _OLDEST=`find /home/pi/pikrellcam/media/archive/ -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d "+" -f 1 | se                                         d -e "s/\-/\//g"`
  echo "oldest files:$_OLDEST"

  echo "delete oldest folder:/home/pi/pikrellcam/media/archive/$_OLDEST"
  rm -rfv "/home/pi/pikrellcam/media/archive/$_OLDEST"
  sync

  _USED_SPACE=`df  | grep root | awk '{print $5}' |  sed -e "s/\%//g"`
  echo "used space now: $_USED_SPACE%"
  _LOOP=$((_LOOP + 1))
 done

 echo "done"
 df
else
 echo -e "used space below $_USED_SPACE_LIMIT%, nothing to do!"
fi

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

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Nov 06, 2017 3:50 pm

jbeale wrote:
Sun Nov 05, 2017 6:29 pm
Thanks billw as always for this update. Regarding this line: "Still & timelapse jpegs are included in media diskfree checking."
Is there anything built-in to pikrellcam that does automatic archiving of stills & video to the /home/pi/pikrellcam/media/archive folder?

On some of my older installations I have a file ~/pikrellcam/scripts/pk-archive.sh as below that does this when called from my crontab, but I don't see this script file in the current distribution (?)
A script like that has never been in the pikrellcam distribution and the new diskfree checking feature is built into PKC (it's C code, not
a script). If you enable Setup->Config->Settings->Check_Archive_Diskfree then a delete script like that is not needed. But you still
need the top archive_still and archive_video part because so far PKC does not have an automatic archiving option. Perhaps I could
just add in a simple archiving script like the first part of what you show.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Nov 07, 2017 2:43 am

I guess I got the script from someone else here. I'd vote for an archiving feature. I find archiving necessary to keep the current thumbnail image page manageable in size. I do sometimes need to reference the older images so I don't delete them right away, but keeping 2+ weeks all on one page is too much to manage.

Ouba
Posts: 11
Joined: Sun Jan 01, 2017 4:12 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Nov 07, 2017 3:03 pm

Hello,

First : Sorry for my english...

Then : Very great software ! Thanks for the job.

I want to enabled the h264 streaming server regarding this post :

viewtopic.php?f=43&t=115583&start=425#p862399

I have some questions

1°) When I read :

##################################################################
put this in /etc/rc.local after pikrellcam start code:
sleep 15 && /root/start-gst-variable-rtsp-server.sh &

Where do I have to put it precisely ?


2°) I understand that I have to create a script "start-gst-variable-rtsp-server.sh" but where do i have tyo create it ?


Thanks in advance

Ouba
Posts: 11
Joined: Sun Jan 01, 2017 4:12 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Nov 07, 2017 8:32 pm

I put the script at this place /root/start-gst-variable-rtsp-server.sh

and edit the /etc/rc.local file like this

su pi -c '(sleep 5; /home/pi/pikrellcam/pikrellcam) &'
'(sleep 15 && /root/start-gst-variable-rtsp-server.sh) &'
exit 0

but ... with vlc on my local network it does not work ...

any idea ?

thanks a lot

stephencassidy
Posts: 37
Joined: Mon Aug 19, 2013 11:12 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Nov 07, 2017 11:29 pm

You may need to make the script executable with

chmod +x /root/start-gst-variable-rtsp-server.sh

The entry in my rc.local file looks like this

su pi -c '(sleep 5; /home/pi/pikrellcam/pikrellcam) &'

sleep 15 && /root/start-gst-variable-rtsp-server.sh &

The stream works but is quite flaky

Ste

User avatar
underwhelmd
Posts: 93
Joined: Fri Jul 08, 2016 10:05 pm
Location: East Coast, Canada

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Nov 08, 2017 6:50 pm

Has it been discussed how to change magnitude_limit, magnitude_count etc based on time of day such as using at-commands? If so, my apologies because I couldn't find it. I'd like to change mag limit and mag count at sunset and then back at sunrise. Thanks for any direction.

preset-no-servos.conf -

Code: Select all

<position 150 150>
<settings>
magnitude_limit 4
magnitude_count 3
burst_count 350
burst_frames 3
add_region 0.005 0.311 0.199 0.473
add_region 0.193 0.290 0.282 0.626
add_region 0.463 0.302 0.257 0.663
add_region 0.697 0.308 0.297 0.688

Ouba
Posts: 11
Joined: Sun Jan 01, 2017 4:12 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Nov 08, 2017 8:26 pm

Thank you Stef for helping me.

I'm still trying to access the h264 stream...

I did what you suggest me with : chmod +x /root/start-gst-variable-rtsp-server.sh

I put the same lines as in your rc.local file.

No success (until now ;-))

For the script start-gst-variable-rtsp-server.sh placed in /root/, is it correct that the first line must be :

#!/bin/bash ... or not ?

I also checked that ipv6 is disabled...

Still searching.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Nov 08, 2017 10:07 pm

underwhelmd wrote:
Wed Nov 08, 2017 6:50 pm
Has it been discussed how to change magnitude_limit, magnitude_count etc based on time of day such as using at-commands? If so, my apologies because I couldn't find it. I'd like to change mag limit and mag count at sunset and then back at sunrise. Thanks for any direction.
There's an example of at-command going to a preset, but I overlooked adding an example for changing mag/limit. To change for
the preset you are on to mag 10 count 20 at sunrise in at-commands.conf:

Code: Select all

daily  sunrise  "@motion limits 18 20"
From your preset-no-servos.conf, you have only one preset and the above command affects that. An alternative way is create a new
preset Config->Setup->Preset->New so you will have 2 settings selectable by the preset arrows up/down. Now you have one preset
position 1 (only one possible because no servos) and two settings presets at that position. Set the mag/count you want at each of the
settings and now the sunrise/sunset at commands can just go to the preset you want:

Code: Select all

daily  sunrise  "@preset goto 1 1"
daily  sunset   "@preset goto 1 2"
Use either @motion or @preset as is convenient for you. If you had servos, I would recommend using @preset.

User avatar
underwhelmd
Posts: 93
Joined: Fri Jul 08, 2016 10:05 pm
Location: East Coast, Canada

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Nov 09, 2017 12:25 am

billw wrote:
Wed Nov 08, 2017 10:07 pm

From your preset-no-servos.conf, you have only one preset and the above command affects that. An alternative way is create a new
preset Config->Setup->Preset->New so you will have 2 settings selectable by the preset arrows up/down. Now you have one preset
position 1 (only one possible because no servos) and two settings presets at that position. Set the mag/count you want at each of the
settings and now the sunrise/sunset at commands can just go to the preset you want:

Code: Select all

daily  sunrise  "@preset goto 1 1"
daily  sunset   "@preset goto 1 2"
Use either @motion or @preset as is convenient for you. If you had servos, I would recommend using @preset.

Thank you BillW. This ^ method works for me because I was changing regions at the same time (sunrise/sunset). So now I can remove the regions commands from at-commands.conf and simply have one command to change regions and mag limit and count at the same time. Tested and works.

Not that it matters but I was changing those settings at those times to minimize false positives from noise at night. Setting regions to only those lit well and making pikrellcam less sensitive means less false positives on that cam.

cheers

budman1758
Posts: 9
Joined: Mon Dec 19, 2016 8:44 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Nov 09, 2017 6:03 pm

Hello. Great piece of software!

Can someone tell me the exact syntax for sending commands to the FIFO from another machine on the network? I want to start and stop recording from other networked computers. I assume this is possible but I have tried and can't seem to make it work. I read the FIFO commands section but its not real clear to me the exact way to format the request. Thanks for any pointers in this regard. :?:

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Nov 09, 2017 8:00 pm

The instructions give an example of sending a command to the FIFO locally, try this first to check that it works.

As it turns out, you can use 'ssh' to execute any commands remotely:
https://www.qualitestgroup.com/resource ... using-ssh/

However to do so automatically from a script (without manually entering the password) you need to first set up the private key:
http://www.linuxproblem.org/art_9.html

budman1758
Posts: 9
Joined: Mon Dec 19, 2016 8:44 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Nov 09, 2017 9:25 pm

Thanks for the quick response.

From a SSH window logged in to the machine the software is on the commands work exactly as they are typed in the help page.

It also says "From the web page, command line or scripts, PiKrellCam is controlled by sending commands to a communication pipe named FIFO in the ~/pikrellcam/www directory."

I'm mostly interested in the first part "From the web page"....

How do you format the command? As a get request? If I add >echo "record on" > ~/pikrellcam/www/FIFO< (without the <>) to the ip address all I get is "not found"

I'm attempting to start and stop recording from a device that can send http commands. "From the web page" suggests you can send pipe commands from the url field on the web page of the camera OSD. Or any other browser or device on the network for that matter.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Nov 09, 2017 11:18 pm

Ah, I see what you mean. BillW can offer the authoritative response but I assumed "from the web page" meant simply that pushing the buttons that are already there on the page, cause the underlying html/php script to generate FIFO commands behind the scenes. Meaning you'd have to code up some more PHP scripts if you want other functions, and it would still be manual interaction with a mouse, not a simple http fetch from a script on another machine. I can imagine that one could write a script to act as a HTTP -> FIFO bridge. There would be security issues to think of.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Nov 10, 2017 12:25 am

There's a couple of ways to go to send a FIFO command from another machine from the command line.

Use ssh and sshpass (you may have to apt install sshpass). This works on my LAN where I have rpi1 set up
with static ip 192.168.0.31 and I have configured ssh to use port 20312. Omit the -p portnum part if your ssh
uses the default port 22. This should also work from outside your LAN if your router port forwards the ssh port
to the pi.

Code: Select all

    sshpass -p my-pi-password ssh -t [email protected] -p 20312 "echo record on > /home/pi/pikrellcam/www/FIFO"
or
    sshpass -p my-pi-password ssh -t [email protected] -p 20312 "echo record on > /home/pi/pikrellcam/www/FIFO"
Second way is to use the pikrellcam multicast feature, but this works only from machines on your LAN (not the WAN) and it works to
raspberry pi hostnames, not IP addresses.

There is a pkc-motion in the scripts-dist directory that sends a motion_enable, so I just took that and modified it to be
a general purpose FIFO command script (I'll probably add this to the next release). So copy this script into pkc-fifo in a bin
directory on a machine on your lan and make it executable:

Code: Select all

#!/usr/bin/env python
# tab-width: 4

# pkc-fifo multicasts a fifo command to all PiKrellCams on a LAN
# If the fifo command is more than one word, enclose it in quotes.

import sys
import socket
import time

# The PiKrellCam multicast group IP and port number is fixed:
PKC_MULTICAST_GROUP = '225.0.0.55'
PKC_MULTICAST_PORT  = 22555

# Open UDP multicast socket to write to.
send_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
send_socket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)

# UDP transmissions are unreliable.  So repeat sending the fifo command
# multiple times to ensure all PiKrellCams will receive it.
# Set a fraction of a second delay between repeat sends.
# The send will use a message id number from sum of command bytes so that
# each receiving PiKrellCam will execute the first fifo command it receives
# and then ignore within 2 second repeats of the same command.

repeat = 4
delay = .05

def usage():
    print "usage: pkc-fifo {host|host-list|all} \"fifo_command\""
    print "    Multicast a fifo command to PiKrellCams on a LAN."
    print "    If the fifo_command is more than one word, enclose it in quotes."
    print "    If host, host-list or all is not specified, all is assumed."
    print "    host-list is a comma separated list of hosts."
    print "Eg. start and stop a manual record on rpi1:"
    print "    pkc-fifo rpi1 \"record on\""
    print "    pkc-fifo rpi1 \"record off\""
    sys.exit()

argc = len(sys.argv)
if argc == 1:
    usage()
if argc == 2:
    hosts = "all"
    fifo_cmd = sys.argv[1]
if argc == 3:
    hosts = sys.argv[1]
    fifo_cmd = sys.argv[2]

ba = bytearray(fifo_cmd)
msg_id = sum(ba)

hostname = socket.gethostname()

for x in range(1, repeat + 1):
    msg = "%s:%d %s command @%s" % (hostname, msg_id, hosts, fifo_cmd)
#   print msg
    send_socket.sendto(msg, (PKC_MULTICAST_GROUP, PKC_MULTICAST_PORT))
    time.sleep(delay)
Now on that machine, to start and stop a manual record on a pi with hostname rpi1 (use quotes around the record command):

Code: Select all

pkc-fifo rpi1 "record on"
pkc-fifo rpi1 "record off"
Edit: if you want to do it by sending http commands, you need to send a put that runs the pikrellcam/www/fifo_command php script
and give the script the record arguments, like "fifo_command.php?cmd=record on".

Ouba
Posts: 11
Joined: Sun Jan 01, 2017 4:12 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Nov 13, 2017 1:11 pm

Still searching to make the H264 streaming server fonctionnal...

I'have this error at the start :

/root/start-gst-variable-rtsp-server.sh: 2: /root/start-gst-variable-rtsp-server.sh: / root/gst-gateworks-apps-master/bin/gst-variable-rtsp-server: not found

Any idea ?

solitarybee
Posts: 5
Joined: Wed Jun 07, 2017 12:34 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Nov 16, 2017 3:59 am

Is there any way in the PiKrellCam client to download batches of videos to my hard drive? The download button only does one at a time, and I have hundreds of videos I want to back up.

Thanks!

User avatar
Gavinmc42
Posts: 2204
Joined: Wed Aug 28, 2013 3:31 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Nov 16, 2017 4:12 am

Use the archive feature.
I archive my daily vids around 1am to an external WD purple drive.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

solitarybee
Posts: 5
Joined: Wed Jun 07, 2017 12:34 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Nov 16, 2017 4:15 am

Gavinmc42 wrote: Use the archive feature.
I archive my daily vids around 1am to an external WD purple drive.
Thanks! The archive by default just archives to the Pi SD. Any tips on how to direct archiving to a different folder?

User avatar
Gavinmc42
Posts: 2204
Joined: Wed Aug 28, 2013 3:31 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Nov 17, 2017 2:32 pm

When it is running, web in and check the help.
Check out the Media section near the bottom of the help for setting up the conf file to use external drives.
I also set it to archive the file to the archive section of my external USB caddy WD purple drive.
I don't remember exactly, it was a long time ago when I set it up

FYI, for everyone on the bleeding edge just rpi-updated to 4.14 on a clean Stretch Lite, everything working on a test unit so far :D
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 2204
Joined: Wed Aug 28, 2013 3:31 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Nov 18, 2017 7:30 am

Finally noticed there is a Timelapse option in Pikrellcam.

Was looking at IR strobes for my gen 3 system, ie night motion detection
This is a bit tricky to do
viewtopic.php?t=143820

But for Timelapse a GPIO could be set before the image and turned off after.
Is this feature already there?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Nov 19, 2017 4:46 pm

Gavinmc42 wrote:
Sat Nov 18, 2017 7:30 am
But for Timelapse a GPIO could be set before the image and turned off after.
Is this feature already there?
Timelapse is hardwired to do a capture, so right now that's not there. But I'm thinking that a timelapse capture event could be
diverted into calling a user script where a GPIO could be controlled around the capture. I'll look at doing that.

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

PKC 4.1.1 stereo audio does work

Sun Nov 19, 2017 5:56 pm

I see the help page on PiKrellCam 4.1.1 indicates that stereo audio has not been tested:

Code: Select all

audio_channels - default: 1  Set to 1 for mono or 2 (not tested yet) for stereo.
I enabled audio with 2 channels in pikrellcam.conf and can confirm that stereo audio is correctly streamed from a Pi Model A+ to a web browser (Google Chrome on Win 10), with several seconds delay. Stereo audio recorded with video also works, L and R channels are correct. When the live audio stream is started, the (single-core) CPU usage goes from 20% to 50%. I did not change the audio sample rate from the default.

Code: Select all

09:23:10 : mic opened: period_frames:600 period_buffer_size:2400 rate:24000 channels:2  MP3 quality:7
The audio input device I have is a BEHRINGER LINE 2 USB "Stereo line in to USB interface cable" https://www.amazon.com/gp/product/B01DT827FA/

Return to “Camera board”