VLC as RTSP server – authentication not working

ip cameraraspberry pirtspvlc-media-player

Settings : I have an IPcam and a raspberry (RPi3 running Raspbian with VLC 3.0). The problem also happens when I replace the raspberry by a computer running Debian, also with VLC 3.0.

Goal : My goal is to be able to remotely access the stream of the IPcam through the Rpi, i.e. running vlc as a RTSP server on the Rpi. It almost works, but I still have a problem with protecting the stream exiting the Rpi by a password.

What i've done : On the Rpi, VLC is running as a RTSP server, taking as input the stream of the camera.

The command running is :

cvlc rtsp://ipcamlogin:ipcampassword@ipcamIP:554/play1.sdp –sout '#transcode{acodec=mp4a,ab=128,channels=2,samplerate=8000}:rtp{sdp=rtsp://username:password@rpiIP:8080/test.sdp}' –sout-ffmpeg-strict -2 –sout-avcodec-strict -2

(Almost) everything works, i can view my webcam remotely by connecting to the RPi.

The problem : The problem is that although i stream on rtsp://username:password@rpiIP:8080/test.sdp, the stream can be accessed at rtsp://rpiIP:8080/test.sdp without any username/password being asked. In other words, the stream can be accessed by anyone. My question is : how can I protect the output stream with a username/password ?

Thanks a lot.

Best Answer

To set up username and password authentication in a RTSP stream, you need to use the --sout-rtsp-user and --sout-rtsp-pwd.

The final command should be:

cvlc rtsp://ipcamlogin:ipcampassword@ipcamIP:554/play1.sdp --sout '#transcode{acodec=mp4a,ab=128,channels=2,samplerate=8000}:rtp{sdp=rtsp://rpiIP:8080/test.sdp}' --sout-ffmpeg-strict -2 --sout-avcodec-strict -2 --sout-rtsp-user username --sout-rtsp-pwd password

The protocol://username:password@hostname:port/path is used when you connect to some remote endpoint. When you create your own stream, you need to use the --sout-... options.

Related Question