DietPiCam Jessie : Motion.php broken.

Having issues with your DietPi installation, or, found a bug? Post it here.
Rich.T.
Posts: 14
Joined: Mon Nov 16, 2015 3:02 am

DietPiCam Jessie : Motion.php broken.

Post by Rich.T. »

I tried out DietPiCam on DietPi ages ago and couldn't get it to work, so I gave up on it for a while and just got around to testing it again.

After installing again, I found that I was getting the same problem as before; namely that I was able to see the webpage (http://dietpi/dietpicam), but was not getting any camera feed or preview.

I tested the camera by using the raspivid command and found it working OK, so I then went back to the RPi-Cam-Web-Interface documentation and found the following under Troubleshooting:
Web interface starts up but just shows 'Loading'. There are a number of causes for this but most are caused by the core raspimjpeg process not running or not running correctly.
I then entered the command raspimjpeg into the command line and voilà! The camera immediately lit up and the preview appeared in the webpage.

Were you aware that DietPiCam was not automatically starting raspimjpeg?
Can this be fixed?

My suggestion would be to start raspberrymjpeg as a service ie. create an init conf file.

Also, I see that you forked this from silvanmelchior's project quite a while ago and I have noticed that there has been quite a lot of development going on over there. Might it be time to have another look and bring this version more up-to-date?

Thanks for all the hard work,
Rich
:)
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: DietPiCam Issues

Post by Fourdee »

Rich.T. wrote:Were you aware that DietPiCam was not automatically starting raspimjpeg?
Can this be fixed?

My suggestion would be to start raspberrymjpeg as a service ie. create an init conf file.

Also, I see that you forked this from silvanmelchior's project quite a while ago and I have noticed that there has been quite a lot of development going on over there. Might it be time to have another look and bring this version more up-to-date?

Thanks for all the hard work,
Rich
:)
Hi Rich,

Thanks for the report.

Strange, DietPi should run the init for raspberrymjpeg during boot. It must be failing to start, I'll look into this when I can and get back to you.

What RPi version and Distro are you running?

Also, could you send a DietPi bug report so I can check your settings please:

Code: Select all

dietpi-bugreport
No need to fill the text out, just need the Reference CODE:.

Heres the current script that runs raspberrymjpeg during boot:
https://github.com/Fourdee/DietPi/blob/ ... mjpeg_init
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Rich.T.
Posts: 14
Joined: Mon Nov 16, 2015 3:02 am

Re: DietPiCam Issues

Post by Rich.T. »

Bug report sent :)

Reference Code: 74da383582db-0
Rich.T.
Posts: 14
Joined: Mon Nov 16, 2015 3:02 am

Re: DietPiCam Issues

Post by Rich.T. »

When I run

Code: Select all

/etc/raspimjpeg_init start
(or restart) I get the following output:
This account is currently not available.
This account is currently not available.

When I run the following commands, I get the same result:

Code: Select all

su -c 'raspimjpeg > /dev/null &' www-data
This account is currently not available.

Code: Select all

su -c 'php /var/www/dietpicam/schedule.php > /dev/null &' www-data
This account is currently not available.
Running raspimjpeg as root gives me:

Code: Select all

~# raspimjpeg
start monitoring for pid: 26306
{2015/11/23 01:10:18} start monitoring for pid: 26306
RaspiMJPEG Version 5.2.10
recommended video buffers 1
h264 buffers set to recommended 1
MJPEG streaming, ready to receive commands
send smd 9
And it works.

Does raspimjpeg require root privileges to run, or something?
User www-data does not and indeed should not have root privilages, for security reasons.

Just a guess...
Fourdee wrote:What RPi version and Distro are you running?
Raspbian Jessie on a Pi 2, though I was getting the same on my model B under Jessie, too.
It was a while ago now, so I'm not sure, but I may have been experiencing the same issue under Wheezy, a few months ago.
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: DietPiCam Issues

Post by Fourdee »

Thanks Rich,

I've created a Git ticket: https://github.com/Fourdee/DietPi/issues/119.

They all get ran as www-data. And yes, giving www-data root permissions is just asking for trouble.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: DietPiCam Issues

Post by Fourdee »

Resolved for V102.

I've updated the init code to use sudo -u instead of su -c. Thanks for your help with debugging on this, saved me alot of time :)

You can manually patch your system now if you like:

Code: Select all

nano /etc/raspimjpeg_init
Replace the su -c lines with the following:

Code: Select all

	Raspimjeg_Start(){
		mkdir -p /dev/shm/mjpeg
		chown www-data:www-data /dev/shm/mjpeg
		chmod 777 /dev/shm/mjpeg

		sleep 1
		sudo -u www-data raspimjpeg > /dev/null &

		sleep 1
		sudo -u www-data php /var/www/dietpicam/schedule.php > /dev/null &
	}
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Rich.T.
Posts: 14
Joined: Mon Nov 16, 2015 3:02 am

Re: DietPiCam Issues

Post by Rich.T. »

Fourdee wrote:Thanks Rich,

I've created a Git ticket: https://github.com/Fourdee/DietPi/issues/119.

They all get ran as www-data. And yes, giving www-data root permissions is just asking for trouble.
Thanks, Dan. :D
I responded on the bug report page in more detail.
Rich.
Rich.T.
Posts: 14
Joined: Mon Nov 16, 2015 3:02 am

Re: DietPiCam Issues

Post by Rich.T. »

Fourdee wrote:Resolved for V102.

I've updated the init code to use sudo -u instead of su -c. Thanks for your help with debugging on this, saved me alot of time :)

You can manually patch your system now if you like:

Code: Select all

nano /etc/raspimjpeg_init
Replace the su -c lines with the following:

Code: Select all

	Raspimjeg_Start(){
		mkdir -p /dev/shm/mjpeg
		chown www-data:www-data /dev/shm/mjpeg
		chmod 777 /dev/shm/mjpeg

		sleep 1
		sudo -u www-data raspimjpeg > /dev/null &

		sleep 1
		sudo -u www-data php /var/www/dietpicam/schedule.php > /dev/null &
	}
Yep. Works a treat!
I had to install sudo, though. ;)
Rich.T.
Posts: 14
Joined: Mon Nov 16, 2015 3:02 am

Re: DietPiCam Issues

Post by Rich.T. »

Now that's fixed for me, I'm having some trouble getting motion detection working on the damn thing. :(
Motion detection starts up, it shows up in the log file and the motion service is listed as running on the system, but the weird thing is that motion.php page is utterly blank and no recording is being triggered.
I'm really just stumbling around in the dark here. I've been working my way through http://elinux.org/RPi-Cam-Web-Interface but it's quite dense reading and doesn't really have a quickstart section, explaining the basics.
i'd have a proper go at reading the forum thread at https://www.raspberrypi.org/forums/view ... 43&t=63276 but it's 121 pages long!

Does anyone have a Pi set up with dietpicam up and running properly?
Dan, do you have a test rig set up with a camera to test this functionality?

I'm not sure whether it's just me being dense and missing something simple in the setup, or that there may be some more bugs in this which need sorting out.
I haven't really seen a great deal of discussion about dietpicam, so some more input might be useful. It's just so straightforward to install, compared with the upstream RPi-Cam-Web-Interface project. I still haven't managed to get that one installed without major aggravation; my last two attempts failed miserably due to webserver problems.

Thanks,
Rich
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: DietPiCam Issues

Post by Fourdee »

Rich.T. wrote:Does anyone have a Pi set up with dietpicam up and running properly?
Dan, do you have a test rig set up with a camera to test this functionality?

I'm not sure whether it's just me being dense and missing something simple in the setup, or that there may be some more bugs in this which need sorting out.
Its been a while since i last tested motion detection. I'll take a look at the guide you linked and run through it, then get back to you with results.

Git ticket: https://github.com/Fourdee/DietPi/issues/120
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Post Reply