Motion - Feature Request 2009x 07x 14x 150700

Feature Request: Enable MOTION to process VLC's MJPG Streams.

Description

Enable MOTION to process VLC's MJPG Streams.

VLC is a powerfull multiplatform streaming solution. There are many Cams in the market which can't be used on unix platforms due to lack of drivers. The idea is to use VLC on windows and restream the DirectShow input from any CAM as an MJPEG Stream. This stream could be used by MOTION as if VLC is an "ordinary" IP-CAM like the Linksys WVC200 for example.

I saw that there is already a Patch integrated in SVN which does such kind of image aquisition:

http://www.lavrsen.dk/twiki/bin/view/Motion/LinksysWVC200SupportPatch

But with that patch alone VLC MJPE Stream cannot be parsed. Motion fills its buffer but can't parse the data.

If you run vlc on an windows machine like that:
dshow:// :dshow-vdev="MY-LINUX-INCOMPATIBLE-CAM" :dshow-adev="none" :dshow-size="640x480" :dshow-caching=1000 :sout=#transcode{vcodec=MJPG,vb=800,scale=1}
:duplicate{dst=std{access=http,mux=asf,dst=192.168.1.149:8081}}

you can grab the stream like that:
wget -S 
http://192.168.1.149:8081 -O ./streamdata.bin 
--16:20:00-- 
http://192.168.1.149:8081/ => `./streamdata.bin' Verbindungsaufbau zu 192.168.1.149:8081... verbunden. 
HTTP Anforderung gesendet, warte auf Antwort... 
HTTP/1.0 200 OK 
Content-type: application/octet-stream 
Cache-Control: no-cache 
Länge: nicht spezifiziert [application/octet-stream]

A first lokk at the captured stream shows that it contains (depending of the used muxer) a small muxer header and then begins (in my opinion) with an standard jpeg header

FF D8 FF FE which contains Lavcxx.xx

then FF DB

and so on till reaching an FF D9

Here you find some extra-data (?) until we reach the next jpeg marker FF D8.

I do not have much experience in such kind of development cause Iam mainly involved in Database Development. Anyway perhaps also others would find it usefull to have such a "bridge" to use the best of two worlds .....

Klaus Deiss

-- KlausDeiss - 14 Jul 2009

Follow up

Comments

Instead of using MJPG codec ... why not use VLC to generate jpeg/multipart that is already supported by motion ?

Then just need to setup motion to get data like a regular netcam smile

-- AngelCarpintero - 14 Jul 2009

I am not sure - vlc always is good for some interesting new features - but as far as I know vlc does not support jpeg/multipart as output ?? Please let me know if you have more information on creating this kind of output with vlc

gracias !

klaus

-- KlausDeiss - 14 Jul 2009

You can use something like for output :
:sout=#transcode{vcodec=MJPG,vb=400,width=320,height=240}:
duplicate{dst=std{access=http{mime=multipart/x-mixed-replace;
boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:1234/webcam.mjpg}} 

-- AngelCarpintero - 14 Jul 2009

Hola Angel,

Casi ......

First of all let me thank you - I didn't know that vlc is able to do that - pero ne se puede saber todo!

There are two small problems - resulting in the following output of motion.
[2] netcam_read_first_header: Received first header ('HTTP/1.0 200 OK') 
[2] netcam_read_first_header: Received first header ('Content-type: multipart/x-mixed-replace;boundary=--myboundary') 
[2] netcam_read_first_header: Streaming camera 
[2] netcam_read_first_header: Boundary string [--myboundary] 
[2] Received first header (cache-Control: no-cache') 
[2] netcam_read_first_header: Received first header ('') 
[2] netcam_read_next_header: Found image header record 
[2] netcam_setup_html: connected, going on to read image. 
[2] netcam_check_buffsize: expanding buffer from [0/0] to [0/4096] bytes. 
[2] netcam_check_buffsize: expanding buffer from [3931/4096] to [3931/8192] bytes. 
[2] netcam_output_message: Not a JPEG file: starts with 0x00 0xff 
[2] netcam_error_exit: netcam->jpeg_error 1 

First of all there is a problem with the boundary syntax, instead of the wished boundary VLC is always inserting "--myboundary", perhaps only a syntactic problem.

Starting vlc that way is a workaround:
C:\Programme\VideoLAN\VLC\vlc.exe dshow:// :dshow-vdev="2Mega Camera, WDM Video Capture" :
dshow-adev="none" :dshow-size="320x240" :dshow-caching=1000 :
sout=#transcode{vcodec=MJPG,vb=800,width=320,height=240}:
duplicate{dst=std{access=http{mime=multipart/x-mixed-replace;boundary=--myboundary},
mux=mpjpeg,dst=192.168.3.211:12345/fu.mjpg}}

But there also remains a semantic problem. After the header, exactly after Content-Length: xxxx VLC inserts 0D 0A and then 00 (bug of vlc ?) - so parsing fails: "starts with 0x00 0xff"

que lastima !

Thx

Klaus

-- KlausDeiss - 15 Jul 2009

Now I using annother VLC Version (0.9.4) - with that version all is running fine. Boundary and the 00 Problem is fixed in that version. Sorry for any inconvinience.

Klaus

-- KlausDeiss - 15 Jul 2009

Klaus, no worries , it's ok.

Glad to see you got it working smile

-- AngelCarpintero - 15 Jul 2009

Update 4 Years later .....

Still no support for MJPG Streams, but anyway this commandline runs actual vlc (2.07) in an motion compatible way:

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" dshow:// :sout=#transcode{vcodec=MJPG,vb=800,fps=5}:std{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=0.0.0.0:8082/go.mjpg,delay=0}

This "netcam" needs in /etc/motion/motion.conf

netcam_url http://192.168.XXX.XXX:8082/go.mjpg

-- KlausDeiss - 16 Jul 2013

Hey KlausDeiss,

I'm so thankful for your work. Now I'm trying to run this command and doesn't work for me:

cvlc -I telnet --telnet-password admin --telnet-port 15600 "http://admin:admin@192.168.0.252/videostream.asf?useruser=admin&pwd=admin&rate=12" --sout "#standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888}"

Do you have any suggestions? I'm using VLC version 2.0.4 Twoflower (2.0.3-289-g6e6100a)

Maybe you can add me on skype, or hangout. Skype:henriquecholo Email: henriquecholo@gmailPLEASENOSPAM.com Thanks.

-- HenriqueCholodovskis - 06 Feb 2014

FeatureRequestForm edit

TopicTitle Enable MOTION to process VLC's MJPG Streams.
FeatureRequestStatus Rejected
SubmittedBy KlausDeiss
Topic revision: r10 - 06 Feb 2014, HenriqueCholodovskis
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.