Streaming MJPG from webcam to RTSP using VLC

Streaming MJPG from webcam to RTSP is very simple through VLC. Well, VLC supports a lot of cool stuffs, you know. We just need to change the output option –sout using rtp module by providing a SDP.

$ vlc v4l2:///dev/video0:chroma=mjpg:width=800:height=600 --sout ‘#rtp{sdp=rtsp://IP:PORT/live.sdp}’

you can also use transcode module to create mjpg stream, but it is not recommended, just show you that it works.

$ vlc v4l2:///dev/video0 --sout ‘#transcode{vcodec=mjpg}:rtp{sdp=rtsp://IP:PORT/live.sdp}’

One important thing to remember, if you use chroma=mjpg, you should not add mux=property on the output, otherwise, the result will contain green color. For example, the following command will produce corruptedly-encoded images.

$ vlc v4l2:///dev/video0:chroma=mjpg --sout ‘#rtp{mux=ts,sdp=rtsp://IP:PORT/live.sdp}’

That’s all :)