Description
I've been using pikrellcam for a while now and once it was going have had few problems with it, an excellent though oft complicated piece of software which worked well for what I wanted at the time (probably 5 years ago).
It was installed initially to monitor activity in our garage which was broken into from a 'common area' of a set of flats soon after we arrived and more recently for extended periods when we weren't present. It served it's purpose well, at least until a couple of years ago. As you might imagine we haven't been away much over the past 2 years partly as a result of the closure on International borders so I haven't been monitoring it or the camera for a while. Now that things appear to moving again it was time to check everything and make sure it was working the way I wanted and at the same time bring the software up-to-date across the common Raspberry Pis I have been using.
So I tried using the system as it was and had no luck then I upgraded to the latest version of buster which worked ok for a couple of days then things started to go awry. As far as I am aware I didn't do anything strange just prior to it not working but...
An explanation of the system:-
2 x Raspberry Pi running Raspbian buster Linux xxxxxx 5.10.63+ #1459 Wed Oct 6 16:40:27 BST 2021 armv6l GNU/Linux
. Image used being Raspberry Pi OS Lite
and with a number of other pieces of software such as perl added. pikrellcam installed as per instructions. One of the Pi's is an original "B" model with no wireless and 2 USB sockets the other a more recent B+ both seem to work without obvious issues.
cd /home/pi
git clone https://github.com/billw2/pikrellcam.git
cd pikrellcam
./install-pikrellcam.sh
After running install-pikrellcam.sh
and going to the page http://168...115:8081
I now just get the error message "No preview...possible causes...". When first tried the upgrade and the software was running properly I changed one or two file locations and permissions and it is these, I wonder, where the errors crept in or is it more than this? From what I can see it all makes sense and 'should' work but then maybe there is something else going on. I need to add that, given buster uses systemd, I did follow instructions elsewhere for adding a pikrellcam.service file into /etc/systemd/system as per the instructions elsewhere in the 'issues' section although slightly modified (VIZ Cyber1000's "Error on autostart if /etc/rc.local is missing #68".
My first question would be, what user:group permissions are required on all files/directories involved? That may be all that is involved.
Some files from the system that might help pinpoint a problem are (all blank lines and comments extracted):-
~/.pikrellcam/pikrellcam.conf
install_dir /home/pi/pikrellcam
media_dir /var/www/camera_1
archive_dir archive
loop_dir loop
log_file /var/log/pikrellcam.log
log_lines 500
on_startup $C/startup $I $m $a $G
halt_enable on
multicast_enable on
loop_enable off
loop_record_time_limit 30
loop_diskusage_percent 30
motion_stills_enable off
motion_stills_per_minute 30
motion_enable on
motion_off_preset off
motion_record_time_limit 0
motion_vectors_dimming 45
motion_confirm_gap 4
motion_event_gap 20
motion_pre_capture 10
motion_post_capture 10
motion_preview_clean on
motion_show_counts off
preview_stall_warning on
motion_area_min_side 80
motion_stats off
motion_detects_fifo_enable off
audio_trigger_video off
audio_trigger_level 50
box_MP3_only off
video_motion_name_format motion_%F_%H.%M.%S_$N.mp4
video_manual_name_format manual_%F_%H.%M.%S_$N.mp4
diskfree_percent 20
check_media_diskfree off
check_archive_diskfree off
video_width 1
video_height 1080
video_fps 24
video_mp4box_fps 0.000
video_bitrate 6000000
mjpeg_width 1920
mjpeg_quality 80
mjpeg_divider 2
still_name_format image_%F_%H.%M.%S_$N.jpg
still_width 2592
still_height 1944
still_quality 100
video_timelapse_name_format tl_%F_%H.%M.%S_$n.mp4
timelapse_convert $c/_timelapse-convert $m $T $n $G $P $l
servo_pan_gpio -1
servo_tilt_gpio -1
servo_use_servoblaster off
servo_pan_min 120
servo_pan_max 180
servo_tilt_min 130
servo_tilt_max 170
servo_pan_invert off
servo_tilt_invert off
servo_move_steps 10
servo_move_step_msec 40
servo_preset_step_msec 20
servo_settle_msec 600
audio_enable off
audio_device plughw:1
audio_rate_Pi2 48000
audio_rate_Pi1 24000
audio_channels 1
audio_gain_dB 0
audio_mp3_quality_Pi2 2
audio_mp3_quality_Pi1 7
notify_duration 4
latitude 27.47027S
longitude 153.04139E
lc_time en_AU
config_sequence 47
annotate_format_string %a %b %e, %l:%M.%S %p
annotate_enable on
annotate_show_motion off
annotate_show_frame off
annotate_text_background_color 808080
annotate_text_brightness 255
annotate_text_size 40
sharpness 0
contrast 0
brightness 50
saturation 0
iso 0
shutter_speed 0
exposure_compensation 0
video_stabilisation false
raw_capture false
rotation 180
exposure_mode night
image_effect washedout
hflip off
vflip off
crop 0 0 65536 65536
metering_mode average
white_balance auto
color_effect false 128 128
As you will see I have changed the location of some of the files at the start but most are part of the original setup. Is there a way of completely shutting down the audio? I do not need it and perhaps this takes up some processing capabilities from the Pi?
~/pikrellcam/scripts/startup-script
install_dir=$1
media_dir=$2
archive_dir=$3
log_file=$4
if [ "$log_file" == "" ]
then
log_file=/dev/null
fi
if [ "$MOUNT_DISK" == "" ]
then
echo " MOUNT_DISK is not set." >> $log_file
else
if ! grep -q $MOUNT_DISK /proc/partitions
then
echo " Cannot find $MOUNT_DISK to mount on $media_dir" >> $log_file
MOUNT_DISK=""
fi
fi
if [ "$MOUNT_DISK" != "" ]
then
disk_device=/dev/$MOUNT_DISK
cd $install_dir
curmount_dir=`fgrep "$disk_device " /etc/mtab | cut -f 2 -d ' ' `
if [ "$curmount_dir" != "" ]
then
if [ "$curmount_dir" != "$media_dir" ]
then
echo " umount $disk_device from $curmount_dir" >> $log_file
sudo umount $disk_device
fi
fi
if ! mountpoint -q $media_dir
then
FS_TYPE=`stat -f -c '%T' $media_dir`
if [ "$FS_TYPE" != "tmpfs" ]
then
if sudo mount $disk_device $media_dir
then
echo " mounted $disk_device on $media_dir" >> $log_file
else
echo " mount of $disk_device on $media_dir failed" >> $log_file
fi
#
# PiKrellCam will make subdirectories and fixup permissions.
else
echo " not mounting $disk_device because $media_dir is a tmpfs" >> $log_file
fi
else
echo " $media_dir is already mounted." >> $log_file
fi
fi
if [ "$NFS_ARCHIVE" == "" ]
then
echo " NFS_ARCHIVE is not set." >> $log_file
fi
if [ "$NFS_ARCHIVE" != "" ]
then
fs_type=$(stat -f -L -c %T $archive_dir)
stale=$(echo "$fs_type" | grep "Stale")
if [ "$stale" != "" ]
then
echo " NFS archive directory $archive_dir is stale." >> $log_file
echo " Remote NFS server may be down?" >> log_file
echo " To force unmount, run: sudo umount -f $archive_dir" >> log_file
elif [ "$fs_type" == "nfs" ]
then
echo " $archive_dir is already NFS mounted." >> $log_file
else
cp $install_dir/www/images/nfs-mounting.jpg /run/pikrellcam/mjpeg.jpg
sudo mount $NFS_ARCHIVE &
for ((p = 0; p < 10; p++))
do
sleep 1
fs_type=$(stat -f -L -c %T $archive_dir)
if [ "$fs_type" == "nfs" ]
then
echo " NFS mounted $NFS_ARCHIVE" >> $log_file
break;
else
echo " NFS mount of $NFS_ARCHIVE slow or failed ..." >> $log_file
fi
done
fi
fi
install_dir=$1
media_dir=$2
archive_dir=$3
log_file=$4
if [ "$log_file" == "" ]
then
log_file=/dev/null
fi
if [ "$MOUNT_DISK" == "" ]
then
echo " MOUNT_DISK is not set." >> $log_file
else
if ! grep -q $MOUNT_DISK /proc/partitions
then
echo " Cannot find $MOUNT_DISK to mount on $media_dir" >> $log_file
MOUNT_DISK=""
fi
fi
if [ "$MOUNT_DISK" != "" ]
then
disk_device=/dev/$MOUNT_DISK
cd $install_dir
curmount_dir=`fgrep "$disk_device " /etc/mtab | cut -f 2 -d ' ' `
if [ "$curmount_dir" != "" ]
then
if [ "$curmount_dir" != "$media_dir" ]
then
echo " umount $disk_device from $curmount_dir" >> $log_file
sudo umount $disk_device
fi
fi
if ! mountpoint -q $media_dir
then
FS_TYPE=`stat -f -c '%T' $media_dir`
if [ "$FS_TYPE" != "tmpfs" ]
then
if sudo mount $disk_device $media_dir
then
echo " mounted $disk_device on $media_dir" >> $log_file
else
echo " mount of $disk_device on $media_dir failed" >> $log_file
fi
#
# PiKrellCam will make subdirectories and fixup permissions.
else
echo " not mounting $disk_device because $media_dir is a tmpfs" >> $log_file
fi
else
echo " $media_dir is already mounted." >> $log_file
fi
fi
if [ "$NFS_ARCHIVE" == "" ]
then
echo " NFS_ARCHIVE is not set." >> $log_file
fi
if [ "$NFS_ARCHIVE" != "" ]
then
fs_type=$(stat -f -L -c %T $archive_dir)
stale=$(echo "$fs_type" | grep "Stale")
if [ "$stale" != "" ]
then
echo " NFS archive directory $archive_dir is stale." >> $log_file
echo " Remote NFS server may be down?" >> log_file
echo " To force unmount, run: sudo umount -f $archive_dir" >> log_file
elif [ "$fs_type" == "nfs" ]
then
echo " $archive_dir is already NFS mounted." >> $log_file
else
cp $install_dir/www/images/nfs-mounting.jpg /run/pikrellcam/mjpeg.jpg
sudo mount $NFS_ARCHIVE &
for ((p = 0; p < 10; p++))
do
sleep 1
fs_type=$(stat -f -L -c %T $archive_dir)
if [ "$fs_type" == "nfs" ]
then
echo " NFS mounted $NFS_ARCHIVE" >> $log_file
break;
else
echo " NFS mount of $NFS_ARCHIVE slow or failed ..." >> $log_file
fi
done
fi
fi
As all files are on the micro-sd card there are no mountable drives or files involved and everything resides off the root directory.
While wandering around trying to find a way around the issues I did a dmesg
immediately after booting which seems to indicate a new set of video drivers being used, perhaps is the problem and it won't work under buster
but then other questions suggest it does. Taking out only those lines that include the 5 letters 'video' I get
[ 20.163275] videodev: Linux video capture interface: v2.00
[ 20.469861] bcm2835-isp bcm2835-isp: Device node output[0] registered as /dev/video13
[ 21.088309] bcm2835-isp bcm2835-isp: Device node capture[0] registered as /dev/video14
[ 21.102951] bcm2835-isp bcm2835-isp: Device node capture[1] registered as /dev/video15
[ 21.103318] bcm2835-codec bcm2835-codec: Device registered as /dev/video10
[ 21.104953] bcm2835-isp bcm2835-isp: Device node stats[2] registered as /dev/video16
[ 21.142072] bcm2835-codec bcm2835-codec: Device registered as /dev/video11
[ 21.196633] bcm2835-codec bcm2835-codec: Device registered as /dev/video12
[ 21.238010] bcm2835-codec bcm2835-codec: Device registered as /dev/video18
[ 21.245037] bcm2835-v4l2-0: V4L2 device registered as video0 - stills mode > 1280x720
[ 21.283466] bcm2835-v4l2-0: Broadcom 2835 MMAL video capture ver 0.0.2 loaded.
These lines appear even when I go through raspi-config
and uninstall video (options 3->P1->'No'
) which surprised me.
...and for completion the /etc/systemd/system/pikrellcam.sh file consists
[Unit]
Description=Pikrellcam
After=sshd.service network-online.target
[Service]
User=video
group=video
Type=simple
ExecStart=/home/pi/pikrellcam/pikrellcam
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartPreventExitStatus=255
RestartSec = 15
RuntimeDirectory=/home/pi/pikrellcam
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=pikrellcam.service
I think that is the correct setup for using pikrellcam under systemd, perhaps something is wrong here (as well). Maybe there should be a user/group specified as well?
What am I missing? Let me know if there are any other files of use and I will post them.