Protect media stream with HTTP basic authentication

In previous article, I mentioned about streaming from webcam to HTTP. But somehow you want to protect it? such as it streams from your Raspberry Pi on your own network, and don’t want anybody to view it freely…

Okay, we can protect HTTP stream with basic authentication digest with VLC by adding user= and pwd= option to the http property on std module.

$ vlc v4l2:///dev/video0:chroma=mjpg — sout ‘#std{access=http{user=petehouston,pwd=secret,mime=multipart/x-mixed-replace;boundary=-7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=IP:PORT}’

Now, everytime you want to view the stream, you need to input the authentication values.It’s simple, not so perfect but it is good enough to use for now.