3

I have set up my Raspberry Pi 3 model B v2 and the Raspberry Pi camera module 2.1.

The camera works, I can take pictures with raspistill and access them via SSH. Querying the camera properties with v4l2-ctl -d /dev/video0 --all works.

I installed and configured motion to not only work on localhost. After starting motion, shutdown and power-cycled, I can neither access the website with the video on port 8081 nor the config website on port 8080.

When starting or restarting the service, I get the following in the motion log:


[0:motion] [NTC] [ALL] [Feb 26 20:18:28] motion_startup: Motion 4.3.2 Started
[0:motion] [NTC] [ALL] [Feb 26 20:18:28] motion_startup: Using default log type (ALL)
[0:motion] [NTC] [ALL] [Feb 26 20:18:28] motion_startup: Using log type (ALL) log level (NTC)
[0:motion] [NTC] [ALL] [Feb 26 20:18:28] become_daemon: Motion going to daemon mode
[0:motion] [NTC] [ALL] [Feb 26 20:18:28] motion_startup: Motion running as daemon process
[0:motion] [NTC] [STR] [Feb 26 20:18:28] webu_start_strm: Starting all camera streams on port 8081
[0:motion] [NTC] [STR] [Feb 26 20:18:28] webu_strm_ntc: Started camera 0 stream on port 8081
[0:motion] [NTC] [STR] [Feb 26 20:18:28] webu_start_ctrl: Starting webcontrol on port 8080
[0:motion] [NTC] [STR] [Feb 26 20:18:28] webu_start_ctrl: Started webcontrol on port 8080
[0:motion] [NTC] [ENC] [Feb 26 20:18:28] ffmpeg_global_init: ffmpeg libavcodec version 58.91.100 libavformat version 58.45.100
[0:motion] [NTC] [ALL] [Feb 26 20:18:28] translate_init: Language: English
[0:motion] [NTC] [ALL] [Feb 26 20:18:28] motion_start_thread: Camera ID: 0 is from /etc/motion/motion.conf
[0:motion] [NTC] [ALL] [Feb 26 20:18:28] motion_start_thread: Camera ID: 0 Camera Name: (null) Device: /dev/video0
[0:motion] [NTC] [ALL] [Feb 26 20:18:28] main: Waiting for threads to finish, pid: 3107
[1:ml1] [NTC] [ALL] [Feb 26 20:18:28] motion_init: Camera 0 started: motion detection Enabled
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] vid_start: Opening V4L2 device
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_device_open: Using videodevice /dev/video0 and input -1
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_device_capability: - VIDEO_CAPTURE
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_device_capability: - VIDEO_OVERLAY
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_device_capability: - READWRITE
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_device_capability: - STREAMING
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_input_select: Name = "Camera 0"- CAMERA
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_norm_select: Device does not support specifying PAL/NTSC norm
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_pixfmt_set: Testing palette YU12 (640x480)
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_pixfmt_set: Using palette YU12 (640x480)
[1:ml1] [NTC] [ALL] [Feb 26 20:18:28] image_ring_resize: Resizing pre_capture buffer to 1 items
[1:ml1] [NTC] [ALL] [Feb 26 20:18:28] image_ring_resize: Resizing pre_capture buffer to 4 items
[1:ml1] [NTC] [ALL] [Feb 26 20:18:28] mlp_actions: End of event 1
[1:ml1] [NTC] [ALL] [Feb 26 20:18:28] motion_loop: Thread exiting
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] vid_close: Cleaning up V4L2 device
[1:ml1] [NTC] [VID] [Feb 26 20:18:28] v4l2_cleanup: Closing video device /dev/video0
[0:motion] [NTC] [ALL] [Feb 26 20:18:29] main: Threads finished
[0:motion] [NTC] [ALL] [Feb 26 20:18:29] main: Motion terminating
[0:motion] [NTC] [ALL] [Feb 26 20:18:29] motion_remove_pid: Closing logfile (/home/motion/log/motion.log).

As you can see, it started in daemon mode and started streaming. But from the last lines, it exits and closes the camera. After that, the motion service is no longer running and consequently the website is unreachable.

$ ps -ef | grep motion
pi        3360  1210  0 20:22 pts/0    00:00:00 grep --color=auto motion

What's wrong here and what do I need to do in order to watch the video stream in the browser?

Questions that I have already reviewed:

If I run motion directly with sudo motion, it works. Using sudo service motion start, it doesn't.

2

1 Answer 1

2

Found this: The systemd service file, with Type=simple, expects motion to run in non-daemon mode, and not fork. If daemon on is set in motion.conf, the service will fail to run.

1
  • Thanks to MatsK and Wouter. Your answers are the only reference to setting 'daemon=off' to get motion to run under systemd. Kudos. No one else ever mentioned this in all the answers I have read. Again I was foiled by tribal knowledge that should have been added to motion.conf a long time ago.
    – Ed Tyler
    Jan 1 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.