Documentation:Streaming HowTo/Stream from Encoding Cards and Other Capture Devices
<?xml version="1.0" encoding="UTF-8"?> <chapter id="hardencoding"><title id="thardencoding"> Stream from encoding cards and other capture peripherals </title>
<sect1><title>Hardware encoding cards</title>
<note><para> This is possible under GNU/Linux only. </para></note><para> VideoLAN supports two kinds of MPEG-2 encoding cards: </para>
<itemizedlist>
<listitem><para>
Hauppauge WinTV-PVR-250 and WinTV-PVR-350,
</para></listitem>
<listitem><para>Visiontech Kfir.</para></listitem>
</itemizedlist>
<para> The Hauppauge WinTV-PVR-250/350 gives much better results and is cheaper than the Visiontech Kfir. </para>
<sect2><title> Stream with the Hauppauge WinTV-PVR-250/350 card </title>
<sect3><title> Install the drivers </title>
<para> First, you will have to patch your kernel (version 2.4) to support the v4l2 API (Video 4 Linux version 2). The patch is available on the <ulink url="http://bytesex.org/v4l/">Video4Linux HQ</ulink>. If you use a 2.6 kernel, you only need to build I2C support and the BT848 Video For Linux module. </para>
<para> Once your kernel is ready, install the CK version (currently in development) of the Linux drivers for the Hauppauge WinTV-PVR-250/350. They are hosted on <ulink url="http://67.18.1.101/~ckennedy/ivtv">ivtv ck</ulink>. You will need to patch your kernel to use it with a 2.4. You can also use the CVS version available here: <ulink url="http://ivtv.sourceforge.net/">ivtv.sourceforge.net</ulink> (this version is not developped anymore). Then, you will have to create the device and load the modules; for this, please refer to the documentation shipped with the drivers. </para>
</sect3>
<sect3><title> Stream with VLC </title>
<note><para> You must add <command>--enable-pvr</command> to <command>./configure</command> to use this feature. </para></note>
<screen> <prompt>% </prompt><userinput>vlc -vvv --color pvr:/dev/video0:norm=secam:size=720x576:frequency=576250: bitrate=3000000:maxbitrate=4000000 --cr-average 1000 --sout udp:192.168.0.42 --ttl 12</userinput> </screen>
<para> where
</para>
<itemizedlist>
<listitem><para><emphasis>/dev/video0</emphasis> is the device corresponding to the encoding card ,</para></listitem>
<listitem><para><emphasis>norm=secam</emphasis>
is name of the standard of the analogic signal
(possible values are pal, secam, and ntsc) ,</para></listitem>
<listitem><para><emphasis>size=720x576</emphasis> is the size of the video you want to stream ,</para></listitem>
<listitem><para><emphasis>frequency=567250</emphasis>
is the frequency in kHz of the channel you want to
stream ,</para></listitem>
<listitem><para><emphasis>bitrate=3000000</emphasis> is the average bitrate of the stream ,</para></listitem>
<listitem><para><emphasis>maxbitrate=4000000</emphasis> is the maximum bitrate of the stream ,</para></listitem>
<listitem><para><emphasis>1000</emphasis> is a secret value to work around a bug of the card. </para></listitem>
<listitem><para><emphasis>192.168.0.42</emphasis>
is either :
</para>
<itemizedlist> <listitem><para> the IP address of the machine you want to unicast to
- </para></listitem>
<listitem><para> or the DNS name the machine you want to unicast to
- </para></listitem>
<listitem><para> or a multicast IP address. </para></listitem>
</itemizedlist>
</listitem>
<listitem><para><emphasis>12</emphasis>
is the value of the TTL (Time To
Live) of your IP packets (which means that the stream will be able to cross 11 routers). </para></listitem>
</itemizedlist>
</sect3>
</sect2>
<sect2><title> Stream with the Visiontech Kfir card </title>
<sect3><title> Install the drivers </title>
<para> If you want to be able to stream from a Visiontech Kfir card, you need to install its Linux drivers. Download the latest release of the drivers from the <ulink url="http://www.linuxtv.org/download/mpeg2/">drivers download page</ulink> of the <ulink url="http://www.linuxtv.org/">LinuxTV web site</ulink>. </para><para> Uncompress the tarball and follow the instructions written in the <filename>INSTALL</filename> file to compile and install the drivers. </para>
<note><para> If you have a VIA chipset, you need to disable USB in the BIOS. </para></note>
</sect3>
<sect3><title>
Stream </title>
<screen> <prompt>% </prompt><userinput>vlc -vvv --color kfir:/dev/video --sout udp:192.168.0.42 --ttl 12</userinput> </screen>
<para>where
:</para>
<itemizedlist>
<listitem><para><filename>/dev/video</filename> is the device corresponding to the Kfir card ,</para></listitem>
<listitem><para><emphasis>192.168.0.42</emphasis>
is either :
</para>
<itemizedlist> <listitem><para> the IP address of the machine you want to unicast to
- </para></listitem>
<listitem><para> or the DNS name the machine you want to unicast to
- </para></listitem>
<listitem><para> or a multicast IP address. </para></listitem>
</itemizedlist>
</listitem>
<listitem><para><emphasis>12</emphasis>
is the value of the TTL (Time To
Live) of your IP packets (which means that the stream will be able to cross 11 routers). </para></listitem>
</itemizedlist>
</sect3>
</sect2> </sect1>
<sect1> <title>Software encoding cards</title>
<sect2><title>Under GNU/Linux</title>
<sect3><title> Install the Video for Linux drivers </title>
<para> If you want to stream from an acquisition card or a webcam, a video4linux driver must be available for it. You can find more information about video4linux and supported devices <ulink url="http://www.exploits.org/v4l">here</ulink>. </para>
<para> Compile the right module for your device, and insert it into your kernel. Some video4linux modules are shipped with the 2.4.x and 2.6.x Linux kernels, the patch is available on the <ulink url="http://bytesex.org/v4l">Video4Linux HQ</ulink>.</para>
<para>You can test your device by using any of the listed programs in the <emphasis>Video: TV and PVR/DVR</emphasis> section of <ulink url="http://www.exploits.org/v4l/">this page</ulink>. </para>
<para> Note that v4l2 modules will also work with VLC. </para>
</sect3>
<sect3><title> Stream with VLC </title>
<note><para> You must add <command>--enable-v4l</command> to <command>./configure</command> to use this feature. </para></note>
<screen> <prompt>% </prompt><userinput>vlc -vvv --color v4l:/dev/video:norm=secam:frequency=543250:size=640x480:channel=0:adev=/dev/dsp:audio=0 --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=3000,ab=256,venc=ffmpeg{keyint=80,hurry-up,vt=800000},deinterlace}:std{access=udp,mux=ts,dst=239.255.12.13}' --ttl 12</userinput> </screen>
<note><para>You can find all transcode options on this page : <xref linkend="cmdline" endterm="tcmdline" /> .</para></note>
<para>where: </para><itemizedlist>
<listitem><para><filename>/dev/video</filename>
is the device corresponding to your acquisition
card or your webcam, </para></listitem>
<listitem><para><emphasis>norm=secam</emphasis>
is name of the standard of the analogic signal
(possible values are pal, secam, and ntsc) ,</para></listitem>
<listitem><para><emphasis>frequency=543250</emphasis>
is the frequency of the channel in kHz
(<emphasis>Warning :</emphasis> for VLC < 0.6.1, Frequency is channel frequency in MHz multiplied by 16), </para></listitem>
<listitem><para> <emphasis>size=640x480</emphasis> is the size of the video you want (you can also put the standard size like <emphasis>subqcif</emphasis> (128x96), <emphasis>qsif</emphasis> (160x120), <emphasis>qcif</emphasis> (176x144), <emphasis>sif</emphasis> (320x240), <emphasis>cif</emphasis> (352x288) or <emphasis>vga</emphasis> (640x480)), </para></listitem>
<listitem><para><emphasis>channel=0</emphasis> is the number of the channel (usually 0 is for tuner, 1 for composite and 2 for svideo),
</para></listitem>
<listitem><para><emphasis>adev=/dev/dsp</emphasis> is the audio device, </para></listitem>
<listitem><para><emphasis>audio=1</emphasis> is the number of the audio channel (usually 0 is for mono and 1 for stereo), </para></listitem>
<listitem><para><emphasis>vcodec=mp4v</emphasis> is the video format you want to encode in (<emphasis>mp4v</emphasis> is MPEG-4, <emphasis>mpgv</emphasis> is MPEG-1, and there is also <emphasis>h263</emphasis>, <emphasis>DIV1</emphasis>, <emphasis>DIV2</emphasis>, <emphasis>DIV3</emphasis>, <emphasis>I420</emphasis>, <emphasis>I422</emphasis>, <emphasis>I444</emphasis>, <emphasis>RV24</emphasis>, <emphasis>YUY2</emphasis>),</para></listitem>
<listitem><para><emphasis>acodec=mpga</emphasis> is the audio format you want to encode in (<emphasis>mpga</emphasis> is MPEG audio layer 2, <emphasis>a52</emphasis> is A52 i.e. AC3 sound), </para></listitem>
<listitem><para><emphasis>vb=3000</emphasis>
is the video bitrate in Kbit/s
</para></listitem>
<listitem><para><emphasis>ab=256</emphasis>
is the audio bitrate in Kbit/s
</para></listitem>
<listitem><para><emphasis>venc=ffmpeg</emphasis>
allows to set the encoder to use, where: </para>
<itemizedlist> <listitem><para><emphasis>keyint=80</emphasis> is the maximal amount of frames between two key frames</para></listitem> <listitem><para><emphasis>hurry-up</emphasis> allows the encoder to decrease the quality of the stream if the CPU can't keep up with the encoding rate</para></listitem> <listitem><para><emphasis>vt=800000</emphasis> is the tolerance in kbit/s for the bitrate of the outputted video</para></listitem> </itemizedlist> </listitem>
<listitem><para><emphasis>deinterlace</emphasis> tells VLC to deinterlace the video on the fly, </para></listitem>
<listitem><para><emphasis>192.168.0.42</emphasis>
is either:
</para>
<itemizedlist> <listitem><para> the IP address of the machine you want to unicast to; </para></listitem>
<listitem><para> or the DNS name the machine you want to unicast to;
</para></listitem>
<listitem><para> or a multicast IP address.</para></listitem>
</itemizedlist>
</listitem>
<listitem><para><emphasis>12</emphasis>
is the value of the TTL (Time To
Live) of your IP packets (which means that the stream will be able to cross 11 routers).</para></listitem>
</itemizedlist>
</sect3>
</sect2> </sect1>
<sect1><title>Stream with DirectShow</title> <note><para>This is only possible under Windows</para></note> <sect2><title>Install your peripheral drivers</title> <para>You need to install your peripherals under Windows with the appropriate drivers. Nothing else is necessary.</para> </sect2> <sect2><title>Stream with VLC in command line</title> <para><screen><prompt>% </prompt><userinput>C:\Program Files\VideoLAN\VLC\vlc.exe -vvv -I rc --ttl 12 dshow:// vdev="VGA USB Camera" adev="USB Camera" size="640x480" --sout=#std{mux=ts,access=udp,dst=239.255.42.12}</userinput></screen></para> <note> <para>You need to precise the complete path to find vlc program or to launch the command from the correct directory.</para> </note> <itemizedlist> <listitem><para><emphasis>vvv</emphasis> is to activate the verbose mode</para></listitem> <listitem><para><emphasis>rc</emphasis> is to activate the remote control interface (MS/DOS console)</para></listitem> <listitem><para><emphasis>12</emphasis> is the value of the TTL (Time To Live) of your IP packets (which means that the stream will be able to cross 11 routers), </para></listitem> <listitem><para><emphasis>vdev="VGA USB Camera"</emphasis> is the name of the video peripheral that DirectShow will use (this is only an exemple), </para></listitem> <listitem><para><emphasis>adev="USB Camera"</emphasis> is the name of the audio peripheral, </para></listitem> <listitem><para><emphasis>size="640x480"</emphasis> is the resolution (you can also put the standard size like <emphasis>subqcif</emphasis> (128x96), <emphasis>qsif</emphasis> (160x120), <emphasis>qcif</emphasis> (176x144), <emphasis>sif</emphasis> (320x240), <emphasis>cif</emphasis> (352x288) or <emphasis>vga</emphasis> (640x480)). </para></listitem>
<listitem><para><emphasis>239.255.42.12</emphasis>
is either:
</para> <itemizedlist> <listitem><para> the IP address of the machine you want to unicast to </para></listitem> <listitem><para> or the DNS name the machine you want to unicast to </para></listitem> <listitem><para> or a multicast IP address.</para></listitem> </itemizedlist> </listitem>
</itemizedlist> </sect2> </sect1> </chapter>