5

What is Motion?: Motion is a deamon application which allows Linux users to record pictures of webcams and ipcams based on motion detection or time settings. A Tutorial how to set up the stable release can be found here. Here is the Motion developer website and documentation

My Setup: I'm using a cheap Hikvision 2032 IP-camera, which is set to IP 192.168.1.199. Its mainstream (H264) is:

rtsp://192.168.1.199:554/ISAPI/streaming/channels/101?auth=YWRtaW46MTIzNDU=

(It is working fine in VLC)

As I've been told Motion unfortunately doesn't supports H264 in its current stable release (3.2.12). But the latest developers build has some integration and that there is a fork which is optimized for it.

The installation of the builds is highly complicated though and I try to collect the tips I get in step-by-step instructions in my posting below:

Edit: At this stage I've downloaded the Git Version MrDave recommended me below and I think I have all dependencies. After following the steps in my collected instructions it finally works at 1080x720 resolution.

I have the problem to save files to my images folder when using 1920x1080:

nuc@nuc:/usr/local/etc$ motion
[0] [NTC] [ALL] conf_load: Processing thread 0 - config file /usr/local/etc/motion.conf
[0] [ALR] [ALL] conf_cmdparse: Unknown config option "sdl_threadnr"
[0] [NTC] [ALL] motion_startup: Motion trunkREVUNKNOWN Started
[0] [NTC] [ALL] motion_startup: Logging to syslog
[0] [NTC] [ALL] motion_startup: Using log type (ALL) log level (NTC)
[0] [NTC] [ENC] ffmpeg_init: ffmpeg LIBAVCODEC_BUILD 3562596 LIBAVFORMAT_BUILD 3555176
[0] [NTC] [ALL] main: Thread 1 is from /usr/local/etc/motion.conf
[0] [NTC] [ALL] main: Thread 1 is device: rtsp://192.168.1.199:554/ISAPI/streaming/channels/101?auth=YWRtaW46MTIzNDU= input -1
[0] [NTC] [ALL] main: Stream port 8081
[0] [NTC] [ALL] main: Waiting for threads to finish, pid: 9028
[1] [NTC] [ALL] motion_init: Thread 1 started , motion detection Enabled
[1] [ALR] [NET] netcam_start: Network Camera thread starting... for url (rtsp://192.168.1.199:554/ISAPI/streaming/channels/101?auth=YWRtaW46MTIzNDU=)
[0] [NTC] [STR] httpd_run: motion-httpd testing : IPV4 addr: 127.0.0.1 port: 8080
[0] [NTC] [STR] httpd_run: motion-httpd Bound : IPV4 addr: 127.0.0.1 port: 8080
[0] [NTC] [STR] httpd_run: motion-httpd/trunkREVUNKNOWN running, accepting connections
[0] [NTC] [STR] httpd_run: motion-httpd: waiting for data on 127.0.0.1 port TCP 8080
[1] [NTC] [NET] netcam_rtsp_open_context: Using tcp transport
[1] [NTC] [NET] netcam_connect_rtsp: Camera connected
[1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
[1] [ALR] [NET] netcam_handler_loop: Camera handler thread [2] started
[1] [NTC] [STR] http_bindsock: motion-stream testing : IPV4 addr: 127.0.0.1 port: 8081
[1] [NTC] [STR] http_bindsock: motion-stream Bound : IPV4 addr: 127.0.0.1 port: 8081
[1] [NTC] [ALL] motion_init: Started motion-stream server in port 8081 auth Disabled
Memoryaccesserror (core image written).

The avi and jpg in full resolution are empty or not availabe if I try to open.

  • Can you edit your question to clarify what "motion" is? I'm assuming it is some software, but I'm not sure. – Seth Aug 23 '14 at 22:27
4

In order to get the rtsp and H264 support, you will need to build the application from source. The primary version of the source is at https://github.com/sackmotion. There are however many forks of this source the implement various features including RTSP/H264. If you review the graphs / network tabs in git you can see these versions and determine which is best for your situation. If you are not familiar with building from source, basic instructions for compiling and building motion can be found in the following fork https://github.com/Mr-Dave/motion in the INSTALL file. Those instructions have been validated with 12.04 but may require slight modifications for use with 14.04.

Note that for the camera you have referenced, the command line that you reference may not be correct. The formats that I have observed for this camera are rtsp://user:pwd@ipaddress:554/streaming/channels/1 (for the primary stream) or rtsp://user:pwd@ipaddress:554/streaming/channels/2 for the secondary stream. Prior to setting up the camera in motion, you should validate the connection string with VLC or avplay. Once it is confirmed to work in either of those applications, you can copy the connect string directly over into the motion.conf file as the netcam url.

Finally, if you want to save CPU resources for this camera, it's better to have motion set up to monitor the smaller SD secondary stream and use the configuration options to trigger an external recording application to record the main HD stream in the native format when motion occurs.

| improve this answer | |
  • I don't see any forks to download, maybe I have to sign in? Doesnt the latest build of motion include it? I'm indeed unfamiliar with building from source. --- I don't see anything with your stated stream. I will receive video in VLC if I enter "rtsp://192.168.1.199:554/ISAPI/streaming/channels/101?auth=YWRtaW46MTIzNDU=". --- Which external application would this be? – empedokles Aug 27 '14 at 8:01
  • nuc@nuc:~$ git clone {https://github.com/Ken-M/motion} Klone nach 'motion}'... fatal: I don't handle protocol '{https' nuc@nuc:~$ – empedokles Aug 27 '14 at 8:16
  • As I recall, the daily build you downloaded should generally work but does have a few issues with memory leaks that would be resolved with the version from git. Regarding the git statement above, enter it just as git clone – MrDave Aug 27 '14 at 23:21
  • github.com/ken-m/motion without the {}. Next, you will need to install FFMPEG or LIBAV. The easiest way to do this is via apt as specified within the INSTALL file. The lack of these libraries being installed is what the configure messages are indicating. – MrDave Aug 27 '14 at 23:33
  • I tried to collect your informations in a step-to-step guide for Ubuntu 14.04. This is also the current point where I hang as it stands. When I try to configure motion I don't get ffmpeg support. I posted the whole terminaloutput of this stage in my original question above. – empedokles Aug 28 '14 at 10:02
3

I summarize MrDaves instruction for Ubuntu 14.04 and 15.04 in a step by step guide:

Motion needs many libraries which need to be installed before we can install Motion.:

Firstly, we have to install the required packages for Motion:

sudo apt-get install autoconf automake build-essential libtool libjpeg8-dev libzip-dev

Secondly, we have to install the LIBAV libraries:

sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools libswscale-dev

Important: This optional third step is only needed if you haven't installed LIBAV libraries (the seconds step): Then we have to install FFMPEG libraries from source:

Goto https://www.ffmpeg.org/download.html and get the latest source for Ubuntu (via Git):

sudo apt-get install git
cd ~
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

And build it from source (I haven't found any easy instructions).

Easier alternative for step 3: As written here one can use apt-get:

sudo add-apt-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg
sudo apt-get install frei0r-plugins

After all this we finally can install Motion via Git:

sudo apt-get install git
cd ~
git clone https://github.com/your_favorite_fork

(Motion seems developed in a rather competing fashion with many forks, so you have to check which version fits best for you by looking at their development tree on Git.)

example: git clone https://github.com/Ken-M/motion

change into the motion folder of your homedrive:

cd motion

Configure a basic setup:

The command by using the LIBAV route (second step) is:

./configure

And without LIBAV:

./configure --with-ffmpeg=$HOME/ffmpeg --with-ffmpeg-headers=$HOME/ffmpeg/include

Now enter:

make
sudo make install

Goto the directory of the conf file and rename the conf file:

cd /usr/local/etc
sudo mv motion-dist.conf motion.conf

Finally start motion:

motion
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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