5

I'm having problems with Motion's live stream going grey and saying unable to open video device.

I can get my live stream working by rebooting my PI and, following a reboot, entering the command sudo modprobe bcm2835-v4l2 (only with the command removed from the RC.local file).

But when I try and place it in the RC.local file to load the driver at boot, it doesn't work.

How can I make it work from boot?

This is where I've put the command in my RC.local file

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#      
# By default this script does nothing.      

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

sudo modprobe bcm2835-v4l2


exit 0
Dennis Williamson
  • 1,689
  • 3
  • 13
  • 11
reggie
  • 1,121
  • 4
  • 14
  • 30

3 Answers3

4

I seem to have got it working by placing sudo modprobe bcm2835-v4l2 in the start section of /etc/init.d/motion and commenting out #export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so

see the below code:

  start)
    if check_daemon_enabled ; then
        if ! [ -d /var/run/motion ]; then
                mkdir /var/run/motion
        fi
        chown motion:motion /var/run/motion

        #export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so
        sudo modprobe bcm2835-v4l2

        chmod 777 /var/run/motion
        # this is the fix we've added to allow the network share to be connected first before we try to start motion:#

        sleep 30

        log_daemon_msg "Starting $DESC" "$NAME" 
        if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then
            log_end_msg 0
         else
            log_end_msg 1
            RET=1
        fi
    fi
    ;;
reggie
  • 1,121
  • 4
  • 14
  • 30
3

I tried the answer mentioned and it didn't quite work for me. I did find that appending

# load camera driver
bcm2835-v4l2

to /etc/modules worked like a charm. Obviously the commented out part is not necessary, but I always like having context when I need to go over something again.

NetApex
  • 31
  • 3
1

If the camera worked fine previously but then suddenly stopped working and shows a gray screen (e.g. in motion) then one possible reason might be that you used raspi-config and under Advanced Options > Memory Split have set a value lower than 128MB.

ccpizza
  • 431
  • 3
  • 8