YvesG
Posts: 46
Joined: Wed Oct 03, 2012 6:54 pm

Re: MMAL Motion - tuning & optimisations

Sun Jun 22, 2014 3:39 pm

Hi dozencrows

Your optimizations are fantastic! i can enjoy full res in motion !!! thanks
Like few others, setting mmalcam_secondary_buffer_jpeg to something <> 0 result in a crash for me

Code: Select all

[1] [NTC] [ALL] [Jun 22 17:29:23] motion_init: Started motion-stream server in port 8081 auth Disabled
[0] [ERR] [ALL] [Jun 22 17:29:56] main: Thread 1 - Watchdog timeout, trying to do a graceful restart
[0] [NTC] [STR] [Jun 22 17:29:56] httpd_run: motion-httpd - Finishing
[0] [NTC] [STR] [Jun 22 17:29:56] httpd_run: motion-httpd Closing
[0] [NTC] [STR] [Jun 22 17:29:56] motion_web_control: motion-httpd thread exit
[0] [ERR] [ALL] [Jun 22 17:30:56] main: Thread 1 - Watchdog timeout, did NOT restart graceful,killing it!
[0] [NTC] [STR] [Jun 22 17:30:56] stream_stop: Closing motion-stream listen socket & active motion-stream sockets
[0] [NTC] [STR] [Jun 22 17:30:56] stream_stop: Closed motion-stream listen socket & active motion-stream sockets
[0] [ALR] [VID] [Jun 22 17:30:56] MMAL Camera cleanup
[0] [NTC] [ALL] [Jun 22 17:30:57] main: Motion thread 1 restart
[1] [NTC] [ALL] [Jun 22 17:30:57] motion_init: Thread 1 started , motion detection Enabled
[1] [ALR] [VID] [Jun 22 17:30:57] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 512 x 384 at 3 fps
[1] [ALR] [VID] [Jun 22 17:30:57] mmalcam_start: MMAL Camera using video capture
[1] [NTC] [VID] [Jun 22 17:30:57] MMAL camera component created
[1] [NTC] [ALL] [Jun 22 17:30:57] image_ring_resize: Resizing pre_capture buffer to 1 items
[1] [NTC] [STR] [Jun 22 17:30:57] http_bindsock: motion-stream testing : IPV4 addr: 0.0.0.0 port: 8081
[1] [NTC] [STR] [Jun 22 17:30:57] http_bindsock: motion-stream Bound : IPV4 addr: 0.0.0.0 port: 8081
[1] [NTC] [ALL] [Jun 22 17:30:57] motion_init: Started motion-stream server in port 8081 auth Disabled
[1] [NTC] [EVT] [Jun 22 17:31:00] event_newfile: File of type 2 saved to: /dd_extern/cam1/20140622/Snapshot/173100-snapshot.jpg
[1] [NTC] [EVT] [Jun 22 17:31:00] event_newfile: File of type 32 saved to: /dd_extern/cam1/20140622/Timelapse/20140622-timelapse.mpg
[0] [ERR] [ALL] [Jun 22 17:31:30] main: Thread 1 - Watchdog timeout, trying to do a graceful restart
Link to config : https://dl.dropboxusercontent.com/u/3670964/Pi/config
Motion seems to crash only if i set mmalcam_secondary_buffer_jpeg to something <> 0 AND i try to access to the web stream http://192.168.1.11:8081/

I really would like to see mmalcam_secondary_buffer_jpeg working and benefit of a jpeg compression from the beginning.
BTW, how do you disable motion compression if you use it at mmalcam_secondary_buffer_jpeg?
stream_quality 100?

Code: Select all

uname -a
Linux raspberrypi 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 armv6l GNU/Linux
gpu_mem=128
/opt/vc/bin/vcgencmd version
Jun 18 2014 18:43:44 
Copyright (c) 2012 Broadcom
version 1a6f79b82240693dcdb9347b33ab16f656b5f067 (clean) (release)
Best regards,
Yves

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Sun Jun 22, 2014 4:13 pm

Many thanks for the config file and all the info, Yves - I'll try this out when I get some time, but it won't be likely until next weekend.

What I can say is that you have picture output, movie output and web stream output all set to secondary buffer, and the secondary buffer scale is 5 x (512 by 384) - i.e. 2560 x 1920.

Even with the secondary buffer JPEG compression on the GPU, that's a lot of data for the web stream to send, which will heap a load of work on the CPU and the network connection.

And the ffmpeg movie encoding can't use the secondary buffer JPEG compression - that may be what is causing your crash, as it could be trying to encode an already JPEG encoded buffer into mpeg4. Try it with movie output off and see if that helps.

I wouldn't generally recommend the movie output anyway unless you're happy with low frame rates, as it runs on the CPU and is very expensive. My current working rig uses secondary buffer pre-encoded to JPEG only for saving pictures, outputs the lower resolution primary buffer to the web stream for checking framing and has movie encoding turned off. That allows me to get up to 15 fps at 1024 x 512 resolution for the captured motion images.

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: MMAL Motion - tuning & optimisations

Sun Jun 29, 2014 7:52 pm

This project is truely awesome! Thanks!

I was experimenting with the mmalcam_secondary_buffer very successfully until I did the last "sudo apt-get upgrade" on about 2/6/14. After that, motion-mmalcam would always fail unless mmalcam_secondary_buffer_jpeg is exactly 0.

Using a fresh and updated installation, I have just tried all the permutations of config settings that I can think of, and it always fails unless mmalcam_secondary_buffer_jpeg is exactly 0.

in /boot/config.txt, I have gpu_mem=128
uname -a gives "Linux test2 3.12.23+ #692 PREEMPT Thu Jun 26 20:15:50 BST 2014 armv6l GNU/Linux
I have not paid for the MPEG-2 license key on this Pi (although I assume jpg encoding doesn't need it).
Git clone of mmal-test done after 10/5/14, so latest version available.
Git pull of userland done today.
Successful make.

The motion log gets to...

[1] [NTC] [EVT] [Jun 29 19:32:51] event_newfile: File of type 2 saved to: /run/shm/lastsnap.jpg
[1] [DBG] [VID] [Jun 29 19:32:51] mmalcam_next: mmalcam_next - start
[1] [DBG] [VID] [Jun 29 19:32:51] mmal_output_process_buffer: Output mmalcam - got buffer
[1] [DBG] [VID] [Jun 29 19:32:51] mmal_output_process_buffer: cmd 0 flags 00000004 size 55296/55296 at 01aacc50
[1] [DBG] [VID] [Jun 29 19:32:51] mmal_output_process_buffer: Output mmalcam - new buffer returned
[0] [DBG] [VID] [Jun 29 19:32:51] buffer_callback: Output mmalcam: buffer_callback - entry
[0] [DBG] [VID] [Jun 29 19:32:51] buffer_callback: Output mmalcam: buffer_callback - exit

Then it waits 30 seconds and gives...

[0] [ERR] [ALL] [Jun 29 19:33:21] main: Thread 1 - Watchdog timeout, trying to do a graceful restart
[0] [NTC] [STR] [Jun 29 19:33:21] httpd_run: motion-httpd - Finishing
[0] [NTC] [STR] [Jun 29 19:33:21] httpd_run: motion-httpd Closing
[0] [NTC] [STR] [Jun 29 19:33:21] motion_web_control: motion-httpd thread exit

then it waits 60 seconds and gives...

[0] [ERR] [ALL] [Jun 29 19:34:21] main: Thread 1 - Watchdog timeout, did NOT restart graceful,killing it!
[0] [INF] [ALL] [Jun 29 19:34:21] motion_cleanup: Calling vid_close() from motion_cleanup
[0] [INF] [VID] [Jun 29 19:34:21] vid_close: calling video source cleanup
[0] [ALR] [VID] [Jun 29 19:34:21] MMAL Camera cleanup
[0] [DBG] [VID] [Jun 29 19:34:21] buffer_callback: Output secondary: buffer_callback - entry
[0] [DBG] [VID] [Jun 29 19:34:21] buffer_callback: Output secondary: buffer_callback - exit
[0] [NTC] [ALL] [Jun 29 19:34:22] main: Motion thread 1 restart

Then it does it all again.

Anything else I can try, or any more info needed?

Hope this helps and thanks again.

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Mon Jun 30, 2014 2:30 pm

That's very helpful, lowflyer. I have been able to replicate it with a fresh, fully updated install of Raspbian and building motion-mmal from git on the Pi itself.

It looks like the Pi camera code on the GPU stops sending secondary buffers after a few frames, then motion times out 30 seconds later while waiting for those buffers - and that triggers its internal "watchdog" to reset and start again, so you see the whole process go around and around until you force it to stop.

I'm looking into why the secondary buffers stop being sent now.

Mortenbirkelund
Posts: 10
Joined: Sun Jun 22, 2014 3:18 pm

Re: MMAL Motion - tuning & optimisations

Mon Jun 30, 2014 11:19 pm

dozencrows wrote:@tgwaste - with regard to the "unknown config option" errors - that's probably because you're not running the right motion executable for the config file. Do you also have the original motion package installed from the Raspbian repositories?
Hi Dozencrows

I have the same problem. I get the "unknown config option" error. How do i check if i have the wrong version of motion, and how do i fix if, in the case that i have the wrong version?

Thanks for all the great work you do

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Tue Jul 01, 2014 12:24 pm

If you have the original package installed, and run motion like this:

Code: Select all

motion
then it will run the original package binary - even if you have the MMAL binary in your current folder.

To run a MMAL binary that's in your current folder, you need to prefix it with ./ like this:

Code: Select all

./motion
If you add -h to the command line, you should see a help message with the version of the app in the first line. This should include the word "mmaltest" if it is the MMAL version of motion.

Mortenbirkelund
Posts: 10
Joined: Sun Jun 22, 2014 3:18 pm

Re: MMAL Motion - tuning & optimisations

Tue Jul 01, 2014 12:30 pm

Code: Select all

[email protected] ~ $ motion -h
motion Version mmaltest, Copyright 2000-2005 Jeroen Vreeken/Folkert van Heusden/                                           Kenneth Lavrsen

usage:  motion [options]


Possible options:

-n                      Run in non-daemon mode.
-s                      Run in setup mode.
-c config               Full path and filename of config file.
-d level                Log level (1-9) (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG,                                            ALL). default: 6 / NTC.
-k type                 Type of log (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL                                           ). default: ALL.
-p process_id_file      Full path and filename of process id file (pid file).
-l log file             Full path and filename of log file.
-m                      Disable motion detection at startup.
-h                      Show this screen.

Motion is configured using a config file only. If none is supplied,
it will read motion.conf from current directory, ~/.motion or /etc.

Everything looks fine.. I will try again and see if i can get it to work.

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Wed Jul 02, 2014 10:39 am

Yes, that's definitely the mmal version.

If your unknown config option errors relate to mmal options (e.g. secondary buffer), it is possible that you may be running an older binary that predates the secondary buffer - did you download it from the link earlier in this thread, or build it from source?

Mortenbirkelund
Posts: 10
Joined: Sun Jun 22, 2014 3:18 pm

Re: MMAL Motion - tuning & optimisations

Wed Jul 02, 2014 11:36 am

I downloaded and build everything according to this guide, but that was some time ago.
http://www.codeproject.com/Articles/665 ... nce-camera

How do i update the binary?

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Wed Jul 02, 2014 12:49 pm

If you're using the binary from that article, it predates the secondary buffer work.

Try the binary from here instead: https://www.dropbox.com/s/jw5r1wss32tdi ... opt.tar.gz.

Mortenbirkelund
Posts: 10
Joined: Sun Jun 22, 2014 3:18 pm

Re: MMAL Motion - tuning & optimisations

Wed Jul 02, 2014 1:24 pm

So basically i need to do the following to update motion mmal

Code: Select all

sudo apt-get update
sudo apt-get upgrade
cd /tmp
wget https://www.dropbox.com/s/jw5r1wss32tdibb/motion-mmal-opt.tar.gz
tar zxvf motion-mmal-opt.tar.gz
sudo mv motion /usr/bin/motion
And after that, I should edit /etc/motion.conf to add the new options. Is that the correct method for updating the binary?

Thanks in advance for your help.

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Wed Jul 02, 2014 2:46 pm

Yes, but don't do the apt-get update and upgrade first... it isn't required, and also there may be an issue with mmal motion and very recent Raspbian or Pi firmware where the secondary buffer jpeg encoding doesn't work (see previous posts in this thread). That's still under investigation.

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: MMAL Motion - tuning & optimisations

Wed Jul 02, 2014 4:14 pm

@dozencrows I did some searching to see if anybody else had recent problems with mmal and found http://www.raspberrypi.org/forums/viewt ... 43&t=80463

As 6by9 suggested, I rebuilt userland with

Code: Select all

static VCOS_LOG_LEVEL_T mmal_log_level = VCOS_LOG_TRACE;
This indeed spews out a lot of detail. Not sure how to interpret it though! Unedited (long and boring) log is here https://www.dropbox.com/s/e3qlk6tzb6dyrbi/motion.log

Anything I can do to help?

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Thu Jul 03, 2014 12:29 pm

Very many thanks for trying that out - it definitely is logging out extra info about the behaviour of the mmal code.

Unfortunately it is only logging out the setup and teardown parts - it's not logging anything when the camera is actually running, or when the problem occurs :(

However, looking at that thread, it would appear there may be some other mmal logging in the Raspbian logs under /var/log - if you can see if there's any info there, that would be a great help too.

There's also another logging control that would be great to try, from this post: http://www.raspberrypi.org/forums/viewt ... 76#p570276. That looks like it might log out buffer behaviour during actual camera operation.

BoehserWolf from that other thread has also spotted that this problem with motion is at least similar to his issue, and jamesh is going to see if he can get some time to check it out at his end as well. So hopefully all of us together can crack it!

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: MMAL Motion - tuning & optimisations

Thu Jul 03, 2014 1:45 pm

I couldn't see anything extra in /var/log - just various copies of the same stuff - and some complaints from syslog about too many entries.

However I did get some more with ENABLE_MMAL_EXTRA_LOGGING enabled in mmal_buffer.c and mmal_port.c

See https://www.dropbox.com/s/bvwauswqz433trs/motion_1.log

The last mmal log before motion notices the problem is

Code: Select all

mmal: mmal_port_buffer_header_callback: vc.ril.resize(3:0) port 0xbf8a80, buffer 0xbfa870 (0,0xc15ac0,0,55296)
Not sure if this helps, but here is a snippet from the end - where it failed

Code: Select all

[1] [DBG] [VID] mmalcam_next: mmalcam_next - start
[1] [DBG] [VID] mmal_output_process_buffer: Output mmalcam - got buffer
[1] [DBG] [VID] mmal_output_process_buffer: cmd 0 flags 00000004 size 55296/55296 at 00c15ac0
mmal: mmal_buffer_header_release: 0xbfa870 (0)
mmal: mmal_port_send_buffer: vc.ril.resize(3:0) port 0xbf8a80, buffer 0xbfa870 (0xc15ac0,0,0)
[1] [DBG] [VID] mmal_output_process_buffer: Output mmalcam - new buffer returned
mmal: mmal_port_buffer_header_callback: vc.ril.resize(3:0) port 0xbf8a80, buffer 0xbfa870 (0,0xc15ac0,0,55296)
[0] [DBG] [VID] buffer_callback: Output mmalcam: buffer_callback - entry
[0] [DBG] [VID] buffer_callback: Output mmalcam: buffer_callback - exit
[0] [ERR] [ALL] main: Thread 1 - Watchdog timeout, trying to do a graceful restart
[0] [NTC] [STR] httpd_run: motion-httpd - Finishing
and here is a very similar snippet from earlier where it (obviously) succeded

Code: Select all

[1] [DBG] [VID] mmalcam_next: mmalcam_next - start
[1] [DBG] [VID] mmal_output_process_buffer: Output mmalcam - got buffer
[1] [DBG] [VID] mmal_output_process_buffer: cmd 0 flags 00000004 size 55296/55296 at 00bfaa70
mmal: mmal_buffer_header_release: 0xbfa4c0 (0)
mmal: mmal_port_send_buffer: vc.ril.resize(3:0) port 0xbf8a80, buffer 0xbfa4c0 (0xbfaa70,0,0)
[1] [DBG] [VID] mmal_output_process_buffer: Output mmalcam - new buffer returned
mmal: mmal_port_buffer_header_callback: vc.ril.resize(3:0) port 0xbf8a80, buffer 0xbfa870 (0,0xc15ac0,0,55296)
[0] [DBG] [VID] buffer_callback: Output mmalcam: buffer_callback - entry
[0] [DBG] [VID] buffer_callback: Output mmalcam: buffer_callback - exit
mmal: mmal_port_buffer_header_callback: vc.ril.resize(3:0) port 0xbf8a80, buffer 0xbfa4c0 (0,0xbfaa70,0,55296)
[0] [DBG] [VID] buffer_callback: Output mmalcam: buffer_callback - entry
[0] [DBG] [VID] buffer_callback: Output mmalcam: buffer_callback - exit
mmal: mmal_port_buffer_header_callback: vc.ril.image_encode(3:0) port 0xc23ed0, buffer 0xc25908 (0,0xc25b00,0,81920)
[0] [DBG] [VID] buffer_callback: Output secondary: buffer_callback - entry
which might imply that it is the vc.ril.image_encode that has hung - somewhat comforting as that seems to be the jpeg encoder:

Code: Select all

mmal: mmal_port_alloc: vc.ril.image_encode:out:0: created at 0xc23ed0mmal: mmal_port_format_commit: vc.ril.image_encode(3:0) port 0xc23ed0 format 3:JPEG
mmal: mmal_port_parameter_set: vc.ril.image_encode(3:0) port 0xc23ed0, param 0xb4fb2a84 (10019,12)
mmal: mmal_port_enable: vc.ril.image_encode:out:0(JPEG) port 0xc23ed0, cb 0x1b594, buffers (1/1/1,81920/81920/81920)
I did this a few times with very similar results.

Hope this helps.

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Thu Jul 03, 2014 3:17 pm

Lots of thanks - that's very helpful! And I agree with your interpretation.

Please would you post a copy of the full log to Dropbox like you did before? There may be some further clues from studying the whole.

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: MMAL Motion - tuning & optimisations

Thu Jul 03, 2014 4:27 pm

Sorry - you are right, I killed motion rather early in https://www.dropbox.com/s/bvwauswqz433trs/motion_1.log above.

https://www.dropbox.com/s/07v34gqfsnsnx1c/motion_2.log has a few cycles of motion watchdog restarts. Good luck looking through all that!!

User avatar
jbeale
Posts: 3491
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: MMAL Motion - tuning & optimisations

Thu Jul 03, 2014 6:01 pm

I got the binary file from https://www.dropbox.com/s/jw5r1wss32tdi ... opt.tar.gz and using the config file at https://raw.githubusercontent.com/dozen ... alcam.conf as /etc/motion.conf I started the binary, but it seems to not be the right version because it doesn't recognize the new mmal options. There is no other version of 'motion' in my path.

Code: Select all

[email protected] ~/mmal $ which motion
[email protected] ~/mmal $ uname -a
Linux rpi10 3.12.19+ #682 PREEMPT Mon May 12 23:27:36 BST 2014 armv6l GNU/Linux

[email protected] ~/mmal $ ./motion &
[1] 740
[email protected] ~/mmal $ [-1242590368] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion.conf
[-1242590368] [ALR] [ALL] conf_cmdparse: Unknown config option "mmalcam_secondary_buffer_upscale"
[-1242590368] [ALR] [ALL] conf_cmdparse: Unknown config option "mmalcam_secondary_buffer_jpeg"
[-1242590368] [ALR] [ALL] conf_cmdparse: Unknown config option "output_secondary_pictures"
[-1242590368] [ALR] [ALL] conf_cmdparse: Unknown config option "ffmpeg_output_secondary_movies"
[-1242590368] [ALR] [ALL] conf_cmdparse: Unknown config option "extpipe_secondary"
[-1242590368] [ALR] [ALL] conf_cmdparse: Unknown config option "stream_secondary"
The prebuilt binary comes with a motion-mmalcam.conf file, which works without error, but it seems to be the "plain vanilla" mode of motion, because it does not include the new mmalcam options above, so it runs at only 2 fps, and saved images match the width/height (1024x576) values set in the config file, and include the onscreen text the same as the original version.

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Thu Jul 03, 2014 6:26 pm

jbeale wrote:... The prebuilt binary comes with a motion-mmalcam.conf file, which works without error, but it seems to be the "plain vanilla" mode of motion, because it does not include the new mmalcam options above...
That's weird - just downloaded from the same link, opened the tarball and looked in the config file, and I can see all the secondary buffer options present. Hmmm.

User avatar
jbeale
Posts: 3491
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: MMAL Motion - tuning & optimisations

Thu Jul 03, 2014 7:40 pm

I just tried it again and this time, I got a different motion-mmalcam.conf file! previous one was 28421 bytes and new one is 29905 bytes. The new file does contain the new parameters like "mmalcam_secondary_buffer_upscale" but unfortunately doesn't work for me, the log file mentions "Watchdog timeout" and "did NOT restart graceful, killing it!"
Note, my camera does work OK using raspistill v1.3.7

Code: Select all

[email protected] ~/mmal/motion-mmal $ ./motion -c motion-mmalcam.conf
[-1242373280] [NTC] [ALL] conf_load: Processing thread 0 - config file motion-mmalcam.conf
[-1242373280] [NTC] [ALL] motion_startup: Motion mmaltest Started
[-1242373280] [NTC] [ALL] motion_startup: Logging to file (/home/pi/motion.log)
^C
[email protected] ~ $ cat /home/pi/motion.log
[-1242373280] [NTC] [ALL] [Jul 03 12:35:14] motion_startup: Using log type (ALL) log level (NTC)
[-1242373280] [NTC] [ENC] [Jul 03 12:35:14] ffmpeg_init: ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785
[0] [NTC] [ALL] [Jul 03 12:35:14] main: Thread 1 is from motion-mmalcam.conf
[0] [NTC] [ALL] [Jul 03 12:35:14] main: Thread 1 is device: /dev/video0 input -1
[0] [NTC] [ALL] [Jul 03 12:35:14] main: Stream port 8081
[0] [NTC] [ALL] [Jul 03 12:35:14] main: Waiting for threads to finish, pid: 2123
[0] [NTC] [STR] [Jul 03 12:35:14] httpd_run: motion-httpd testing : IPV4 addr: 127.0.0.1 port: 8080
[0] [NTC] [STR] [Jul 03 12:35:14] httpd_run: motion-httpd Bound : IPV4 addr: 127.0.0.1 port: 8080
[0] [NTC] [STR] [Jul 03 12:35:14] httpd_run: motion-httpd/mmaltest running, accepting connections
[0] [NTC] [STR] [Jul 03 12:35:14] httpd_run: motion-httpd: waiting for data on 127.0.0.1 port TCP 8080
[1] [NTC] [ALL] [Jul 03 12:35:14] motion_init: Thread 1 started , motion detection Enabled
[1] [ALR] [VID] [Jul 03 12:35:14] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 256 x 144 at 15 fps
[1] [ALR] [VID] [Jul 03 12:35:14] mmalcam_start: MMAL Camera using video capture
[1] [NTC] [VID] [Jul 03 12:35:14] MMAL camera component created
[1] [NTC] [ALL] [Jul 03 12:35:14] image_ring_resize: Resizing pre_capture buffer to 1 items
[1] [NTC] [STR] [Jul 03 12:35:14] http_bindsock: motion-stream testing : IPV4 addr: 0.0.0.0 port: 8081
[1] [NTC] [STR] [Jul 03 12:35:14] http_bindsock: motion-stream Bound : IPV4 addr: 0.0.0.0 port: 8081
[1] [NTC] [ALL] [Jul 03 12:35:14] motion_init: Started motion-stream server in port 8081 auth Disabled
[0] [ERR] [ALL] [Jul 03 12:35:44] main: Thread 1 - Watchdog timeout, trying to do a graceful restart
[0] [NTC] [STR] [Jul 03 12:35:44] httpd_run: motion-httpd - Finishing
[0] [NTC] [STR] [Jul 03 12:35:44] httpd_run: motion-httpd Closing
[0] [NTC] [STR] [Jul 03 12:35:44] motion_web_control: motion-httpd thread exit
[0] [ERR] [ALL] [Jul 03 12:36:44] main: Thread 1 - Watchdog timeout, did NOT restart graceful,killing it!
[0] [NTC] [STR] [Jul 03 12:36:44] stream_stop: Closing motion-stream listen socket & active motion-stream sockets
[0] [NTC] [STR] [Jul 03 12:36:44] stream_stop: Closed motion-stream listen socket & active motion-stream sockets
[0] [ALR] [VID] [Jul 03 12:36:44] MMAL Camera cleanup
[0] [NTC] [ALL] [Jul 03 12:36:45] main: Motion thread 1 restart
[1] [NTC] [ALL] [Jul 03 12:36:45] motion_init: Thread 1 started , motion detection Enabled
[1] [ALR] [VID] [Jul 03 12:36:45] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 256 x 144 at 15 fps
[1] [ALR] [VID] [Jul 03 12:36:45] mmalcam_start: MMAL Camera using video capture
[1] [NTC] [VID] [Jul 03 12:36:45] MMAL camera component created
[1] [NTC] [ALL] [Jul 03 12:36:45] image_ring_resize: Resizing pre_capture buffer to 1 items
[1] [NTC] [STR] [Jul 03 12:36:45] http_bindsock: motion-stream testing : IPV4 addr: 0.0.0.0 port: 8081
[1] [NTC] [STR] [Jul 03 12:36:45] http_bindsock: motion-stream Bound : IPV4 addr: 0.0.0.0 port: 8081
[1] [NTC] [ALL] [Jul 03 12:36:45] motion_init: Started motion-stream server in port 8081 auth Disabled
[0] [ERR] [ALL] [Jul 03 12:37:15] main: Thread 1 - Watchdog timeout, trying to do a graceful restart
[0] [ERR] [ALL] [Jul 03 12:38:15] main: Thread 1 - Watchdog timeout, did NOT restart graceful,killing it!
[0] [NTC] [STR] [Jul 03 12:38:15] stream_stop: Closing motion-stream listen socket & active motion-stream sockets
[0] [NTC] [STR] [Jul 03 12:38:15] stream_stop: Closed motion-stream listen socket & active motion-stream sockets
[0] [ALR] [VID] [Jul 03 12:38:15] MMAL Camera cleanup
[0] [NTC] [ALL] [Jul 03 12:38:16] main: Threads finished
[0] [NTC] [ALL] [Jul 03 12:38:17] main: Motion terminating
[0] [NTC] [ALL] [Jul 03 12:38:17] motion_remove_pid: Closing logfile (/home/pi/motion.log).
EDIT: Aha! I have the same issue as several others reported here: http://www.raspberrypi.org/forums/viewt ... 25#p561020
I must set mmalcam_secondary_buffer_jpeg to 0, then it works (config file says 15 fps, I see about 10 fps with motion working on 256x144 but saving 1024x576 JPEG). I am using a R-Pi Model A (256 MB RAM total), is memory size an issue?

User avatar
jbeale
Posts: 3491
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: MMAL Motion - tuning & optimisations

Thu Jul 03, 2014 8:15 pm

By the way, I see that "mmalcam_secondary_buffer_upscale 8" also works; it saves 2048x1152 JPEG files but only at 2 or 3 fps (although the motion detection working on the smaller image runs faster, so I guess it will still have good latency). In any event, this is an impressive improvement from what we had before.

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: MMAL Motion - tuning & optimisations

Tue Jul 08, 2014 4:32 pm

This is interesting (at least I thought so - sad, or what??)!

I started from a fresh installation of 2014-01-07-wheezy-raspbian, copied over the mmal-motion folder and the userland folder, then did

Code: Select all

sudo apt-get update
and installed the packages that motion needs, without doing

Code: Select all

sudo apt-get upgrade
Then I went through https://github.com/Hexxeh/rpi-firmware/ ... ter?page=1 and found the first firmware update where mmal fails and....

Code: Select all

sudo rpi-update 1df38213888faccd4040deec6e88563beedbff2e
works fine, but

Code: Select all

sudo rpi-update f0eeb5b9431a87906ee77bc70a5baa9203c361e2
fails. That update was done on 7th April and addressed the following issues
firmware: image_encode: Fix that works for both buffers and tunnelling.

See: http://forum.xbmc.org/showthread.php?ti ... pid1673527

firmware: video_decode: Allow ts fifo to be forced off with avoid_fix_ts=2
See: http://forum.xbmc.org/showthread.php?ti ... pid1674875

userland: tvservice: Enhance callback mechanism
See: raspberrypi/userland#162
I guess we really are in Dom's very capable hands!

Again, hope this helps!

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Tue Jul 08, 2014 6:51 pm

That's really great detective work - thank you for following up on it! And it is interesting... :)

User avatar
jbeale
Posts: 3491
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: MMAL Motion - tuning & optimisations

Wed Jul 09, 2014 2:14 pm

lowflyer wrote:I guess we really are in Dom's very capable hands!
I'm not sure if Dom reads *every* thread on the forum; is he aware of this issue?

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: MMAL Motion - tuning & optimisations

Wed Jul 09, 2014 3:30 pm

The Foundation/Broadcom guys relevant to this are aware - I've got another thread going with their input.

Likely next steps are to make a simpler test case to reproduce this so they can debug it, and also give them the option to look at the motion app itself if that's required.

Return to “Camera board”