Remove entire note about Sound Blaster Live is not supported under
[dragonfly.git] / en / books / handbook / multimedia / chapter.sgml
1 <!--
2      The FreeBSD Documentation Project
3
4      $FreeBSD: doc/en_US.ISO8859-1/books/handbook/multimedia/chapter.sgml,v 1.81 2004/03/27 23:01:29 mheinen Exp $
5      $DragonFly: doc/en/books/handbook/multimedia/chapter.sgml,v 1.5 2005/06/30 02:14:18 reed Exp $
6 -->
7
8 <chapter id="multimedia">
9  <chapterinfo>
10   <authorgroup>
11    <author>
12     <firstname>Ross</firstname>
13     <surname>Lippert</surname>
14     <contrib>Edited by </contrib>
15    </author>
16   </authorgroup>
17  </chapterinfo>
18
19  <title>Multimedia</title>
20   <sect1 id="multimedia-synopsis">
21   <title>Synopsis</title>
22
23     <para>&os; supports a wide variety of sound cards, allowing you
24       to enjoy high fidelity output from your computer.  This includes
25       the ability to record and playback audio in the MPEG Audio Layer
26       3 (MP3), WAV, and Ogg Vorbis formats as well as many other
27       formats.  The &pkgsrc; and FreeBSD Ports collections also contain
28       applications allowing you to edit your recorded audio, add sound
29       effects, and control attached MIDI devices.</para>
30
31     <para>With some willingness to experiment, &os; can support
32       playback of video files and DVD's.  The number of applications
33       to encode, convert, and playback various video media is more
34       limited than the number of sound applications.  For example as
35       of this writing, there is no good re-encoding application in the
36       FreeBSD Ports Collection, which could be use to convert
37       between formats, as there is with <filename
38       role="package">audio/sox</filename>.  However, the software
39       landscape in this area is changing rapidly.</para>
40       <!-- todo: reed: is the above "no good re-encoding" true? -->
41
42     <para>This chapter will describe the necessary steps to configure
43       your sound card.  The configuration and installation of X11
44       (<xref linkend="x11">) has already taken care of the
45       hardware issues for your video card, though there may be some
46       tweaks to apply for better playback.</para>
47
48     <para>After reading this chapter, you will know:</para>
49
50     <itemizedlist>
51       <listitem>
52         <para>How to configure your system so that your sound card is
53           recognized.</para>
54       </listitem>
55
56       <listitem>
57         <para>Methods to test that your card is working using
58           sample applications.</para>
59       </listitem>
60
61       <listitem>
62         <para>How to troubleshoot your sound setup.</para>
63       </listitem>
64
65       <listitem>
66         <para>How to playback and encode MP3s and other audio.</para>
67       </listitem>
68
69       <listitem>
70         <para>How video is supported by the X server.</para>
71       </listitem>
72
73       <listitem>
74         <para>Some video player/encoder ports which give good results.</para>
75       </listitem>
76
77       <listitem>
78         <para>How to playback DVD's, <filename>.mpg</filename> and <filename>.avi</filename> files.</para>
79       </listitem>
80
81       <listitem>
82         <para>How to rip CD and DVD information into files.</para>
83       </listitem>
84
85       <listitem>
86         <para>How to configure a TV card.</para>
87       </listitem>
88     </itemizedlist>
89
90     <para>Before reading this chapter, you should:</para>
91
92     <itemizedlist>
93       <listitem><para>Know how to configure and install a new kernel (<xref
94         linkend="kernelconfig">).</para></listitem>
95     </itemizedlist>
96
97     <warning>
98       <para>Trying to mount audio CDs
99         with the &man.mount.8; command will
100         result in an error, at least, and a <emphasis>kernel
101         panic</emphasis>, at worst.  These media have specialized
102         encodings which differ from the usual ISO-filesystem.</para>
103     </warning>
104
105   </sect1>
106
107   <sect1 id="sound-setup">
108     <sect1info>
109       <authorgroup>
110         <author>
111          <firstname>Moses</firstname>
112          <surname>Moore</surname>
113          <contrib>Contributed by </contrib>
114          <!-- 20 November 2000 -->
115         </author>
116       </authorgroup>
117     </sect1info>
118
119     <title>Setting Up the Sound Card</title>
120     
121   <sect2 id="sound-device">
122     <title>Locating the Correct Device</title>
123
124     <indexterm><primary>PCI</primary></indexterm>
125     <indexterm><primary>ISA</primary></indexterm>
126     <indexterm><primary>sound cards</primary></indexterm>
127     <para>Before you begin, you should know the model of the card you
128       have, the chip it uses, and whether it is a PCI or ISA card.
129       &os; supports a wide variety of both PCI and ISA cards.  If
130       you do not see your card in the following list, check the
131       &man.pcm.4; manual page.  This is not a complete list; however,
132       it does list some of the most common cards.</para>
133
134     <itemizedlist>
135       <listitem>
136         <para>Crystal 4237, 4236, 4232, 4231</para>
137       </listitem>
138
139       <listitem>
140         <para>Yamaha OPL-SAx</para>
141       </listitem>
142
143       <listitem>
144         <para>OPTi931</para>
145       </listitem>
146
147       <listitem>
148         <para>Ensoniq AudioPCI 1370/1371</para>
149       </listitem>
150
151       <listitem>
152         <para>ESS Solo-1/1E</para>
153       </listitem>
154
155       <listitem>
156         <para>NeoMagic 256AV/ZX</para>
157       </listitem>
158
159       <listitem>
160         <para>&soundblaster; Pro, 16, 32, AWE64, AWE128, Live</para>
161       </listitem>
162
163       <listitem>
164         <para>Creative ViBRA16</para>
165       </listitem>
166
167       <listitem>
168         <para>Advanced Asound 100, 110, and Logic ALS120</para>
169       </listitem>
170
171       <listitem>
172         <para>ES 1868, 1869, 1879, 1888</para>
173       </listitem>
174
175       <listitem>
176         <para>Gravis UltraSound</para>
177       </listitem>
178
179       <listitem>
180         <para>Aureal Vortex 1 or 2</para>
181       </listitem>
182     </itemizedlist>
183
184     <indexterm>
185       <primary>kernel</primary>
186       <secondary>configuration</secondary>
187     </indexterm>
188
189     <para>To use your sound device, you will need to load the proper
190       device driver.  This may be accomplished in one of two ways.
191       The easiest way is to simply load a kernel module for your sound
192       card with &man.kldload.8; which can either be done from the
193       command line:</para>
194
195     <screen>&prompt.root; <userinput>kldload snd_emu10k1.ko</userinput></screen>
196     <para>or by adding the appropriate line to the file
197       <filename>/boot/loader.conf</filename> like this:</para>
198
199     <programlisting>snd_emu10k1_load="YES"</programlisting>
200
201     <para>These examples are for a Creative &soundblaster; Live! sound
202       card.  Other available loadable sound modules are listed in
203       <filename>/boot/defaults/loader.conf</filename>.</para>
204
205     <para>Alternatively, you may statically
206       compile in support for your sound card in your kernel.  The
207       sections below provide the information you need to add support
208       for your hardware in this manner.  For more information about
209       recompiling your kernel, please see <xref
210       linkend="kernelconfig">.</para>
211
212     <sect3>
213       <title>Creative, Advance, and ESS Sound Cards</title>
214
215       <para>If you have one of the above cards, you will need to
216         add:</para>
217         
218       <programlisting>device pcm</programlisting>
219
220       <para>to your kernel configuration file.  If you have a PnP ISA
221         card, you will also need to add:</para>
222
223       <programlisting>device sbc</programlisting>
224
225       <para>For a non-PnP ISA card, add:</para>
226
227       <programlisting>device pcm
228 device sbc0 at isa? port 0x220 irq 5 drq 1 flags 0x15</programlisting>
229
230       <para>to your kernel configuration file.  The settings shown
231         above are the defaults.  You may need to change the IRQ or the
232         other settings to match your card.  See the &man.sbc.4; manual
233         page for more information.</para>
234
235     </sect3>
236
237     <sect3>
238       <title>Gravis UltraSound Cards</title>
239
240       <para>For a PnP ISA card, you will need to add:</para>
241
242       <programlisting>device pcm
243 device gusc</programlisting>
244
245       <para>to your kernel configuration file.  If you have a non-PnP
246         ISA card, you will need to add:</para>
247
248       <programlisting>device pcm
249 device gus0 at isa? port 0x220 irq 5 drq 1 flags 0x13</programlisting>
250
251       <para>to your kernel configuration file.  You may need to change
252         the IRQ or the other settings to match your card. See the
253         &man.gusc.4; manual page for more information.</para>
254     </sect3>
255
256     <sect3>
257       <title>Crystal Sound Cards</title>
258
259       <para>For Crystal cards, you will need to add:</para>
260
261       <programlisting>device pcm
262 device csa</programlisting>
263
264       <para>to your kernel configuration file.</para>
265     </sect3>
266
267     <sect3>
268       <title>Generic Support</title>
269
270       <para>For PnP ISA or PCI cards, you will need to add:</para>
271
272       <programlisting>device pcm</programlisting>
273
274       <para>to your kernel configuration file.  If you have a non-PnP
275         ISA sound card that does not have a bridge driver, you will
276         need to add:</para>
277
278       <programlisting>device pcm0 at isa? irq 10 drq 1 flags 0x0</programlisting>
279
280       <para>to your kernel configuration file.  You may need to change
281         the IRQ or the other settings to match your card.</para>
282
283     </sect3>
284
285     <sect3>
286       <title>Onboard Sound</title>
287
288       <para>Some systems with built-in motherboard sound devices may
289         require the following device in your kernel
290         configuration:</para>
291
292       <programlisting>device pnpbios</programlisting>
293
294     </sect3>
295   </sect2>
296
297   <sect2 id="sound-devicenodes">
298     <title>Creating and Testing the Device Nodes</title>
299
300     <indexterm><primary>device nodes</primary></indexterm>
301     <para>After you reboot, log in and check for the device in the
302       <filename>/var/run/dmesg.boot</filename> file, as shown below:</para>
303
304     <screen>&prompt.root; <userinput>grep pcm /var/run/dmesg.boot</userinput>
305 pcm0: &lt;SB16 DSP 4.11&gt; on sbc0</screen>
306
307     <para>The output from your system may look different.  If no
308       <devicename>pcm</devicename> devices show up, something went
309       wrong earlier.  If that happens, go through your kernel
310       configuration file again and make sure you chose the correct
311       device.  Common problems are listed in <xref
312       linkend="troubleshooting">.</para>
313
314     <para>If the previous command returned
315       <devicename>pcm0</devicename>, you will have to run the
316       following as <username>root</username>:</para>
317
318     <screen>&prompt.root; <userinput>cd /dev</userinput>
319 &prompt.root; <userinput>sh MAKEDEV snd0</userinput></screen>
320
321     <para>If the command returned <devicename>pcm1</devicename>,
322       follow the same steps as shown above, replacing
323       <devicename>snd0</devicename> with
324       <devicename>snd1</devicename>.</para>
325
326     <note>
327       <para>The above commands will <emphasis>not</emphasis> create a
328         <devicename>/dev/snd</devicename> device!</para>
329     </note>
330
331     <para><command>MAKEDEV</command> will create a group of device
332       nodes, including:</para>
333
334     <informaltable frame="none">
335       <tgroup cols="2">
336         <thead>
337           <row>
338             <entry>Device</entry>
339             <entry>Description</entry>
340           </row>
341         </thead>
342
343         <tbody>
344           <row>
345             <entry><devicename>/dev/audio</devicename></entry>
346             <entry>&sparc; compatible audio device</entry>
347           </row>
348
349           <row>
350             <entry><devicename>/dev/dsp</devicename></entry>
351             <entry>Digitized voice device</entry>
352           </row>
353
354           <row>
355             <entry><devicename>/dev/dspW</devicename></entry>
356             <entry>Like <devicename>/dev/dsp</devicename>, but 16 bits
357               per sample</entry>
358           </row>
359
360           <row>
361             <entry><devicename>/dev/midi</devicename></entry>
362             <entry>Raw midi access device</entry>
363           </row>
364
365           <row>
366             <entry><devicename>/dev/mixer</devicename></entry>
367             <entry>Control port mixer device</entry>
368           </row>
369
370           <row>
371             <entry><devicename>/dev/music</devicename></entry>
372             <entry>Level 2 sequencer interface</entry>
373           </row>
374
375           <row>
376             <entry><devicename>/dev/sequencer</devicename></entry>
377             <entry>Sequencer device</entry>
378           </row>
379
380           <row>
381             <entry><devicename>/dev/pss</devicename></entry>
382             <entry>Programmable device interface</entry>
383           </row>
384         </tbody>
385       </tgroup>
386     </informaltable>
387
388     <para>If all goes well, you should now have a functioning sound
389       card.  If your CD-ROM or DVD-ROM drive is properly coupled to
390       your sound card, you can put a CD in the drive and play it
391       with &man.cdcontrol.1;:</para>
392
393       <screen>&prompt.user; <userinput>cdcontrol -f /dev/acd0c play 1</userinput></screen>
394
395     <para>Various applications, such as <filename
396       role="package">audio/workman</filename> offer a better
397       <!-- todo: reed: not in pkgsrc -->
398       interface.  You may want to install an application such as
399       <filename role="package">audio/mpg123</filename> to listen to
400       MP3 audio files.</para>
401
402     <sect3 id="troubleshooting">
403       <title>Common Problems</title>
404
405       <indexterm><primary>device nodes</primary></indexterm>
406       <indexterm><primary>I/O port</primary></indexterm>
407       <indexterm><primary>IRQ</primary></indexterm>
408       <indexterm><primary>DSP</primary></indexterm>
409
410       <informaltable>
411         <tgroup cols="2">
412           <thead>
413             <row>
414              <entry>Error</entry>
415               <entry>Solution</entry>
416             </row>
417           </thead>
418
419           <tbody>
420             <row>
421               <entry><errorname>unsupported subdevice XX</errorname></entry>
422               <entry><para>One or more of the device nodes was not created
423                 correctly.  Repeat the steps above.</para></entry>
424             </row>
425
426             <row>
427               <entry><errorname>sb_dspwr(XX) timed out</errorname></entry>
428               <entry><para>The I/O port is not set correctly.</para></entry>
429             </row>
430
431             <row>
432               <entry><errorname>bad irq XX</errorname></entry>
433               <entry><para>The IRQ is set incorrectly.  Make sure that
434                 the set IRQ and the sound IRQ are the same.</para></entry>
435             </row>
436
437             <row>
438               <entry><errorname>xxx: gus pcm not attached, out of memory</errorname></entry>
439               <entry><para>There is not enough available memory to use
440                 the device.</para></entry>
441             </row>
442
443             <row>
444               <entry><errorname>xxx: can't open /dev/dsp!</errorname></entry>
445               <entry><para>Check with <command>fstat | grep dsp</command>
446                 if another application is holding the device open.
447                 Noteworthy troublemakers are <application>esound</application> and <application>KDE</application>'s sound
448                 support.</para></entry>
449             </row>
450           </tbody>
451         </tgroup>
452       </informaltable>
453     </sect3>
454   </sect2>
455
456   <sect2>
457     <sect2info>
458      <authorgroup>
459       <author>
460        <firstname>Munish</firstname>
461        <surname>Chopra</surname>
462        <contrib>Contributed by </contrib>
463       </author>
464      </authorgroup>
465     </sect2info>
466     <title>Utilizing Multiple Sound Sources</title>
467
468     <para>It is often desirable to have multiple sources of sound that
469       are able to play simultaneously, such as when
470       <application>esound</application> or
471       <application>artsd</application> do not support sharing of the
472       sound device with a certain application.</para>
473
474     <para>&os; lets you do this through <emphasis>Virtual Sound
475       Channels</emphasis>, which can be set with the &man.sysctl.8;
476       facility.  Virtual channels allow you to multiplex your sound
477       card's playback channels by mixing sound in the kernel.</para>
478
479     <para>To set the number of virtual channels, there are two sysctl
480       knobs which, if you are the <username>root</username> user, can
481       be set like this:</para>
482     <screen>&prompt.root; <userinput>sysctl hw.snd.pcm0.vchans=4</userinput>
483 &prompt.root; <userinput>sysctl hw.snd.maxautovchans=4</userinput></screen>
484
485     <para>The above example allocates four virtual channels, which is a
486       practical number for everyday use.  <varname>hw.snd.pcm0.vchans</varname>
487       is the number of virtual channels <devicename>pcm0</devicename> has, and is configurable
488       once a device has been attached.
489       <literal>hw.snd.maxautovchans</literal> is the number of virtual channels
490       a new audio device is given when it is attached using
491       &man.kldload.8;.  Since the <devicename>pcm</devicename> module
492       can be loaded independently of the hardware drivers,
493       <varname>hw.snd.maxautovchans</varname> can store how many
494       virtual channels any devices which are attached later will be
495       given.</para>
496
497     <para>If you are not using &man.devfs.5;, you will have to point
498       your applications at <devicename>/dev/dsp0</devicename>.<replaceable>x</replaceable>, where
499       <replaceable>x</replaceable> is 0 to 3 if <varname>hw.snd.pcm.0.vchans</varname> is set
500       to 4 as in the above example.  On a system using &man.devfs.5;, the above will automatically be
501       allocated transparently to the user.</para>
502    </sect2>
503   </sect1>
504
505   <sect1 id="sound-mp3">
506     <sect1info>
507       <authorgroup>
508         <author>
509           <firstname>Chern</firstname>
510           <surname>Lee</surname>
511           <contrib>Contributed by </contrib>
512         </author>
513       </authorgroup>
514       <!-- 11 Sept 2001 -->
515     </sect1info>
516
517     <title>MP3 Audio</title>
518
519     <para>MP3 (MPEG Layer 3 Audio) accomplishes near CD-quality sound,
520       leaving no reason to let your &os; workstation fall short of
521       its offerings.</para>
522
523     <sect2 id="mp3-players">
524       <title>MP3 Players</title>
525
526       <para>A popular X11 MP3 player is
527         <application>XMMS</application> (X Multimedia System).  
528         <application>Winamp</application>
529         skins can be used with <application>XMMS</application> since the
530         GUI is almost identical to that of Nullsoft's 
531         <application>Winamp</application>.
532         <application>XMMS</application> also has native plug-in
533         support.</para>
534
535       <para><application>XMMS</application> can be installed from the
536         <filename role="package">multimedia/xmms</filename> port or package.</para>
537         <!-- todo: reed: under audio category for pkgsrc -->
538
539       <para><application>XMMS'</application> interface is intuitive,
540         with a playlist, graphic equalizer, and more.  Those familiar
541         with <application>Winamp</application> will find
542         <application>XMMS</application> simple to use.</para>
543
544       <para>The <filename role="package">audio/mpg123</filename> port is an alternative,
545         command-line MP3 player.</para>
546
547       <para><application>mpg123</application> can be run by specifying
548         the sound device and the MP3 file on the command line, as
549         shown below:</para>
550
551       <screen>&prompt.root; <userinput>mpg123 -a <replaceable>/dev/dsp1.0</replaceable> Foobar-GreatestHits.mp3</userinput>
552 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.
553 Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp.
554 Uses code from various people. See 'README' for more!
555 THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
556
557
558
559
560
561 Playing MPEG stream from Foobar-GreatestHits.mp3 ...
562 MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo
563 </screen>
564
565       <para><literal>/dev/dsp1.0</literal> should be replaced with the
566         <devicename>dsp</devicename> device entry on your system.</para>
567
568     </sect2>
569
570     <sect2 id="rip-cd">
571       <title>Ripping CD Audio Tracks</title>
572
573       <para>Before encoding a CD or CD track to MP3, the audio data on
574         the CD must be ripped onto the hard drive.  This is done by
575         copying the raw CDDA (CD Digital Audio) data to WAV
576         files.</para>
577
578       <para>The <command>cdda2wav</command> tool, which is a part of
579         the <filename role="package">sysutils/cdrtools</filename>
580         suite, is used for ripping audio information from CDs and the
581         information associated with them.</para>
582         <!-- todo: reed: pkgsrc is still called sysutils/cdrecord -->
583
584       <para>With the audio CD in the drive, the following command can
585         be issued (as <username>root</username>) to rip an entire CD
586         into individual (per track) WAV files:</para>
587
588       <screen>&prompt.root; <userinput>cdda2wav -D <replaceable>0,1,0</replaceable> -B</userinput></screen>
589
590       <para><application>cdda2wav</application> will support
591         ATAPI (IDE) CDROM drives.  To rip from an IDE drive, specify
592         the device name in place of the SCSI unit numbers.  For
593         example, to rip track 7 from an IDE drive:</para>
594
595       <screen>&prompt.root; <userinput>cdda2wav -D <replaceable>/dev/acd0a</replaceable> -t 7</userinput></screen>
596
597       <para>The <option>-D <replaceable>0,1,0</replaceable></option>
598         indicates the SCSI device <devicename>0,1,0</devicename>,
599         which corresponds to the output of <command>cdrecord
600         -scanbus</command>.</para>
601
602       <para>To rip individual tracks, make use of the
603         <option>-t</option> option as shown:</para>
604
605       <screen>&prompt.root; <userinput>cdda2wav -D <replaceable>0,1,0</replaceable> -t 7</userinput></screen>
606
607       <para>This example rips track seven of the audio CDROM.  To rip
608         a range of tracks, for example, track one to seven, specify a
609         range:</para>
610
611       <screen>&prompt.root; <userinput>cdda2wav -D <replaceable>0,1,0</replaceable> -t 1+7</userinput></screen>
612
613       <para>The utility &man.dd.1; can also be used to extract audio tracks
614         on ATAPI drives, read <xref linkend="duplicating-audiocds">
615         for more information on that possibility.</para>
616
617     </sect2>
618
619     <sect2 id="mp3-encoding">
620       <title>Encoding MP3s</title>
621
622       <para>Nowadays, the mp3 encoder of choice is
623         <application>lame</application>.
624         <application>Lame</application> can be found at
625         <filename role="package">audio/lame</filename> in the pkgsrc and ports trees.</para>
626
627       <para>Using the ripped WAV files, the following command will
628         convert <filename>audio01.wav</filename> to
629         <filename>audio01.mp3</filename>:</para>
630
631       <screen>&prompt.root; <userinput>lame -h -b <replaceable>128</replaceable> \
632 --tt "<replaceable>Foo Song Title</replaceable>" \
633 --ta "<replaceable>FooBar Artist</replaceable>" \
634 --tl "<replaceable>FooBar Album</replaceable>" \
635 --ty "<replaceable>2001</replaceable>" \
636 --tc "<replaceable>Ripped and encoded by Foo</replaceable>" \
637 --tg "<replaceable>Genre</replaceable>" \
638 <replaceable>audio01.wav audio01.mp3</replaceable></userinput></screen>
639
640       <para>128&nbsp;kbits seems to be the standard MP3 bitrate in use.
641         Many enjoy the higher quality 160, or 192.  The higher the
642         bitrate, the more disk space the resulting MP3 will
643         consume--but the quality will be higher.  The
644         <option>-h</option> option turns on the <quote>higher quality
645         but a little slower</quote> mode.  The options beginning with
646         <option>--t</option> indicate ID3 tags, which usually contain
647         song information, to be embedded within the MP3 file.
648         Additional encoding options can be found by consulting the
649         lame man page.</para>
650     </sect2>
651
652     <sect2 id="mp3-decoding">
653       <title>Decoding MP3s</title>
654
655       <para>In order to burn an audio CD from MP3s, they must be
656         converted to a non-compressed WAV format.  Both
657         <application>XMMS</application> and
658         <application>mpg123</application> support the output of MP3 to
659         an uncompressed file format.</para>
660
661       <para>Writing to Disk in <application>XMMS</application>:</para>
662
663       <procedure>
664         <step>
665           <para>Launch <application>XMMS</application>.</para>
666         </step>
667
668         <step>
669           <para>Right-click on the window to bring up the
670             <application>XMMS</application> menu.</para>
671         </step>
672
673         <step>
674           <para>Select <literal>Preference</literal> under
675             <literal>Options</literal>.</para>
676         </step>
677
678         <step>
679           <para>Change the Output Plugin to <quote>Disk Writer
680               Plugin</quote>.</para>
681         </step>
682
683         <step>
684           <para>Press <literal>Configure</literal>.</para>
685         </step>
686
687         <step>
688           <para>Enter (or choose browse) a directory to write the
689             uncompressed files to.</para>
690         </step>
691
692         <step>
693           <para>Load the MP3 file into <application>XMMS</application>
694             as usual, with volume at 100% and EQ settings turned
695             off.</para>
696         </step>
697
698         <step>
699           <para>Press <literal>Play</literal> &mdash;
700             <application>XMMS</application> will appear as if it is
701             playing the MP3, but no music will be heard.  It is
702             actually playing the MP3 to a file.</para>
703         </step>
704
705         <step>
706           <para>Be sure to set the default Output Plugin back to what
707             it was before in order to listen to MP3s again.</para>
708         </step>
709       </procedure>
710
711       <para>Writing to stdout in <application>mpg123</application>:</para>
712
713       <procedure>
714         <step>
715           <para>Run <command>mpg123 -s <replaceable>audio01.mp3</replaceable>
716             &gt; audio01.pcm</command></para>
717         </step>
718       </procedure>
719
720       <para><application>XMMS</application> writes a file in the WAV
721         format, while <application>mpg123</application> converts the
722         MP3 into raw PCM audio data.  Both of these formats can be
723         used with <application>cdrecord</application> to create audio CDs.
724         You have to use raw PCM with &man.burncd.8;.
725         If you use WAV files, you will notice a small tick sound at the
726         beginning of each track, this sound is the header of the WAV
727         file.  You can simply remove the header of a WAV file with the
728         utility <application>SoX</application> (it can be installed from
729         the <filename role="package">audio/sox</filename> port or
730         package):</para>
731
732       <screen>&prompt.user; <userinput>sox -t wav -r 44100 -s -w -c 2 <replaceable>track.wav track.raw</replaceable></userinput></screen>
733
734       <para>Read <xref linkend="creating-cds"> for more information on using a
735           CD burner in &os;.</para>
736     </sect2>
737  </sect1>
738
739  <sect1 id="video-playback">
740   <sect1info>
741     <authorgroup>
742       <author>
743         <firstname>Ross</firstname>
744         <surname>Lippert</surname>
745         <contrib>Contributed by </contrib>
746       </author>
747     </authorgroup>
748     <!-- 5 June 2002 -->
749   </sect1info>
750
751   <title>Video Playback</title>
752
753     <para>Video playback is a very new and rapidly developing application
754       area.  Be patient.  Not everything is going to work as smoothly as
755       it did with sound.</para>
756
757     <para>Before you begin, you should know the model of the video
758       card you have and the chip it uses.  While <application>&xfree86;</application> and <application>&xorg;</application> support a
759       wide variety of video cards, fewer give good playback
760       performance.  To obtain a list of extensions supported by the
761       X server using your card use the command &man.xdpyinfo.1; while
762       X11 is running.</para>
763
764     <para>It is a good idea to have a short MPEG file which can be
765       treated as a test file for evaluating various players and
766       options.  Since some DVD players will look for DVD media in
767       <filename>/dev/dvd</filename> by default, or have this device
768       name hardcoded in them, you might find it useful to make
769       symbolic links to the proper devices:</para>
770
771       <screen>&prompt.root; <userinput>ln -sf /dev/acd0c /dev/dvd</userinput>
772 &prompt.root; <userinput>ln -sf /dev/racd0c /dev/rdvd</userinput></screen>
773
774     <para>Additionally, DVD decryption, which requires invoking
775       special DVD-ROM functions, requires write permission on the DVD
776       devices.</para>
777
778     <indexterm>
779       <primary>kernel options</primary>
780       <secondary>options CPU_ENABLE_SSE</secondary>
781     </indexterm>
782     <indexterm>
783       <primary>kernel options</primary>
784       <secondary>options USER_LDT</secondary>
785     </indexterm>
786
787     <para>Some of the packages discussed rely on the following kernel
788       options to build correctly.  Before attempting to build, add
789       these options to the kernel configuration file, build a new kernel, and reboot:</para>
790
791       <programlisting>option CPU_ENABLE_SSE
792 option USER_LDT</programlisting>
793
794     <para>To enhance the shared memory X11 interface, it is
795       recommended that the values of some &man.sysctl.8; variables
796       should be increased:</para>
797
798       <programlisting>kern.ipc.shmmax=67108864
799 kern.ipc.shmall=32768</programlisting>
800
801   <sect2 id="video-interface">
802     <title>Determining Video Capabilities</title>
803
804     <indexterm><primary>XVideo</primary></indexterm>
805     <indexterm><primary>SDL</primary></indexterm>
806     <indexterm><primary>DGA</primary></indexterm>
807
808     <para>There are several possible ways to display video under X11.
809       What will really work is largely hardware dependent.  Each
810       method described below will have varying quality across
811       different hardware.  Secondly, the rendering of video in X11 is
812       a topic receiving a lot of attention lately, and with each
813       version of <application>&xorg;</application> or <application>&xfree86;</application> there may be significant improvement.</para>
814
815     <para>A list of common video interfaces:</para>
816
817     <orderedlist>
818     <listitem>
819       <para>X11: normal X11 output using shared memory.</para>
820     </listitem>
821     <listitem>
822       <para>XVideo: an extension to the X11
823       interface which supports video in any X11 drawable.</para>
824     </listitem>
825     <listitem>
826       <para>SDL: the Simple Directmedia Layer.</para>
827     </listitem>
828     <listitem>
829       <para>DGA: the Direct Graphics Access.</para>
830     </listitem>
831     <listitem>
832       <para>SVGAlib: low level console graphics layer.</para>
833     </listitem>
834     </orderedlist>
835
836     <sect3 id="video-interface-xvideo">
837     <title>XVideo</title>
838
839       <para>Both <application>&xfree86; 4.X</application> and <application>&xorg;</application> have an extension called
840         <emphasis>XVideo</emphasis> (aka Xvideo, aka Xv, aka xv) which
841         allows video to be directly displayed in drawable objects
842         through a special acceleration.  This extension provides very
843         good quality playback even on low-end machines (for example my
844         PIII&nbsp;400&nbsp;Mhz laptop).  Unfortunately, the list of cards in which
845         this feature is supported <quote>out of the box</quote> is
846         currently:</para>
847       
848         <orderedlist>
849         <listitem>
850            <para>3DFX Voodoo 3</para>
851         </listitem>
852         <listitem>
853            <para>&intel; i810 and i815</para>
854         </listitem>
855         <listitem>
856           <para>some S3 chips (such as Savage/IX and Savage/MX)</para>
857         </listitem>
858         </orderedlist>
859
860       <para>If your card is not one of these, do not be disappointed yet.
861       <!-- todo: reed: clean this up -->
862       <application>&xfree86; 4.X</application> adds new xv capabilities with each release
863       <footnote>
864         <para>A popular familiar graphics card with generally very good
865          <application>&xfree86;</application> performance, nVidia, has yet to release the specifications
866          on their XVideo support to the <application>&xfree86;</application> team.  It may be some time
867          before <application>&xfree86;</application> fully support XVideo for these cards.</para>
868       </footnote>.
869       To check whether the extension is running, 
870       use <command>xvinfo</command>:</para>
871
872         <screen>&prompt.user; <userinput>xvinfo</userinput></screen>
873
874       <para>XVideo is supported for your card if the result looks like:</para>
875 <screen>X-Video Extension version 2.2
876 screen #0
877   Adaptor #0: "Savage Streams Engine"
878     number of ports: 1
879     port base: 43
880     operations supported: PutImage 
881     supported visuals:
882       depth 16, visualID 0x22
883       depth 16, visualID 0x23
884     number of attributes: 5
885       "XV_COLORKEY" (range 0 to 16777215)
886               client settable attribute
887               client gettable attribute (current value is 2110)
888       "XV_BRIGHTNESS" (range -128 to 127)
889               client settable attribute
890               client gettable attribute (current value is 0)
891       "XV_CONTRAST" (range 0 to 255)
892               client settable attribute
893               client gettable attribute (current value is 128)
894       "XV_SATURATION" (range 0 to 255)
895               client settable attribute
896               client gettable attribute (current value is 128)
897       "XV_HUE" (range -180 to 180)
898               client settable attribute
899               client gettable attribute (current value is 0)
900     maximum XvImage size: 1024 x 1024
901     Number of image formats: 7
902       id: 0x32595559 (YUY2)
903         guid: 59555932-0000-0010-8000-00aa00389b71
904         bits per pixel: 16
905         number of planes: 1
906         type: YUV (packed)
907       id: 0x32315659 (YV12)
908         guid: 59563132-0000-0010-8000-00aa00389b71
909         bits per pixel: 12
910         number of planes: 3
911         type: YUV (planar)
912       id: 0x30323449 (I420)
913         guid: 49343230-0000-0010-8000-00aa00389b71
914         bits per pixel: 12
915         number of planes: 3
916         type: YUV (planar)
917       id: 0x36315652 (RV16)
918         guid: 52563135-0000-0000-0000-000000000000
919         bits per pixel: 16
920         number of planes: 1
921         type: RGB (packed)
922         depth: 0
923         red, green, blue masks: 0x1f, 0x3e0, 0x7c00
924       id: 0x35315652 (RV15)
925         guid: 52563136-0000-0000-0000-000000000000
926         bits per pixel: 16
927         number of planes: 1
928         type: RGB (packed)
929         depth: 0
930         red, green, blue masks: 0x1f, 0x7e0, 0xf800
931       id: 0x31313259 (Y211)
932         guid: 59323131-0000-0010-8000-00aa00389b71
933         bits per pixel: 6
934         number of planes: 3
935         type: YUV (packed)
936       id: 0x0
937         guid: 00000000-0000-0000-0000-000000000000
938         bits per pixel: 0
939         number of planes: 0
940         type: RGB (packed)
941         depth: 1
942         red, green, blue masks: 0x0, 0x0, 0x0</screen>
943
944     <para>Also note that the formats listed (YUV2, YUV12, etc) are not
945      present with every implementation of XVideo and their absence may
946      hinder some players.</para>
947
948     <para>If the result looks like:</para>
949 <screen>X-Video Extension version 2.2
950 screen #0
951 no adaptors present</screen>
952
953     <para>Then XVideo is probably not supported for your card.</para>
954
955     <para>If XVideo is not supported for your card, this only means
956       that it will be more difficult for your display to meet the
957       computational demands of rendering video.  Depending on your
958       video card and processor, though, you might still be able to
959       have a satisfying experience.  You should probably read about
960       ways of improving performance in the advanced reading <xref
961       linkend="video-further-reading">.</para>
962
963     </sect3>
964
965     <sect3 id="video-interface-SDL">
966     <title>Simple Directmedia Layer</title>
967
968     <para>The Simple Directmedia Layer, SDL, was intended to be a
969       porting layer between &microsoft.windows;, BeOS, and &unix;,
970       allowing cross-platform applications to be developed which made
971       efficient use of sound and graphics.  The SDL layer provides a
972       low-level abstraction to the hardware which can sometimes be
973       more efficient than the X11 interface.</para>
974
975     <para>The SDL can be found at <filename role="package">devel/sdl12</filename> (or <filename role="package">pkgsrc/devel/SDL2</filename>).</para>
976
977     </sect3>
978
979     <sect3 id="video-interface-DGA">
980     <title>Direct Graphics Access</title>
981
982     <para>Direct Graphics Access is an X11 extension which allows
983       a program to bypass the X server and directly alter the
984       framebuffer.  Because it relies on a low level memory mapping to
985       effect this sharing, programs using it must be run as
986       <username>root</username>.</para>
987
988     <para>The DGA extension can be tested and benchmarked by
989       &man.dga.1;.  When <command>dga</command> is running, it
990       changes the colors of the display whenever a key is pressed.  To
991       quit, use <keycap>q</keycap>.</para>
992
993     </sect3>
994
995   </sect2>
996
997   <sect2 id="video-packages">
998     <title>Ports and Packages Dealing with Video</title>
999
1000     <indexterm><primary>video ports</primary></indexterm>
1001     <indexterm><primary>video packages</primary></indexterm>
1002
1003     <para>This section discusses the software available from the
1004       &pkgsrc; and FreeBSD Ports collections which can be used for video playback.
1005       Video playback is a very active area of software development,
1006       and the capabilities of various applications are bound to
1007       diverge somewhat from the descriptions given here.</para>
1008
1009     <para>Firstly, it is important to know that many of the video
1010       applications which run on &os; were developed as Linux
1011       applications.  Many of these applications are still
1012       beta-quality.  Some of the problems that you may encounter with
1013       video packages on &os; include:</para>
1014
1015       <orderedlist>
1016
1017       <listitem>
1018         <para>An application cannot playback a file which another
1019           application produced.</para>
1020       </listitem> 
1021
1022       <listitem>
1023         <para>An application cannot playback a file which the
1024           application itself produced.</para>
1025       </listitem>
1026
1027       <listitem>
1028         <para>The same application on two different machines,
1029           rebuilt on each machine for that machine, plays back the same
1030           file differently.</para>
1031       </listitem>
1032
1033       <listitem>
1034         <para>A seemingly trivial filter like rescaling of the image
1035           size results in very bad artifacts from a buggy rescaling
1036           routine.</para>
1037       </listitem>
1038
1039       <listitem>
1040         <para>An application frequently dumps core.</para>
1041       </listitem>
1042
1043       <listitem>
1044         <para>Documentation is not installed with the port and can be
1045           found either on the web or under the port's <filename role='directory'>work</filename>
1046           directory.</para>
1047       </listitem>
1048
1049       </orderedlist>
1050
1051     <para>Many of these applications may also exhibit
1052       <quote>Linux-isms</quote>.  That is, there may be
1053       issues resulting from the way some standard libraries are
1054       implemented in the Linux distributions, or some features of the
1055       Linux kernel which have been assumed by the authors of the
1056       applications.  These issues are not always noticed and worked around
1057       by the port maintainers, which can lead to problems like
1058       these:</para>
1059        
1060       <orderedlist>
1061
1062       <listitem>
1063         <para>The use of <filename>/proc/cpuinfo</filename> to detect
1064           processor characteristics.</para>
1065       </listitem>
1066
1067       <listitem>
1068         <para>A misuse of threads which causes a program to hang upon
1069           completion instead of truly terminating.</para>
1070       </listitem>
1071
1072       <listitem>
1073         <para>Software not yet in the &pkgsrc; or FreeBSD Ports collections
1074           which is commonly used in conjunction with the application.</para>
1075       </listitem>
1076
1077       </orderedlist>
1078
1079       <para>So far, these application developers have been cooperative with
1080         port maintainers to minimize the work-arounds needed for
1081         port-ing.</para>
1082
1083     <sect3 id="video-mplayer">
1084       <title>MPlayer</title>
1085
1086       <para><application>MPlayer</application> is a recently developed and rapidly developing
1087         video player.  The goals of the <application>MPlayer</application> team are speed and
1088         flexibility on Linux and other Unices.  The project was
1089         started when the team founder got fed up with bad playback
1090         performance on then available players.  Some would say that
1091         the graphical interface has been sacrificed for a streamlined
1092         design.  However, once
1093         you get used to the command line options and the key-stroke
1094         controls, it works very well.</para>
1095
1096       <sect4 id="video-mplayer-building">
1097         <title>Building MPlayer</title>
1098         <indexterm><primary>MPlayer</primary>
1099                    <secondary>making</secondary></indexterm>
1100
1101         <para><application>MPlayer</application> resides in <filename
1102           role="package">multimedia/mplayer</filename>.
1103           <application>MPlayer</application> performs a variety of
1104           hardware checks during the build process, resulting in a
1105           binary which will not be portable from one system to
1106           another.  Therefore, it is important to build it from
1107           ports and not to use a binary package.  Additionally, a
1108           number of options can be specified in the <command>make</command>
1109           command line, as described at the start of the build.</para>
1110           <!-- todo: reed: mention pkgsrc here too -->
1111
1112         <screen>&prompt.root; <userinput>cd /usr/ports/multimedia/mplayer</userinput>
1113 &prompt.root; <userinput>make</userinput>
1114 You can enable additional compilation optimizations
1115 by defining WITH_OPTIMIZED_CFLAGS
1116 You can enable GTK GUI by defining WITH_GUI.
1117 You can enable DVD support by defining WITH_DVD.
1118 You can enable SVGALIB support by defining WITH_SVGALIB.
1119 You can enable VORBIS sound support by defining WITH_VORBIS.
1120 You can enable XAnim DLL support by defining WITH_XANIM.
1121 </screen>
1122
1123         <!-- todo: reed: this is ports specific, could add pkgsrc notes -->
1124         <para>If you have <filename
1125           role="package">x11-toolkits/gtk12</filename> installed, then
1126           you might as well enable the GUI.  Otherwise, it is not
1127           worth the effort.  If you intend to play (possibly CSS
1128           encoded) DVD's with <application>MPlayer</application> you must enable the DVD support
1129           option here <footnote><para>Unauthorized DVD playback is a
1130           serious criminal act in some countries.  Check local laws
1131           before enabling this option.</para> </footnote>.  Some
1132           reasonable options are:</para>
1133
1134         <screen>&prompt.root; <userinput>make WITH_DVD=yes WITH_SVGALIB=yes</userinput></screen>
1135
1136         <para>As of this writing, the <application>MPlayer</application> port will build its HTML
1137           documentation and one executable,
1138           <command>mplayer</command>.  It can also be made to build an
1139           encoder, <command>mencoder</command>, which is a tool for
1140           re-encoding video.  A modification to the
1141           <filename>Makefile</filename> can enable it.  It may be
1142           enabled by default in subsequent versions of the port.</para>
1143
1144         <para>The HTML documentation for <application>MPlayer</application> is very informative.
1145           If the reader finds the information on video hardware and
1146           interfaces in this chapter lacking, the <application>MPlayer</application> documentation
1147           is a very thorough supplement.  You should definitely take
1148           the time to read the <application>MPlayer</application>
1149           documentation if you are looking for information about video
1150           support in &unix;.</para>
1151
1152       </sect4>
1153
1154       <sect4 id="video-mplayer-using">
1155         <title>Using MPlayer</title>
1156         <indexterm><primary>MPlayer</primary>
1157                    <secondary>use</secondary></indexterm>
1158
1159         <para>Any user of <application>MPlayer</application> must set up a
1160           <filename>.mplayer</filename> subdirectory of her
1161           home directory.  To create this necessary subdirectory,
1162           you can type the following:</para>
1163
1164 <screen>&prompt.user; <userinput>cd /usr/ports/multimedia/mplayer</userinput>
1165 &prompt.user; <userinput>make install-user</userinput></screen>
1166
1167         <para>The command options for <command>mplayer</command> are
1168           listed in the manual page.  For even more detail there is HTML
1169           documentation.  In this section, we will describe only a few
1170           common uses.</para>
1171
1172         <para>To play a file, such as
1173           <filename><replaceable>testfile.avi</replaceable></filename>,
1174           through one of the various video interfaces set the
1175           <option>-vo</option> option:</para>
1176
1177           <screen>&prompt.user; <userinput>mplayer -vo xv testfile.avi</userinput></screen>
1178           <screen>&prompt.user; <userinput>mplayer -vo sdl testfile.avi</userinput></screen>
1179           <screen>&prompt.user; <userinput>mplayer -vo x11 testfile.avi</userinput></screen>
1180           <screen>&prompt.root; <userinput>mplayer -vo dga testfile.avi</userinput></screen>
1181           <screen>&prompt.root; <userinput>mplayer -vo 'sdl:dga' testfile.avi</userinput></screen>
1182
1183         <para>It is worth trying all of these options, as their relative
1184           performance depends on many factors and will vary significantly
1185           with hardware.</para>
1186
1187         <para>To play from a DVD, replace the
1188          <filename>testfile.avi</filename> with <option>-dvd <replaceable>N</replaceable>
1189          <replaceable>DEVICE</replaceable></option> where <replaceable>N</replaceable> is
1190          the title number to play and
1191          <filename><replaceable>DEVICE</replaceable></filename> is the
1192          device node for the DVD-ROM.  For example, to play title 3
1193          from <filename>/dev/dvd</filename>:</para>
1194
1195           <screen>&prompt.root; <userinput>mplayer -vo dga -dvd 3 /dev/dvd</userinput></screen>
1196
1197         <para>To stop, pause, advance and so on, consult the
1198           keybindings, which are output by running <command>mplayer
1199           -h</command> or read the manual page.</para>
1200
1201         <para>Additional important options for playback are:
1202           <option>-fs -zoom</option> which engages the fullscreen mode
1203           and <option>-framedrop</option> which helps performance.</para>
1204
1205         <para>In order for the mplayer command line to not become too
1206           large, the user can create a file
1207           <filename>.mplayer/config</filename> and set default options
1208           there:</para>
1209 <programlisting>vo=xv
1210 fs=yes
1211 zoom=yes</programlisting>
1212
1213         <para>Finally, <command>mplayer</command> can be used to rip a
1214           DVD title into a <filename>.vob</filename> file.  To dump
1215           out the second title from a DVD, type this:</para>
1216
1217           <screen>&prompt.root; <userinput>mplayer -dumpstream -dumpfile out.vob -dvd 2 /dev/dvd</userinput></screen>
1218
1219         <para>The output file, <filename>out.vob</filename>, will be
1220           MPEG and can be manipulated by the other packages described
1221           in this section.</para>
1222
1223       </sect4>
1224       <sect4 id="video-mencoder">
1225         <title>mencoder</title>
1226         <indexterm>
1227           <primary>mencoder</primary>
1228         </indexterm>
1229
1230         <para>If you opt to install <command>mencoder</command> when
1231          you build <application>MPlayer</application>, be forewarned
1232          that it is still an experimental component.  Before using 
1233          <command>mencoder</command> it is a good idea to
1234          familiarize yourself with the options from the HTML
1235          documentation.  There is a manual page, but it is not very
1236          useful without the HTML documentation.  There are innumerable ways to
1237          improve quality, lower bitrate, and change formats, and some
1238          of these tricks may make the difference between good
1239          or bad performance.  Here are a couple of examples to get
1240          you going.  First a simple copy:</para>
1241
1242          <screen>&prompt.user; <userinput>mencoder input.avi -oac copy -ovc copy -o output.avi</userinput></screen>
1243
1244          <para>Improper combinations of command line options can yield
1245          output files that are
1246          unplayable even by <command>mplayer</command>.  Thus, if you
1247          just want to rip to a file, stick to the <option>-dumpfile</option>
1248          in <command>mplayer</command>.</para>
1249
1250          <para>To convert <filename>input.avi</filename> to the MPEG4
1251          codec with MPEG3 audio encoding (<filename role="package">audio/lame</filename> is required):</para>
1252
1253          <screen>&prompt.user; <userinput>mencoder input.avi -oac mp3lame -lameopts br=192 \
1254          -ovc lavc -lavcopts vcodec=mpeg4:vhq -o output.avi</userinput></screen>
1255
1256          <para>This has produced output playable by <command>mplayer</command>
1257          and <command>xine</command>.</para>
1258
1259          <para><filename>input.avi</filename> can be replaced with
1260            <option>-dvd 1 /dev/dvd</option> and run as
1261            <username>root</username> to re-encode a DVD title
1262            directly.  Since you are likely to be dissatisfied with
1263            your results the first time around, it is recommended you
1264            dump the title to a file and work on the file.</para>
1265       </sect4>
1266
1267     </sect3>
1268
1269     <sect3 id="video-xine">
1270     <title>The xine Video Player</title>
1271
1272     <para>The <application>xine</application> video player is a project of wide scope aiming not only at being an
1273      all in one video solution, but also in producing a reusable base
1274      library and a modular executable which can be extended with
1275      plugins.  It comes both as a package and as a port, <filename
1276      role="package">multimedia/xine</filename>.</para>
1277
1278     <para>The <application>xine</application> player
1279      is still very rough around the edges, but it is clearly off to a
1280      good start.  In practice, <application>xine</application> requires either a fast CPU with a
1281      fast video card, or support for the XVideo extension.  The GUI is
1282      usable, but a bit clumsy.</para>
1283
1284     <para>As of this writing, there is no input module shipped with
1285      <application>xine</application> which will play CSS encoded DVD's.  There are third party
1286      builds which do have modules for this built in them, but none
1287      of these are in the FreeBSD Ports Collection.</para>
1288      <!-- todo: reed: what about pkgsrc? -->
1289
1290     <para>Compared to <application>MPlayer</application>, <application>xine</application> does more for the user, but at the
1291       same time, takes some of the more fine-grained control away from
1292       the user.  The <application>xine</application> video player
1293       performs best on XVideo interfaces.</para>
1294      
1295     <para>By default, <application>xine</application> player will
1296     start up in a graphical user interface.  The menus can then be
1297     used to open a specific file:</para>
1298
1299       <screen>&prompt.user; <userinput>xine</userinput></screen>
1300
1301     <para>Alternatively, it may be invoked to play a file immediately
1302       without the GUI with the command:</para>
1303
1304       <screen>&prompt.user; <userinput>xine -g -p mymovie.avi</userinput></screen>
1305
1306     </sect3>
1307
1308     <sect3 id="video-packages-transcode">
1309     <title>The transcode Utilities</title>
1310
1311     <para>The software <application>transcode</application> is not a player, but a suite of tools for
1312       re-encoding <filename>.avi</filename> and <filename>.mpg</filename> files.  With <application>transcode</application>, one has the
1313       ability to merge video files, repair broken files, using command
1314       line tools with <filename>stdin/stdout</filename> stream
1315       interfaces.</para>
1316
1317     <para>Like <application>MPlayer</application>, <application>transcode</application> is very experimental software which
1318       must be build from ports or &pkgsrc; at <filename
1319       role="package">multimedia/transcode</filename>.  Using a great
1320       many options to the <command>make</command> command.  I
1321       recommend:</para>
1322
1323       <screen>&prompt.root; <userinput>make WITH_LIBMPEG2=yes</userinput></screen>
1324
1325     <!-- todo: reed: ports specific, add pkgsrc notes? -->
1326     <para>If you plan to install <filename
1327       role="package">multimedia/avifile</filename>, then add the
1328       <literal>WITH_AVIFILE</literal> option to your
1329       <command>make</command> command line, as shown here:</para>
1330
1331       <screen>&prompt.root; <userinput>make WITH_AVIFILE=yes WITH_LIBMPEG2=yes</userinput></screen>
1332
1333     <para>Here are two examples of using <command>transcode</command>
1334       for video conversion which produce rescaled output.  The first
1335       encodes the output to an openDIVX AVI file, while the second
1336       encodes to the much more portable MPEG format.</para>
1337
1338       <screen>&prompt.user; <userinput>transcode -i input.vob -x vob -V -Z 320x240 \
1339 -y opendivx -N 0x55 -o output.avi</userinput></screen>
1340
1341       <screen>&prompt.user; <userinput>transcode -i input.vob -x vob -V -Z 320x240 \
1342 -y mpeg -N 0x55 -o output.tmp</userinput>
1343 &prompt.user; <userinput>tcmplex -o output.mpg -i output.tmp.m1v -p output.tmp.mpa -m 1</userinput></screen>
1344
1345     <para>There is a manual page for <command>transcode</command>, but
1346       there is little documentation for the various <command>tc*</command> utilities (such as
1347       <command>tcmplex</command>) which are also installed.
1348       However, the <option>-h</option> command line option can
1349       always be given to get curt usage instructions for a
1350       command.</para>
1351
1352     <para>In comparison, <command>transcode</command> runs
1353       significantly slower than <command>mencoder</command>, but it
1354       has a better chance of producing a more widely playable file.
1355       MPEGs created by <command>transcode</command> have been known to
1356       play on
1357       <application>&windows.media; Player</application> and Apple's <application>&quicktime;</application>, for example.</para>
1358
1359     </sect3>
1360
1361   </sect2>
1362
1363   <sect2 id="video-further-reading">
1364     <title>Further Reading</title>
1365
1366     <para>The various video software packages for &os; are
1367       developing rapidly.  It is quite possible that in the near
1368       future many of the problems discussed here will have been
1369       resolved.  In the mean time, those who
1370      want to get the very most out of &os;'s A/V capabilities will
1371      have to cobble together knowledge from several FAQs and tutorials
1372      and use a few different applications.  This section exists to
1373       give the reader pointers to such additional information.</para>
1374
1375     <para>The 
1376       <ulink url="http://www.mplayerhq.hu/DOCS/">MPlayer documentation</ulink>
1377       is very technically informative.
1378       These documents should probably be consulted by anyone wishing
1379       to obtain a high level of expertise with &unix; video.  The
1380       <application>MPlayer</application> mailing list is hostile to anyone who has not bothered
1381       to read the documentation, so if you plan on making bug reports
1382       to them, RTFM.</para>
1383
1384     <para>The
1385       <ulink url="http://dvd.sourceforge.net/xine-howto/en_GB/html/howto.html">      xine HOWTO</ulink>
1386       contains a chapter on performance improvement
1387       which is general to all players.</para>
1388
1389     <para>Finally, there are some other promising applications which
1390     the reader may try:</para>
1391
1392     <itemizedlist>
1393
1394        <listitem>
1395          <para><ulink
1396            url="http://avifile.sourceforge.net/">Avifile</ulink> which
1397            is also a port <filename
1398            role='package'>multimedia/avifile</filename>.</para>
1399        </listitem>
1400        <!-- todo: reed: in pkgsrc-wip currently -->
1401
1402        <listitem>
1403          <para><ulink
1404            url="http://www.dtek.chalmers.se/groups/dvd/">Ogle</ulink>
1405            which is also a port <filename
1406            role='package'>multimedia/ogle</filename>.</para>
1407        </listitem>
1408
1409        <listitem>
1410          <para><ulink url="http://xtheater.sourceforge.net/">Xtheater</ulink></para>
1411        </listitem>
1412
1413         <listitem>
1414          <para><filename
1415            role="package">multimedia/dvdauthor</filename>, an open
1416            source package for authoring DVD content.</para>
1417         </listitem>
1418
1419     </itemizedlist>
1420
1421   </sect2>
1422  </sect1>
1423
1424   <sect1 id="tvcard">
1425     <sect1info>
1426       <authorgroup>
1427         <author>
1428           <firstname>Josef</firstname>
1429           <surname>El-Rayes</surname>
1430           <contrib>Original contribution by </contrib>
1431         </author>
1432       </authorgroup>
1433       <authorgroup>
1434         <author>
1435           <firstname>Marc</firstname>
1436           <surname>Fonvieille</surname>
1437           <contrib>Enhanced and adapted by </contrib>
1438           <!-- 02 January 2004 -->
1439         </author>
1440       </authorgroup>
1441     </sect1info>
1442
1443     <title>Setting Up TV Cards</title>
1444     <indexterm>
1445       <primary>TV cards</primary>
1446     </indexterm>
1447
1448     <sect2>
1449       <title>Introduction</title>
1450
1451       <para>TV cards allow you to watch broadcast or cable TV on your
1452         computer.  Most of them accept composite video via an RCA or
1453         S-video input and some of these cards come with a FM
1454         radio tuner.</para>
1455
1456       <para>&os; provides support for PCI-based TV cards using a
1457         Brooktree Bt848/849/878/879 or a Conexant CN-878/Fusion 878a
1458         Video Capture Chip with the &man.bktr.4; driver.  You must
1459         also ensure the board comes with a supported tuner, consult
1460         the &man.bktr.4; manual page for a list of supported
1461         tuners.</para>
1462     </sect2>
1463
1464     <sect2>
1465       <title>Adding the Driver</title>
1466
1467       <para>To use your card, you will need to load the &man.bktr.4;
1468         driver, this can be done by adding the following line to the
1469         <filename>/boot/loader.conf</filename> file like this:</para>
1470
1471       <programlisting>bktr_load="YES"</programlisting>
1472
1473       <para>Alternatively, you may statically compile the support for
1474         the TV card in your kernel, in that case add the following
1475         lines to your kernel configuration:</para>
1476         
1477       <programlisting>device     bktr
1478 device  iicbus
1479 device  iicbb
1480 device  smbus</programlisting>
1481
1482       <para>These additional device drivers are necessary because of the
1483         card components being interconnected via an I2C bus.  Then build
1484         and install a new kernel.</para>
1485
1486       <para>Once the support was added to your system, you have to
1487         reboot your machine.  During the boot process, your TV card
1488         should show up, like this:</para>
1489
1490       <programlisting>bktr0: &lt;BrookTree 848A&gt; mem 0xd7000000-0xd7000fff irq 10 at device 10.0 on pci0
1491 iicbb0: &lt;I2C bit-banging driver&gt; on bti2c0
1492 iicbus0: &lt;Philips I2C bus&gt; on iicbb0 master-only
1493 iicbus1: &lt;Philips I2C bus&gt; on iicbb0 master-only
1494 smbus0: &lt;System Management Bus&gt; on bti2c0
1495 bktr0: Pinnacle/Miro TV, Philips SECAM tuner.</programlisting>
1496
1497       <para>Of course these messages can differ according to your
1498         hardware.  However you should check if the tuner is correctly
1499         detected; it is still possible to override some of the
1500         detected parameters with &man.sysctl.8; MIBs and kernel
1501         configuration file options.  For example, if you want to force
1502         the tuner to a Philips SECAM tuner, you should add the
1503         following line to your kernel configuration file:</para>
1504
1505       <programlisting>options OVERRIDE_TUNER=6</programlisting>
1506
1507       <para>or you can directly use &man.sysctl.8;:</para>
1508
1509       <screen>&prompt.root; <userinput>sysctl hw.bt848.tuner=6</userinput></screen>
1510
1511       <para>See the &man.bktr.4; manual page and the
1512         <filename>/usr/src/sys/i386/conf/LINT</filename> file for more
1513         details on the available options. </para>
1514     </sect2>
1515
1516     <sect2>
1517       <title>Useful Applications</title>
1518
1519       <para>To use your TV card you need to install one of the
1520         following applications:</para>
1521
1522       <itemizedlist>
1523         <listitem>
1524           <para><filename role="package">multimedia/fxtv</filename>
1525             provides TV-in-a-window and image/audio/video capture
1526             capabilities.</para>
1527         </listitem>
1528         <listitem>
1529           <para><filename role="package">multimedia/xawtv</filename>
1530             is also a TV application, with the same features as
1531             <application>fxtv</application>.</para>
1532         </listitem>
1533         <listitem>
1534           <para><filename role="package">misc/alevt</filename>
1535             (or <filename role="package">pkgsrc/multimedia/alevt</filename>) decodes
1536             and displays Videotext/Teletext.</para>
1537         </listitem>
1538         <listitem>
1539           <para><filename role="package">audio/xmradio</filename>, an
1540             application to use the FM radio tuner coming with some
1541             TV cards.</para>
1542         </listitem>
1543         <listitem>
1544           <para><filename role="package">audio/wmtune</filename>, a handy
1545             desktop application for radio tuners.</para>
1546             <!-- todo: reed: not in pkgsrc? -->
1547         </listitem>
1548       </itemizedlist>
1549
1550       <para>More applications are available in the &pkgsrc; and FreeBSD Ports
1551         collections.</para>
1552     </sect2>
1553
1554     <sect2>
1555       <title>Troubleshooting</title>
1556
1557       <para>If you encounter any problem with your TV card, you should
1558         check at first if the video capture chip and the tuner are
1559         really supported by the &man.bktr.4; driver and if you used the right
1560         configuration options.  For more support and various questions
1561         about your TV card you may want to contact and use the
1562         archives of the &a.multimedia.name; mailing list.</para>
1563     </sect2>
1564   </sect1>
1565 </chapter>
1566
1567 <!--
1568      Local Variables:
1569      mode: sgml
1570      sgml-declaration: "../chapter.decl"
1571      sgml-indent-data: t
1572      sgml-omittag: nil
1573      sgml-always-quote-attributes: t
1574      sgml-parent-document: ("../book.sgml" "part" "chapter")
1575      End:
1576 -->