Thursday, July 26, 2007

Using VLC to stream videos

Streaming Videos using vlc.
vlc is a versatile audio video streamer. Please look at http://www.videolan.org for more information.

1) start vlc
vlc --intf telnet
This starts vlc and makes it listen on port 4212 for incoming connections.

2) Telnet into vlc.
telnet 127.0.0.1 4212
Use 'admin' as password. If you want to connect from another machine can you use the IP of vlc machine instead of 127.0.0.1
You will see messages like below,
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Password:
Welcome, Master
>
3) Now create a media

>new unexpected broadcast
>setup unexpected input /home/developer/mpeg/Unexpect2001.mpeg
>setup unexpected enabled
>setup unexpected output "#duplicate{dst=std{access=udp,mux=ts,dst=192.168.11.6:1234}}"
>setup unexpected loop
What are we doing here? We are creating a media named 'unexpected'. The input file is '/home/developer/mpeg/Unexpect2001.mpeg' and output will be streamed in udp (access=udp) packets as mpeg transport stream (mux=ts) to 192.168.11.6:1234 (host:port). If you want (for IPTV etc ), you can use multicast IPs.

4) Play the media
control unexpected play
This will start playing the media.
If you do these operations frequently then,

5) You can also save these commands in a file by
save commands.file

a file saved like this can be reloaded some other time by
load command.file

6) After loading the commands files you can play the media as mentioned in step 4.

The loop at the last line in step 3 means that it will keep looping till you stop playing (control unexpected stop)

Note: You can use the same instance of vlc to stream multiple media streams by creating different medias.
You can download free videos from http://www.archive.org