Stream over HTTP¶
This page explains how VLC Media Player can be used to stream a media file over HTTP in the local network. Streaming over the local network means that the streaming device and all the receiving device(s) should be connected to the same router for the streaming to work.
To stream a media file over HTTP, do the following in the std module:
Set
access=http, andSet
dst=:port/path(whereportis the port number andpathis the optional path name).
Sending the stream¶
To stream a file (sample.mp4) over port number 8090 and path name sample (you can choose your own port and path-name), the code will be:
$ vlc sample.mp4 --sout="#std{access=http, mux=ts, dst=:8090/sample}"
Note: It is important to specify the mux in std, otherwise the streaming fails.
Receiving the stream¶
As we did not mention any IP address while specifying the dst, the stream will be published over the IP address of the streaming device.
As an example, let us assume that the IP address of the streaming device is 192.168.0.101.
To receive the stream on the same device, you can do any of the following:
Run
$ vlc http://:8090/sample.Run
$ vlc http://localhost:8090/sample.Run
$ vlc http://127.0.0.1:8090/sample.Run
$ vlc http://192.168.0.101:8090/sample.
To receive the stream on a different device, we need to specify the IP address of the streaming device. Hence, run the following code on a new terminal in the receiving devices:
$ vlc http://192.168.0.101:8090/sample
Diagramtically, this is how the network might look. Notice that as http is a pull protocol, the stream is sent to a device only when it requests for it.
In case of streaming over HTTP, the access output part (at the end of the sout pipeline) works a little differently than in other cases. This is because in case of HTTP-streaming, the data isn’t sent anywhere until a client machine requests for it, while in other scenarios (like when streaming over UDP, or when saving the file), the data is “pushed” to relevant address specified through the dst parameter.
Alternate syntax¶
Instead of using the #std{access=http syntax, we can use the alternate syntax #http{ to stream over HTTP. The alternate syntax is just a stortcut for calling the access=http part of the std module, so all the other parameters remain the same.
Hence, the following code:
$ vlc sample.mp4 --sout="#std{access=http, mux=ts, dst=:8090/sample}"
is equivalent to:
$ vlc sample.mp4 --sout="#http{mux=ts, dst=:8090/sample}"