Motion - can't get streaming working from a webcam

Posted by Emmanuel Brunet on Super User See other posts from Super User or by Emmanuel Brunet
Published on 2014-06-03T14:55:43Z Indexed on 2014/06/03 15:32 UTC
Read the original article Hit count: 303

Filed under:
|
|
|
|

I'm trying to record a video stream from my Tenvis IP camera with motion 3.2.12 on Debian 7.5.

I used the standard debian package with

sudo apt-get install motion

Assume my DNS IP cam is webcam, user : admin, password : password

/etc/motion/motion.conf

Bellow are my configuration file settings :

netcam_url http://webcam/videostream.cgi

netcam_userpass admin:password
target_dir /media/videos/log/motion

# The mini-http server listens to this port for requests (default: 0 = disabled)
webcam_port 1234

ffmpeg_cap_new on
ffmpeg_video_codec mpeg4

output_motion off
snapshot_interval 0

# Quality of the jpeg (in percent) images produced (default: 50)
webcam_quality 50

# Output frames at 1 fps when no motion is detected and increase to the
# rate given by webcam_maxrate when motion is detected (default: off)
webcam_motion on

# Maximum framerate for webcam streams (default: 1)
webcam_maxrate 15

# Restrict webcam connections to localhost only (default: on)
webcam_localhost on

# Limits the number of images per connection (default: 0 = unlimited)
# Number can be defined by multiplying actual webcam rate by desired number of seconds
# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate
webcam_limit 0

control_port 8080
control_authentication admin:password

Issue #1

when I try display

http:/localhost:1234

the browser looks frozen, no HTTP 404 received but it stills waiting for data it seems ..

Issue #2

in the output directory motion writes a lot of jpeg snapshots althought I just want to have several video sequenced files.

Log

I run motion in interactive mode in a terminal, here is the ouput

root@mercure:/etc/motion# motion -c motion-1.0.conf
[0] Processing thread 0 - config file motion-1.0.conf
[0] Motion 3.2.12 Started
[0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785
[0] Thread 1 is from motion-1.0.conf
[0] motion-httpd/3.2.12 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8080
[1] Thread 1 started
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 1234
[1] avcodec_open - could not open codec: Operation now in progress
[1] ffopen_open error creating (new) file [~/tmp/motion/01-20140603165303.avi]: Operation now in progress
[1] File of type 1 saved to: ~/tmp/motion/01-20140603165303-01.jpg
[1] Thread exiting
[1] Calling vid_close() from motion_cleanup
[1] vid_close: calling netcam_cleanup
[1] netcam camera handler: finish set, exiting
[0] Motion thread 1 restart
[1] Thread 1 started
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 1234
[1] avcodec_open - could not open codec: Resource temporarily unavailable
[1] ffopen_open error creating (new) file [~/tmp/motion/01-20140603165329.avi]: Resource temporarily unavailable
[1] File of type 1 saved to: ~/tmp/motion/01-20140603165329-00.jpg
[1] Thread exiting
[1] Calling vid_close() from motion_cleanup
[1] vid_close: calling netcam_cleanup
[1] netcam camera handler: finish set, exiting
[0] Motion thread 1 restart
[1] Thread 1 started
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 1234
[1] avcodec_open - could not open codec: Connection reset by peer
[1] ffopen_open error creating (new) file [~/tmp/motion/01-20140603165355.avi]: Connection reset by peer
[1] File of type 1 saved to: ~/tmp/motion/01-20140603165355-06.jpg
[1] Thread exiting
[1] Calling vid_close() from motion_cleanup
[1] vid_close: calling netcam_cleanup
[0] httpd - Finishing
[0] httpd Closing
[0] httpd thread exit
[1] netcam camera handler: finish set, exiting
[0] Motion thread 1 restart
[1] Thread 1 started
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 1234

It doesn't find the codec ...

avcodec_open - could not open codec: Operation now in progress

I've changed fmpeg_video_codec from mpeg4 to swf the result is the same.

When using flv format motion writes a lot of .jpg image but I can't see anything at http://localhost:1234

[1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-00.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-01.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-02.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-03.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-04.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-05.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-06.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171036-00.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171036-01.jpg
[1] File of type 1 saved to: ~/tmp/motion/01-20140603171036-02.jpg

Any idea just to get the video stream recoded on my local disk ?

© Super User or respective owner

Related posts about linux

Related posts about video