<?xml version="1.0" encoding="UTF-8"?>
<chapter id="usesout"><title id="tusesout">
Examples for advanced use of VLC's stream output
(transcoding, multiple streaming, etc...)
</title>

<sect1><title>
Transcoding
</title>

<para>
Transcode the input stream and send it to a
multicast IP address with the associated SAP announce:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128,deinterlace}:
rtp{mux=ts,dst=239.255.12.42,port=5004,sdp=sap://,name="TestStream"}'</userinput>
</screen>

<para>
 Display the input stream, transcode it and send it
to a multicast IP address with the associated SAP announce:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#duplicate{dst=display,dst=
"transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128,deinterlace}:
rtp{mux=ts,dst=239.255.12.42,port=5004,sdp=sap://,name="TestStream"}"}'</userinput>
</screen>

<para>
Transcode the input stream, display the transcoded
stream and send it to a multicast IP address with the associated SAP
announce:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128,deinterlace}:
duplicate{dst=display,dst=rtp{mux=ts,dst=239.255.12.42,port=5004,sdp=sap://,name="TestStream"}}'</userinput>
</screen>

</sect1>

<sect1><title>
Multiple streaming
</title>

<para>
Send a stream to a multicast IP address and a
unicast IP address:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#duplicate{dst=
rtp{mux=ts,dst=239.255.12.42,port=5004,sdp=sap://,name="TestStream"},
dst=rtp{mux=ts,dst=192.168.1.2,port=50000}}'</userinput>
</screen>

<para>
Display the stream and send it to two unicast IP
addresses:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream
--sout '#duplicate{dst=display,
dst=rtp{mux=ts,dst=192.168.1.12,port=50002},
dst=rtp{mux=ts,dst=192.168.1.42,port=50004}}'</userinput>
</screen>

<para>Send parts of a multiple program input stream:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv multiple_program_input_stream 
--sout '#duplicate{dst=rtp{mux=ts,dst=239.255.12.42,port=5004},select="program=12345",
dst=rtp{mux=ts,dst=239.255.12.43,port=5004}, select="video,program=1234-2345"}'</userinput>
</screen>

<para>This command sends the program of the input stream which id is
12345 to 239.255.12.42 and all video programs with id between 1234 and
2345 to 239.255.12.43.</para>

</sect1>

<sect1><title>

Transcoding and multiple streaming
</title>

<para>
Transcode the input stream, display the transcoded
stream and send it to a multicast IP address with the associated SAP
announce and an unicast IP address:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128,deinterlace}:
duplicate{dst=display,dst=rtp{mux=ts,dst=239.255.12.42,sdp=sap://,name="TestStream"},
dst=rtp{mux=ts,dst=192.168.1.2,port=50006}}'</userinput>
</screen>

<para>
Display the input stream, transcode it and send it
to two unicast IP addresses:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#duplicate{dst=display,
dst="transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:
duplicate{dst=rtp{mux=ts,dst=192.168.1.2,port=50008},
dst=rtp{mux=ts,dst=192.168.1.12,port=50010}"}'</userinput>
</screen>

<para>
Send the input stream to a multicast IP address
and the transcoded stream to another multicast IP address with the
associated SAP announces:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#duplicate{dst=
rtp{mux=ts,dst=239.255.1.2,port=5004,sdp=sap://,name="OriginalStream"},
dst="transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:
rtp{mux=ts,dst=239.255.1.3,port=5004,sdp=sap://,name="TranscodedStream"}"}'</userinput>
</screen>

</sect1>

<sect1><title>
HTTP streaming
</title>

<para>
Stream in HTTP:
</para>

<itemizedlist>

<listitem><para>
on the server, run:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#standard{access=http,mux=ogg,dst=server.example.org:8080}'</userinput>
</screen>

</listitem>

<listitem><para>
on the client(s), run:
</para>

<screen>
<prompt>% </prompt><userinput>vlc http://server.example.org:8080</userinput>
</screen>

</listitem>

</itemizedlist>

<para>
Transcode and stream in HTTP:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:
standard{access=http,mux=ogg,dst=server.example.org:8080}'</userinput>
</screen>

<para>
For example, if you want to stream an audio CD in
Ogg/Vorbis over HTTP:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv cdda:///dev/cdrom --sout '#transcode{acodec=vorb,ab=128}:
standard{access=http,mux=ogg,dst=server.example.org:8080}'</userinput>
</screen>

</sect1>

<sect1><title>
RTP streaming
</title>

<para>
Stream in RTP:
</para>

<itemizedlist>

<listitem><para>
on the server, run:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#rtp{dst=192.168.0.12,port=1234,sdp=rtsp://server.example.org:8080/test.sdp}'</userinput>
</screen>

</listitem>

<listitem><para>
on the client(s), run:
</para>

<screen>
<prompt>% </prompt><userinput>vlc rtsp://server.example.org:8080/test.sdp</userinput>
</screen>

</listitem>

</itemizedlist>

<note><para>You can remplace the <emphasis>rtsp</emphasis> URL
by a <emphasis>http</emphasis> one, a file path (prefixed with
<emphasis>file://</emphasis>) or <emphasis>sap://</emphasis> to export
the sdp file using one of these methods instead of rtsp.</para></note>

</sect1>

<sect1><title>RTSP
</title>

<para>See <xref linkend="vlm" endterm="tvlm" /></para>

</sect1>

<sect1><title>MMS / MMSH streaming to Windows Media Player
</title>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#transcode{vcodec=DIV3,vb=256,scale=1,acodec=mp3,ab=32,channels=2}:std{access=mmsh,mux=asfh,dst=:8080}'</userinput>
</screen>

<para>VLC media player can connect to this by using the following url : mmsh://server_ip_address:8080 .</para>
<para>Windows Media Player can connect to this by using the following url : mms://server_ip_address:8080 .</para>
</sect1>

<sect1><title>
Use the <emphasis>es</emphasis> module
</title>

<para>
Separate audio and video in two PS files:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout
'#es{access=file,mux=ps,url_audio=audio-%c.%m,url_video=video-%c.%m}'</userinput>
</screen>

<para>
Extract the audio track of the input stream to a TS
file:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#es{access_audio=file,mux_audio=ts,url_audio=audio-%c.%m}'</userinput>
</screen>

<para>
 Stream in unicast the audio track on a port and the
video track on another port
(NOTE: This will not only work with VLC 0.8.6 or older - FIXME?)
</para>

<itemizedlist>

<listitem><para>
on the server side:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout
'#es{access=rtp,mux=ts,url_audio=192.168.1.2:50002,url_video=192.168.1.2:50004}'</userinput>
</screen>

</listitem>

<listitem><para>
on the client side: to receive the audio:
</para>

<screen>
<prompt>% </prompt><userinput>vlc rtp://@:50002</userinput>
</screen><para>
to receive the video:
</para>

<screen>
<prompt>% </prompt><userinput>vlc rtp://@:50004</userinput>
</screen>

</listitem>

</itemizedlist>

<para>
Stream in multicast the video and dump the audio in a file:
</para>

<screen>
<prompt>% </prompt><userinput>vlc -vvv input_stream --sout '#es{access-video=udp,mux-video=ts,dst-video=239.255.12.42,
access-audio=file,mux-audio=ps,dst-audio=audio-%c.%m}'</userinput>
</screen>

<note><para>
You can also combine the <emphasis>es</emphasis>
module with the other modules to set-up even more complex
solution.
</para></note>

</sect1>
</chapter>

