Picam with Motion Only Minimal Fresh Install and NLoad Stream BW

25/9/17 - bought an old Pi B in error; my other images only work for diff size SD cards if USB Img Writer is used - not DD, and then boot partition boot flag set with Gparted/cfdisk.

I also tried latest DL'd 2GB min Stretch img - did my setup below - didn't work due to new Motion version conf file - not backwards compatible with the steps below! Also there is the prob:

* failed to open vchiq instance

fixed via:

sudo chmod 777 /dev/vchiq

raspivid -o /Share/motion/test.h264

video flashed up on HDMI TV with no Dtop X server. The current working conf for 2017 Motion

here (incompatible with older Motion confs):


Pi with HDMI TV small fonts:

sudo dpkg-reconfigure console-setup
choose; let system decide/larger font size

Update 17/2/17! Getting this error that does not stop Motion camera live stream OR recording working, but must be an rpi-update bug - common on forums too:

stevee@pi ~ $ sudo raspivid -o test.h264
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

When dd used with 2015-05-05-raspbian-wheezy.img for SD cards of diff sizes than the original image clone it may need to be expanded, fschecked and boot flagged in Gparted before it will boot in a new Pi!

try dd progress monitoring with pv.

sudo apt install pv

stevee@AMDA8 ~ $ sudo dd if=2015-05-05-raspbian-wheezy.img | pv | of=/dev/mmcblk0


I had to re-install PiNoir camera recently after non start/bad behaviour/corruption/update issues, so decided to keep it lean as possible, for camera use only, with a minimal install, and eventually remove other unwanted default Apps/services like SonicPi etc, then save it's working image once done as a future easy reload in the event of failure.

If you only want to use a Pi with Motion and a few other tools, as a surveillance cam only, that works with a Pi Noir camera (not that there should be any difference for Noir or regular cam, but some forums seem to indicate thus, with all sorts of reasons; from driver/kernel updates to loose ribbon leads for the same fault I got below), for the kernel version:

uname -a

Linux pinoir 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux

available now, 4/9/2015 from:


then the minimal steps I took to get the Noir working with Motion, are listed below - just what needs doing overall.

A fresh Pi img install with ssh and Picam set on:

in the raspi-conf screen, then find the IP address from your router DHCP table:

9 B8-27-EB-54-E3-42 23:52:54 raspberrypi


and all below works with a Pi camera, and shows vids in Chrome in Mint AND Windows now it seems (just found it working in Win8 + Chrome 6/9/15).

Do all these as root so you can paste them in order..(saves me writing sudo!) (

After initial raspi-config setup; pi user login:

sudo su 

passwd root
adduser stevee
adduser stevee sudo
passwd stevee
smbpasswd -a stevee (samba net user/share access/passwd)
apt-get install winbind libnss-winbind nbtscan (use PC names on net instead of IP no. Add "wins" to /etc/nsswitch.conf)
apt-get install motion
adduser stevee motion (user added to motion group)
vi /etc/motion/motion.conf (daemon on; for boot start and other settings - see working conf below)
vi /etc/default/motion (start_motion_daemon=yes)
update-rc.d motion enable (runlevel 2 boot start)
motion (manual check for motion start - pid creation fault)
mkdir /var/run/motion (create required pid folder)
touch /var/run/motion/motion.pid (create blank pid file)
chgrp motion -R /var/run/motion (allow motion access to write to pid dir/file)
motion (manual check for motion start ok)
apt-get install samba smbclient cifs-utils (net access from any PC)
apt-get install vim (useable text editor)
vi /etc/samba/smb.conf (set homes section for shares and access perms; add [Share] section):
path = /Share
writable = 1
browsable = 1
mkdir /Share/ (folder for net access and motion vids)
mkdir /Share/motion (folder for motion vid creation set in motion.conf)
chown stevee.motion /Share/ -R (main net access user/owner and group)
chmod 775 -R /Share/ (allows access to user stevee and his group, traversal for others)
service samba restart (get changes read)
echo "bcm2835-v4l2" >> /etc/modules
modprobe bcm2835-v4l2 (live driver addition for tests)
lsmod | grep bcm2835 (check driver is loaded)
raspivid -o /Share/motion/test.h264 (test video writes to share folders)
omxplayer /Share/motion/test.h264 (test video created works)
apt-get install nmap (check motion mini webserver runs on default 8081)
nmap (8081/tcp open blackice)
service motion restart (run with cam driver)
ls -al /Share/motion/ (check perms of vids dir)
chgrp motion /usr/bin/motion (allow motion access to start binary for boot start)
chown motion -R /Share/motion/ (allow motion write access to vid file and stevee owner to view/delete remotely)
ls -al /Share/motion/ (check perms are for motion of vids dir)
vi /boot/config.txt
Drag a working version of motion.conf from your working Pis to the /Share/motion dir of this new Pi, then replace default /etc/motion/motion.conf with it:
sudo cp -v /Share/motion/motion.conf /etc/motion/
reboot (check LED light on restart = motion running)

If it all works from this original Pi install card - fine. If not, update firmware with:

sudo rpi-update

Then reboot and check again. With the motion.conf setup, you should see the webpage at pi:8081

The last chgrp/chown steps are easily forgotten - motion needs access to the binary at boot and the vid store space, which is root's initially, so can't boot or write unless you add group access, change ownership, or chmod 775. The LED should be permanently on after bootup, not flashing (= problem!).

If motion can't write it's files - even if it runs from boot - as soon as motion is detected, the LED turns off.

Then you get this:

Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] Error opening file ./01-20150905082558-21.jpg with mode w: Permission denied
[1] Can't write picture to file ./01-20150905082558-21.jpg - check access rights to target directory: Permission denied
[1] Thread is going to finish due to this fatal error: Permission denied
[1] Thread exiting
[1] Calling vid_close() from motion_cleanup
[1] Closing video device /dev/video0

Once you have things working the way you want, I suggest you image the SDRAM card using dd, (over the network is easier if you don't want to take your cam offline - see the later dd and netcat Post) so you can just reinstall back to any card or Pi in future e.g. by shutting down, removing it to another linbox, finding it's /dev ID, then imaging:

fdisk -l 

dd if=/dev/sdg of=/Pinoir.img
15523840+0 records in
15523840+0 records out
7948206080 bytes (7.9 GB) copied, 433.922 s, 18.3 MB/s

For GUI folk, right click the image and use:

or Bootable USB Writer:

Set the time for the cameras in:


I also use this name format for easier file time ID:

movie_filename %v-%Hhr%Mmins_%Ssecs_%d_%m_%Y

This gives a name of file time creation for playback in Videos, like:


To see all the settings without comments - which beginners could paste into a blank motion.conf file just to get going with the same settings I use:

stevee@pirear ~ $ grep -Ev '^#|^;|^$' /etc/motion/motion.conf

-v, --invert-match
Invert the sense of matching, to select non-matching lines.

You can see how it works by line inversion of those commented by # and ;
daemon on
process_id_file /var/run/motion/motion.pid
setup_mode off
videodevice /dev/video0
v4l2_palette 8
/ The video input to be used (default: 8)
input 8
norm 0
frequency 0
rotate 0
width 960
height 720
framerate 100
minimum_frame_time 0
auto_brightness off
brightness 0
contrast 0
saturation 0
hue 0
threshold 10000
threshold_tune off
noise_level 32
noise_tune on
despeckle EedDl
area_detect 12345679
smart_mask_speed 0
lightswitch 0
minimum_motion_frames 5
pre_capture 0
post_capture 10
gap 60
max_mpeg_time 0
output_all off
area_detect 12345679
output_normal first
output_motion off
quality 75
ppm off
ffmpeg_cap_new on
ffmpeg_cap_motion off
ffmpeg_timelapse 0
ffmpeg_timelapse_mode daily
ffmpeg_bps 500000
ffmpeg_variable_bitrate 0
ffmpeg_video_codec mpeg4
ffmpeg_deinterlace off
snapshot_interval 0
locate off
text_right %Y-%m-%d\n%T-%q
text_left GATE
text_changes off
text_event %Y%m%d%H%M%S
text_double on
target_dir /Share/motion
movie_filename %v-%Hhr%Mmins_%Ssecs_%d_%m_%Y
timelapse_filename %Y%m%d-timelapse
webcam_port 8081
webcam_quality 50
webcam_motion on
webcam_maxrate 5
webcam_localhost off
webcam_limit 0
control_port 8080
control_localhost off
control_html_output on
track_type 0
track_auto off
track_motorx 0
track_motory 0
track_maxx 0
track_maxy 0
track_iomojo_id 0
track_step_angle_x 10
track_step_angle_y 10
track_move_wait 10
track_speed 255
track_stepsize 40
quiet on
on_movie_end rm -vr /Share/motion/*jpg --i=no
on_camera_lost reboot

If you want to quickly mount the Pi's shares on the desktop:

nemo smb://pinoir/Share

Streaming NOW works in Chrome in Linux AND Windows.


It was interesting to see, just before sunrise, some PiNoir footage in B&W due to it's infra red capability. There's some experimentation to be done with that yet - plants and night critters etc.


Piblanc ( is net attached by a Powerline connector across the mains, but PiNoir has a 100Mb connection to the router, so I wanted to get an idea how poor the net connection is compared to PiNoir ( using nload, and was surprised how similar the average figures are when each is streaming to Chrome:

apt-get install nload


However, the powerline link does drop to 0 bits at times as seen by the minimum.

If you want to use sendemail as your motion event messenger to gmail, install it and update the perl SSH modules following that Post:



Comments are closed.

Post Navigation