'VLC - How to play a MJPEG Stream

I have a server broadcasting the video generated by a USB webcam using GStream with the following gst-launch command:

 gst-launch-1.0 v4l2src ! video/x-raw,width=352,height=288 ! jpegenc! rtpjpegpay ! udpsink host=239.255.12.52 port=5004

Now i need a client to play that broadcast with VLC. I tried playing the following:

rtsp://239.255.12.52:5004

But I only get the following error:

SDP required:
A description in SDP format is required to receive the RTP stream. Note that rtp:// URIs cannot work with dynamic RTP payload format (96).

Then i searched trying to find a sdp file that could help me play the stream. I tried this:

v=0 
c=IN IP4 239.255.12.52 
t=0 
m=video 5004 RTP/AVP 96 
a=rtpmap:96 JPEG/90000 

But it did'nt work. The vlc log just says:

es error: cannot peek
es error: cannot peek
...

I know the stream is working because i can use gstreamer to play it with the following command:

gst-launch-1.0 udpsrc uri="udp://239.255.12.52:5004" ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideosink

But i need it play with vlc not gstreamer. Any ideas? Thanks!!



Solution 1:[1]

How about this approach:

server (gstreamer):

gst-launch-1.0 v4l2src ! image/jpeg,width=1280,height=720 ! tcpserversink host=###.###.###.###

client (vlc):

tcp://###.###.###.###:4953

Also, in vlc gui, set caching to 0 ms. (:network-caching=0)

In this approach, there's no extra encode (jpegenc not needed) on the server side because the camera itself can produce .jpg images (this is common with web cameras). Also no muxing needed.

On the client side, the latency is minimal.

It's not multicast, but maybe that's ok for you?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 helloflow