aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/handbook/multimedia/chapter.xml
blob: 529bd216e4368ef28c116555f69c3aa3eaaa3893 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
     The FreeBSD Documentation Project

     $FreeBSD$
-->

<chapter id="multimedia">
  <chapterinfo>
    <authorgroup>
      <author>
	<firstname>Ross</firstname>
	<surname>Lippert</surname>
	<contrib>Edited by </contrib>
      </author>
    </authorgroup>
  </chapterinfo>

  <title>Multimedia</title>

  <sect1 id="multimedia-synopsis">
    <title>Synopsis</title>

    <para>&os; supports a wide variety of sound cards, allowing users
      to enjoy high fidelity output from a &os; system.  This includes
      the ability to record and playback audio in the MPEG Audio Layer
      3 (<acronym>MP3</acronym>), Waveform Audio File
      (<acronym>WAV</acronym>), Ogg Vorbis, and other formats.  The
      &os; Ports Collection contains many applications for editing
      recorded audio, adding sound effects, and controlling attached
      MIDI devices.</para>

    <para>&os; also supports the playback of video files and DVDs.
      The &os; Ports Collection contains applications to encode,
      convert, and playback various video media.</para>

    <para>This chapter describes how to configure sound cards, video
      playback, TV tuner cards, and scanners on &os;.  It also
      describes some of the applications which are available for
      using these devices.</para>

    <para>After reading this chapter, you will know how to:</para>

    <itemizedlist>
      <listitem>
	<para>Configure a sound card on os;.</para>
      </listitem>

      <listitem>
	<para>Troubleshoot the sound setup.</para>
      </listitem>

      <listitem>
	<para>Playback and encode MP3s and other audio.</para>
      </listitem>

      <listitem>
	<para>Prepare a &os; system for video playback.</para>
      </listitem>

      <listitem>
	<para>Playback DVDs, <filename>.mpg</filename>, and
	  <filename>.avi</filename> files.</para>
      </listitem>

      <listitem>
	<para>Rip CD and DVD content into files.</para>
      </listitem>

      <listitem>
	<para>Configure a TV card.</para>
      </listitem>

      <listitem>
	<para>Install and setup MythTV on &os;</para>
      </listitem>

      <listitem>
	<para>Configure an image scanner.</para>
      </listitem>

      <listitem>
	<para>How to configure an image scanner.</para>
      </listitem>
    </itemizedlist>

    <para>Before reading this chapter, you should:</para>

    <itemizedlist>
      <listitem><para>Know how to configure and install a new kernel
	(<xref linkend="kernelconfig"/>).</para></listitem>
    </itemizedlist>

    <warning>
      <para>Audio CDs have specialized encodings which differ from the
	usual ISO-filesystem.  This means that they should not be
	mounted using &man.mount.8;.</para>
    </warning>

  </sect1>

  <sect1 id="sound-setup">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Moses</firstname>
	  <surname>Moore</surname>
	  <contrib>Contributed by </contrib>
	  <!-- 20 November 2000 -->
	</author>
      </authorgroup>
      <authorgroup>
	<author>
	  <firstname>Marc</firstname>
	  <surname>Fonvieille</surname>
	  <contrib>Enhanced by </contrib>
	  <!-- 13 September 2004 -->
	</author>
      </authorgroup>
    </sect1info>

    <title>Setting Up the Sound Card</title>

    <sect2 id="sound-device">
      <title>Configuring the System</title>

      <indexterm><primary>PCI</primary></indexterm>
      <indexterm><primary>sound cards</primary></indexterm>
      <para>Before beginning the configuration, determine the model of
	the sound card and the chip it uses.  &os; supports a wide
	variety of sound cards.  Check the supported audio devices
	list of the <ulink url="&rel.current.hardware;">Hardware
	  Notes</ulink> to see if the card is supported and which &os;
	driver it uses.</para>

      <indexterm>
	<primary>kernel</primary>
	<secondary>configuration</secondary>
      </indexterm>

      <para>In order to use the sound device, the proper device driver
	must be loaded.  This may be accomplished in one of two ways.
	The easiest way is to load a kernel module for the sound card
	with &man.kldload.8;.  This example loads the driver for a
	Creative &soundblaster; Live! sound card:</para>

    <screen>&prompt.root; <userinput>kldload snd_emu10k1</userinput></screen>

    <para>To automate the loading of this driver at boot time, add the
      driver to <filename>/boot/loader.conf</filename>. The line for
      this driver is:</para>

    <programlisting>snd_emu10k1_load="YES"</programlisting>

    <para>Other available sound modules are listed in
      <filename>/boot/defaults/loader.conf</filename>.  When unsure
      which driver to use, load the <filename>snd_driver</filename>
      module:</para>

    <screen>&prompt.root; <userinput>kldload snd_driver</userinput></screen>

    <para>This is a metadriver which loads all of the most common
      sound drivers and can be used to speed up the search for the
      correct driver.  It is also possible to load all sound drivers
      by adding the metadriver to
      <filename>/boot/loader.conf</filename>.</para>

    <para>To determine which driver was selected for the sound card
      after loading the <filename>snd_driver</filename> metadriver,
      type <command>cat /dev/sndstat</command>.</para>

    <para>Users who prefer to statically compile in support for the
      sound card in a custom kernel should refer to the instructions
      in the next section.  For more information about recompiling a
      kernel, refer to <xref linkend="kernelconfig"/>.</para>

  <sect3>
    <title>Configuring a Custom Kernel with Sound Support</title>

    <para>When using a custom kernel to provide sound support, make
      sure that the audio framework driver exists in the custom kernel
      configuration file:</para>

    <programlisting>device sound</programlisting>

    <para>Next, add support for the sound card.  Therefore, you need
      to know which driver supports the card.  To continue the example
      of the Creative &soundblaster; Live! sound card from the
      previous section, use the following line in the custom kernel
      configuration file:</para>

      <programlisting>device snd_emu10k1</programlisting>

      <para>Be sure to read the manual page of the driver for the
	syntax to use.  The explicit syntax for the kernel
	configuration of every supported sound driver can also be
	found in <filename>/usr/src/sys/conf/NOTES</filename>.</para>

      <para>Non-PnP ISA sound cards may require the IRQ and I/O port
	settings of the card to be added to
	<filename>/boot/device.hints</filename>.  During the boot
	process, &man.loader.8; reads this file and passes the
	settings to the kernel.  For example, an old Creative
	&soundblaster; 16 ISA non-PnP card will use the
	&man.snd.sbc.4; driver in conjunction with
	<literal>snd_sb16</literal>.  For this card, the following
	lines must be added to the kernel configuration file:</para>

      <programlisting>device snd_sbc
device snd_sb16</programlisting>

      <para>If the card uses the <literal>0x220</literal> I/O port and
	IRQ <literal>5</literal>, these lines must also be added to
	<filename>/boot/device.hints</filename>:</para>

      <programlisting>hint.sbc.0.at="isa"
hint.sbc.0.port="0x220"
hint.sbc.0.irq="5"
hint.sbc.0.drq="1"
hint.sbc.0.flags="0x15"</programlisting>

      <para>In this case, the card uses the <literal>0x220</literal>
	I/O port and the IRQ <literal>5</literal>.</para>

      <para>The syntax used in
	<filename>/boot/device.hints</filename> is described in
	&man.sound.4; and the manual page for the driver of the sound
	card.</para>

      <para>The settings shown above are the defaults.  In some
	cases, the IRQ or other settings may need to be changed to
	match the card.  Refer to &man.snd.sbc.4; for more information
	about this card.</para>
    </sect3>
  </sect2>

  <sect2 id="sound-testing">
    <title>Testing the Sound Card</title>

    <para>After rebooting into the custom kernel, or after loading
      the required module, the sound card should appear in the system
      message buffer.  Run &man.dmesg.8; and look for a message
	like:</para>

    <screen>pcm0: &lt;Intel ICH3 (82801CA)&gt; port 0xdc80-0xdcbf,0xd800-0xd8ff irq 5 at device 31.5 on pci0
pcm0: [GIANT-LOCKED]
pcm0: &lt;Cirrus Logic CS4205 AC97 Codec&gt;</screen>

    <para>The status of the sound card may also be checked using this
      command:</para>

    <screen>&prompt.root; <userinput>cat /dev/sndstat</userinput>
FreeBSD Audio Driver (newpcm)
Installed devices:
pcm0: &lt;Intel ICH3 (82801CA)&gt; at io 0xd800, 0xdc80 irq 5 bufsz 16384
kld snd_ich (1p/2r/0v channels duplex default)</screen>

    <para>The output may vary between systems.  If no
      <devicename>pcm</devicename> devices are listed, go back and
      review the kernel configuration file and make sure the correct
      device driver was chosen.  Common problems are listed in <xref
	linkend="troubleshooting"/>.</para>

    <para>If all goes well, the sound card should now work in os;.  If
      the CD-ROM or DVD-ROM drive's audio-out pins are properly
      connected to the sound card, one can insert an audio CD in the
      drive and play it with &man.cdcontrol.1;:</para>

      <screen>&prompt.user; <userinput>cdcontrol -f /dev/acd0 play 1</userinput></screen>

    <para>Various applications, such as <filename
	role="package">audio/workman</filename> provide a friendlier
      interface.  The <filename role="package">audio/mpg123</filename>
      port can be installed to listen to MP3 audio files.</para>

    <para>Another quick way to test the card is to send data to
      <filename>/dev/dsp</filename>:</para>

    <screen>&prompt.user; <userinput>cat <replaceable>filename</replaceable> &gt; /dev/dsp</userinput></screen>

    <para>where
      <filename><replaceable>filename</replaceable></filename> can
      be any file.  This command should produce some noise, confirming
      that the sound card is actually working.</para>

    <note>
      <para>The <devicename>/dev/dsp*</devicename> device nodes will
	be created automatically as needed.  When not in use, they
	do not exist and will not appear in the output of
	&man.ls.1;.</para>
    </note>

    <para>Sound card mixer levels can be changed using &man.mixer.8;.
      More details can be found in &man.mixer.8;.</para>

    <sect3 id="troubleshooting">
      <title>Common Problems</title>

      <indexterm><primary>device nodes</primary></indexterm>
      <indexterm><primary>I/O port</primary></indexterm>
      <indexterm><primary>IRQ</primary></indexterm>
      <indexterm><primary>DSP</primary></indexterm>

      <informaltable frame="none" pgwide="1">
	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>Error</entry>
	      <entry>Solution</entry>
	    </row>
	  </thead>

	  <tbody>
	    <row>
	      <entry><errorname>sb_dspwr(XX) timed
		  out</errorname></entry>
	      <entry><para>The I/O port is not set
		correctly.</para></entry>
	    </row>

	    <row>
	      <entry><errorname>bad irq XX</errorname></entry>
	      <entry><para>The IRQ is set incorrectly.  Make sure
		that the set IRQ and the sound IRQ are the
		same.</para></entry>
	    </row>

	    <row>
	      <entry><errorname>xxx: gus pcm not attached, out of
		  memory</errorname></entry>
	      <entry><para>There is not enough available memory to
		use the device.</para></entry>
	    </row>

	    <row>
	      <entry><errorname>xxx: can't open
		  /dev/dsp!</errorname></entry>
	      <entry><para>Check with <command>fstat | grep
		  dsp</command> if another application is holding the
		device open.  Noteworthy troublemakers are
		<application>esound</application> and
		<application>KDE</application>'s sound
		support.</para></entry>
	    </row>
	  </tbody>
	</tgroup>
      </informaltable>

      <para>Another issue is that modern graphics cards often come
	with their own sound driver, for use with
	<acronym>HDMI</acronym> and similar.  This sound device will
	sometimes be enumerated before the sound card and the sound
	card will subsequently not be used as the default playback
	device.  To check if this is the case, run
	<application>dmesg</application> and look for
	<literal>pcm</literal>.  The output looks something like
	this:</para>

      <programlisting>...
hdac0: HDA Driver Revision: 20100226_0142
hdac1: HDA Driver Revision: 20100226_0142
hdac0: HDA Codec #0: NVidia (Unknown)
hdac0: HDA Codec #1: NVidia (Unknown)
hdac0: HDA Codec #2: NVidia (Unknown)
hdac0: HDA Codec #3: NVidia (Unknown)
pcm0: &lt;HDA NVidia (Unknown) PCM #0 DisplayPort&gt; at cad 0 nid 1 on hdac0
pcm1: &lt;HDA NVidia (Unknown) PCM #0 DisplayPort&gt; at cad 1 nid 1 on hdac0
pcm2: &lt;HDA NVidia (Unknown) PCM #0 DisplayPort&gt; at cad 2 nid 1 on hdac0
pcm3: &lt;HDA NVidia (Unknown) PCM #0 DisplayPort&gt; at cad 3 nid 1 on hdac0
hdac1: HDA Codec #2: Realtek ALC889
pcm4: &lt;HDA Realtek ALC889 PCM #0 Analog&gt; at cad 2 nid 1 on hdac1
pcm5: &lt;HDA Realtek ALC889 PCM #1 Analog&gt; at cad 2 nid 1 on hdac1
pcm6: &lt;HDA Realtek ALC889 PCM #2 Digital&gt; at cad 2 nid 1 on hdac1
pcm7: &lt;HDA Realtek ALC889 PCM #3 Digital&gt; at cad 2 nid 1 on hdac1
...</programlisting>

      <para>Here the graphics card (<literal>NVidia</literal>) has
	been enumerated before the sound card (<literal>Realtek
	ALC889</literal>).  To use the sound card as the default
	playback device, change <varname>hw.snd.default_unit</varname>
	to the unit that should be used for playback:</para>

      <screen>&prompt.root; <userinput>sysctl hw.snd.default_unit=<replaceable>n</replaceable></userinput></screen>

      <para>Here, <literal>n</literal> is the number of the sound
	device to use.  In this example, it should be
	<literal>4</literal>.  Make this change permanent by adding
	the following line to
	<filename>/etc/sysctl.conf</filename>:</para>

      <programlisting>hw.snd.default_unit=<replaceable>4</replaceable></programlisting>
    </sect3>
  </sect2>

  <sect2 id="sound-multiple-sources">
    <sect2info>
      <authorgroup>
	<author>
	  <firstname>Munish</firstname>
	  <surname>Chopra</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
    </sect2info>
    <title>Utilizing Multiple Sound Sources</title>

    <para>It is often desirable to have multiple sources of sound that
      are able to play simultaneously.  &os; uses <emphasis>Virtual
	Sound Channels</emphasis>, which can be enabled using
      &man.sysctl.8;.  Virtual channels allow one to multiplex the
      sound card's playback by mixing sound in the kernel.</para>

    <para>To set the number of virtual channels, three
      &man.sysctl.8; knobs are available:</para>

    <screen>&prompt.root; <userinput>sysctl dev.pcm.0.play.vchans=4</userinput>
&prompt.root; <userinput>sysctl dev.pcm.0.rec.vchans=4</userinput>
&prompt.root; <userinput>sysctl hw.snd.maxautovchans=4</userinput></screen>

    <para>The above example allocates four virtual channels, which
      is a practical number for everyday use.  Both
      <varname>dev.pcm.0.play.vchans=4</varname> and
      <varname>dev.pcm.0.rec.vchans=4</varname> are the number of
      virtual channels <devicename>pcm0</devicename> has for playback
      and recording, and are configurable after a device has been
      attached.  <literal>hw.snd.maxautovchans</literal> is the number
      of virtual channels a new audio device is given when it is
      attached using &man.kldload.8;.  Since the
      <devicename>pcm</devicename> module can be loaded independently
      of the hardware drivers, <varname>hw.snd.maxautovchans</varname>
      indicates how many virtual channels will be given to devices
      when they are attached. Refer to &man.pcm.4; for more
      information.</para>

    <note>
      <para>The number of virtual channels for a device cannot be
	changed while it is in use.  First, close any programs using
	the device, such as music players or sound daemons.</para>
    </note>

    <para>
      The correct <devicename>pcm</devicename> device will
      automatically be allocated transparently to a program that
      requests <filename>/dev/dsp0</filename>.</para>
  </sect2>

  <sect2>
    <sect2info>
      <authorgroup>
	<author>
	  <firstname>Josef</firstname>
	  <surname>El-Rayes</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
    </sect2info>

    <title>Setting Default Values for Mixer Channels</title>

    <para>The default values for the different mixer channels are
      hardcoded in the source code of the &man.pcm.4; driver.  There
      are many different applications and daemons that allow values to
      be set for the mixer that are remembered between invocations,
      but this is not a clean solution.  It is possible to set default
      mixer values at the driver level.  This is accomplished by
      defining the appropriate values in
      <filename>/boot/device.hints</filename>, as seen in this
      example:</para>

    <programlisting>hint.pcm.0.vol="50"</programlisting>

    <para>This will set the volume channel to a default value of
      <literal>50</literal> when the &man.pcm.4; module is
      loaded.</para>
  </sect2>
</sect1>

<sect1 id="sound-mp3">
  <sect1info>
    <authorgroup>
      <author>
	<firstname>Chern</firstname>
	<surname>Lee</surname>
	<contrib>Contributed by </contrib>
      </author>
    </authorgroup>
    <!-- 11 Sept 2001 -->
  </sect1info>

    <title>MP3 Audio</title>

    <para>This section describes some <acronym>MP3</acronym>
      players available for &os;, how to rip audio CD tracks, and
      how to encode and decode <acronym>MP3</acronym>s.</para>

    <sect2 id="mp3-players">
      <title>MP3 Players</title>

      <para>A popular graphical <acronym>MP3</acronym> player is
	<application>XMMS</application>.
	<application>Winamp</application>
	skins can be used with <application>XMMS</application> since
	the interface is almost identical to that of Nullsoft's
	<application>Winamp</application>.
	<application>XMMS</application> also has native plug-in
	support.</para>

      <para><application>XMMS</application> can be installed from
	the <filename role="package">multimedia/xmms</filename> port
	or package.</para>

      <para><application>XMMS</application>'s interface is intuitive,
	with a playlist, graphic equalizer, and more.  Those familiar
	with <application>Winamp</application> will find
	<application>XMMS</application> simple to use.</para>

      <para>The <filename role="package">audio/mpg123</filename> port
	provides an alternative, command-line <acronym>MP3</acronym>
	player.</para>

      <para><application>mpg123</application> can be run by specifying
	the sound device and the <acronym>MP3</acronym> file on the
	command line.  Assuming the audio device is
	<devicename>/dev/dsp1.0</devicename> and the
	<acronym>MP3</acronym> file is
	<replaceable>Foobar-GreatestHits.mp3</replaceable>, enter the
	following to play the file:</para>

      <screen>&prompt.root; <userinput>mpg123 -a <devicename>/dev/dsp1.0</devicename> <replaceable>Foobar-GreatestHits.mp3</replaceable></userinput>
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.
Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp.
Uses code from various people. See 'README' for more!
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!





Playing MPEG stream from Foobar-GreatestHits.mp3 ...
MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo</screen>
    </sect2>

    <sect2 id="rip-cd">
      <title>Ripping CD Audio Tracks</title>

      <para>Before encoding a CD or CD track to
	<acronym>MP3</acronym>, the audio data on the CD must be
	ripped to the hard drive.  This is done by copying the raw CD
	Digital Audio (<acronym>CDDA</acronym>) data to
	<acronym>WAV</acronym> files.</para>

      <para>The <command>cdda2wav</command> tool, which is installed
	with the <filename role="package">sysutils/cdrtools</filename>
	suite, is used for ripping audio information from CDs and the
	information associated with them.</para>

      <para>With the audio CD in the drive, the following command can
	be issued as <username>root</username> to rip an entire CD
	into individual (per track) <acronym>WAV</acronym>
	files:</para>

      <screen>&prompt.root; <userinput>cdda2wav -D <replaceable>0,1,0</replaceable> -B</userinput></screen>

      <para>The <option>-D <replaceable>0,1,0</replaceable></option>
	indicates the SCSI device <devicename>0,1,0</devicename>,
	which corresponds to the output of <command>cdrecord
	  -scanbus</command>.</para>

      <para><application>cdda2wav</application> will support ATAPI
	(IDE) CDROM drives.  To rip from an IDE drive, specify the
	device name in place of the SCSI unit numbers.  For example,
	to rip track 7 from an IDE drive:</para>

      <screen>&prompt.root; <userinput>cdda2wav -D <replaceable>/dev/acd0</replaceable> -t 7</userinput></screen>

      <para>To rip individual tracks, make use of the
	<option>-t</option> as shown:</para>

      <screen>&prompt.root; <userinput>cdda2wav -D <replaceable>0,1,0</replaceable> -t 7</userinput></screen>

      <para>This example rips track seven of the audio CDROM.  To rip
	a range of tracks, such as track one to seven, specify a
	range:</para>

      <screen>&prompt.root; <userinput>cdda2wav -D <replaceable>0,1,0</replaceable> -t 1+7</userinput></screen>

      <para>&man.dd.1; can also be used to extract audio tracks on
	ATAPI drives, as described in <xref
	  linkend="duplicating-audiocds"/>.</para>

    </sect2>

    <sect2 id="mp3-encoding">
      <title>Encoding MP3s</title>

      <para>
	<application>Lame</application> is a popular
	<acronym>MP3</acronym> encoder which can be installed from the
	<filename role="package">audio/lame</filename> port.  Due to
	licensing restrictions, a package is not available.</para>

      <para>The following command will convert the ripped
	<acronym>WAV</acronym> files
	<filename><replaceable>audio01.wav</replaceable></filename>
	to
	<filename><replaceable>audio01.mp3</replaceable></filename>:</para>

      <screen>&prompt.root; <userinput>lame -h -b <replaceable>128</replaceable> \
--tt "<replaceable>Foo Song Title</replaceable>" \
--ta "<replaceable>FooBar Artist</replaceable>" \
--tl "<replaceable>FooBar Album</replaceable>" \
--ty "<replaceable>2001</replaceable>" \
--tc "<replaceable>Ripped and encoded by Foo</replaceable>" \
--tg "<replaceable>Genre</replaceable>" \
<replaceable>audio01.wav audio01.mp3</replaceable></userinput></screen>

      <para>128&nbsp;kbits is a standard <acronym>MP3</acronym>
	bitrate.  The 160 and 192 bitrates provide higher quality.
	The higher the bitrate, the larger the size of the resulting
	<acronym>MP3</acronym>.  <option>-h</option> turns on the
	<quote>higher quality but a little slower</quote> mode.  The
	options beginning with <option>--t</option> indicate ID3 tags,
	which usually contain song information, to be embedded within
	the <acronym>MP3</acronym> file.  Additional encoding options
	can be found in the <application>lame</application> manual
	page.</para>
    </sect2>

    <sect2 id="mp3-decoding">
      <title>Decoding MP3s</title>

      <para>In order to burn an audio CD from <acronym>MP3</acronym>s,
	they must first be converted to a non-compressed
	<acronym>WAV</acronym> format.  Both
	<application>XMMS</application> and
	<application>mpg123</application> support the output of
	<acronym>MP3</acronym> to an uncompressed file format.</para>

      <para>Writing to Disk in <application>XMMS</application>:</para>

      <procedure>
	<step>
	  <para>Launch <application>XMMS</application>.</para>
	</step>

	<step>
	  <para>Right-click the window to bring up the
	    <application>XMMS</application> menu.</para>
	</step>

	<step>
	  <para>Select <literal>Preferences</literal> under
	    <literal>Options</literal>.</para>
	</step>

	<step>
	  <para>Change the Output Plugin to <quote>Disk Writer
	      Plugin</quote>.</para>
	</step>

	<step>
	  <para>Press <literal>Configure</literal>.</para>
	</step>

	<step>
	  <para>Enter or browse to a directory to write the
	    uncompressed files to.</para>
	</step>

	<step>
	  <para>Load the <acronym>MP3</acronym> file into
	    <application>XMMS</application> as usual, with volume at
	    100% and EQ settings turned off.</para>
	</step>

	<step>
	  <para>Press <literal>Play</literal>.  The
	    <application>XMMS</application> will appear as if it is
	    playing the <acronym>MP3</acronym>, but no music will be
	    heard.  It is actually playing the <acronym>MP3</acronym>
	    to a file.</para>
	</step>

	<step>
	  <para>When finished, be sure to set the default Output
	    Plugin back to what it was before in order to listen to
	    <acronym>MP3</acronym>s again.</para>
	</step>
      </procedure>

      <para>Writing to stdout in
	<application>mpg123</application>:</para>

      <procedure>
	<step>
	  <para>Run <command>mpg123 -s
	      <replaceable>audio01.mp3</replaceable> &gt;
	      <replaceable>audio01.pcm</replaceable></command></para>
	</step>
      </procedure>

      <para><application>XMMS</application> writes a file in the
	<acronym>WAV</acronym> format, while
	<application>mpg123</application> converts the
	<acronym>MP3</acronym> into raw PCM audio data.  Both of these
	formats can be used with <application>cdrecord</application>
	to create audio CDs, whereas &man.burncd.8; requires a raw
	Pulse-Code Modulation (<acronym>PCM</acronym>.  When using
	<acronym>WAV</acronym> files, there will be a small tick
	sound at the beginning of each track.  This sound is the
	header of the <acronym>WAV</acronym> file.  One can remove the
	header with <application>SoX</application>, which can be
	installed from the <filename
	  role="package">audio/sox</filename> port or package:</para>

      <screen>&prompt.user; <userinput>sox -t wav -r 44100 -s -w -c 2 <replaceable>track.wav track.raw</replaceable></userinput></screen>

      <para>Refer to <xref linkend="creating-cds"/> for more
	information on using a CD burner in &os;.</para>
    </sect2>
  </sect1>

  <sect1 id="video-playback">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Ross</firstname>
	  <surname>Lippert</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
      <!-- 5 June 2002 -->
    </sect1info>

    <title>Video Playback</title>

    <para>Before configuring video playback, determine the model
      of the video card and the chip it uses.  While
      <application>&xorg;</application> supports a wide variety of
      video cards, fewer give good playback performance.  To obtain
      a list of extensions supported by the
      <application>&xorg;</application> server using the card, run
      &man.xdpyinfo.1; while <application>&xorg;</application> is
      running.</para>

    <para>It is a good idea to have a short MPEG test file for
      evaluating various players and options.  Since some DVD
      applications look for DVD media in <filename
	class="directory">/dev/dvd</filename> by default, or have this
      device name hardcoded in them, it might be useful to make
      symbolic links to the proper devices:</para>

    <screen>&prompt.root; <userinput>ln -sf /dev/acd0 /dev/dvd</userinput>
&prompt.root; <userinput>ln -sf /dev/acd0 /dev/rdvd</userinput></screen>

    <para>Due to the nature of &man.devfs.5;, manually created links
      will not persist after a system reboot.  In order to create the
      symbolic links automatically when the system boots, add the
      following lines to <filename>/etc/devfs.conf</filename>:</para>

    <programlisting>link acd0 dvd
link acd0 rdvd</programlisting>

    <para>DVD decryption invokes special DVD-ROM functions and
      requires write permission on the DVD devices.</para>

    <para>To enhance the shared memory
      <application>&xorg;</application> interface, it is
      recommended to increase the values of these &man.sysctl.8;
      variables:</para>

    <programlisting>kern.ipc.shmmax=67108864
kern.ipc.shmall=32768</programlisting>

  <sect2 id="video-interface">
    <title>Determining Video Capabilities</title>

    <indexterm><primary>XVideo</primary></indexterm>
    <indexterm><primary>SDL</primary></indexterm>
    <indexterm><primary>DGA</primary></indexterm>

    <para>There are several possible ways to display video under
      <application>&xorg;</application>.  What works is largely
      hardware dependent.  Each method described below will have
      varying quality across different hardware.</para>

    <para>Common video interfaces include:</para>

    <orderedlist>
      <listitem>
	<para><application>&xorg;</application>: normal output using
	  shared memory.</para>
      </listitem>

      <listitem>
	<para>XVideo: an extension to the
	  <application>&xorg;</application> interface which supports
	  video in any drawable object.</para>
      </listitem>

      <listitem>
	<para><acronym>SDL</acronym>: the Simple Directmedia
	  Layer.</para>
      </listitem>

      <listitem>
	<para><acronym>DGA</acronym>: the Direct Graphics
	  Access.</para>
      </listitem>

      <listitem>
	<para>SVGAlib: low level console graphics layer.</para>
      </listitem>
    </orderedlist>

    <sect3 id="video-interface-xvideo">
      <title>XVideo</title>

      <para><application>&xorg;</application> has an extension called
	<emphasis>XVideo</emphasis>, also known as Xvideo, Xv, and xv.
	It allows video to be directly displayed in drawable objects
	through a special acceleration.  This extension provides
	good quality playback even on low-end machines.</para>

      <para>To check whether the extension is running, use
	<command>xvinfo</command>:</para>

      <screen>&prompt.user; <userinput>xvinfo</userinput></screen>

      <para>XVideo is supported for the card if the result looks
	like:</para>

      <screen>X-Video Extension version 2.2
  screen #0
  Adaptor #0: "Savage Streams Engine"
    number of ports: 1
    port base: 43
    operations supported: PutImage
    supported visuals:
      depth 16, visualID 0x22
      depth 16, visualID 0x23
    number of attributes: 5
      "XV_COLORKEY" (range 0 to 16777215)
              client settable attribute
              client gettable attribute (current value is 2110)
      "XV_BRIGHTNESS" (range -128 to 127)
              client settable attribute
              client gettable attribute (current value is 0)
      "XV_CONTRAST" (range 0 to 255)
              client settable attribute
              client gettable attribute (current value is 128)
      "XV_SATURATION" (range 0 to 255)
              client settable attribute
              client gettable attribute (current value is 128)
      "XV_HUE" (range -180 to 180)
              client settable attribute
              client gettable attribute (current value is 0)
    maximum XvImage size: 1024 x 1024
    Number of image formats: 7
      id: 0x32595559 (YUY2)
        guid: 59555932-0000-0010-8000-00aa00389b71
        bits per pixel: 16
        number of planes: 1
        type: YUV (packed)
      id: 0x32315659 (YV12)
        guid: 59563132-0000-0010-8000-00aa00389b71
        bits per pixel: 12
        number of planes: 3
        type: YUV (planar)
      id: 0x30323449 (I420)
        guid: 49343230-0000-0010-8000-00aa00389b71
        bits per pixel: 12
        number of planes: 3
        type: YUV (planar)
      id: 0x36315652 (RV16)
        guid: 52563135-0000-0000-0000-000000000000
        bits per pixel: 16
        number of planes: 1
        type: RGB (packed)
        depth: 0
        red, green, blue masks: 0x1f, 0x3e0, 0x7c00
      id: 0x35315652 (RV15)
        guid: 52563136-0000-0000-0000-000000000000
        bits per pixel: 16
        number of planes: 1
        type: RGB (packed)
        depth: 0
        red, green, blue masks: 0x1f, 0x7e0, 0xf800
      id: 0x31313259 (Y211)
        guid: 59323131-0000-0010-8000-00aa00389b71
        bits per pixel: 6
        number of planes: 3
        type: YUV (packed)
      id: 0x0
        guid: 00000000-0000-0000-0000-000000000000
        bits per pixel: 0
        number of planes: 0
        type: RGB (packed)
        depth: 1
        red, green, blue masks: 0x0, 0x0, 0x0</screen>

    <para>The formats listed, such as YUV2 and YUV12, are not present
      with every implementation of XVideo and their absence may hinder
      some players.</para>

    <para>If the result looks like:</para>

    <screen>X-Video Extension version 2.2
screen #0
no adaptors present</screen>

    <para>XVideo is probably not supported for the card.  This means
      that it will be more difficult for the display to meet the
      computational demands of rendering video.  Depending on the
      video card and processor, one might still be able to have a
      satisfying experience.</para>

  </sect3>

  <sect3 id="video-interface-SDL">
    <title>Simple Directmedia Layer</title>

    <para>The Simple Directmedia Layer, SDL, is a
      porting layer for many operating systems
      allowing cross-platform applications to be developed which make
      efficient use of sound and graphics.  The SDL layer provides a
      low-level abstraction to the hardware which can sometimes be
      more efficient than the <application>&xorg;</application>
      interface.</para>

    <para><acronym>SDL</acronym> can be installed using the <filename
	role="package">devel/sdl12</filename> package or port.</para>

  </sect3>

  <sect3 id="video-interface-DGA">
    <title>Direct Graphics Access</title>

    <para><acronym>DGA</acronym> is an
      <application>&xorg;</application> extension which allows a
      program to bypass the <application>&xorg;</application> server
      and directly alter the framebuffer.  Because it relies on a low
      level memory mapping, programs using it must be run as
      <username>root</username>.</para>

    <para>The <acronym>DGA</acronym> extension can be tested and
      benchmarked using &man.dga.1;.  When <command>dga</command> is
      running, it changes the colors of the display whenever a key is
      pressed.  To quit, press <keycap>q</keycap>.</para>

  </sect3>
</sect2>

  <sect2 id="video-ports">
    <title>Ports and Packages Dealing with Video</title>

    <indexterm><primary>video ports</primary></indexterm>
    <indexterm><primary>video packages</primary></indexterm>

    <para>This section introduces some of the software available from
      the &os; Ports Collection which can be used for video
      playback.</para>

    <para>Many of the video applications which run on &os; were
      developed as &linux; applications.  Many of these applications
      are still beta-quality.  Some of the problems commonly
      encountered with video packages on &os; include:</para>

    <orderedlist>

      <listitem>
	<para>An application cannot playback a file which another
	  application produced.</para>
      </listitem>

      <listitem>
	<para>An application cannot playback a file which the
	  application itself produced.</para>
      </listitem>

      <listitem>
	<para>The same application on two different machines,
	  rebuilt on each machine for that machine, plays back the
	  same file differently.</para>
      </listitem>

      <listitem>
	<para>A seemingly trivial filter, like rescaling of the image
	  size, results in bad artifacts from a buggy rescaling
	  routine.</para>
      </listitem>

      <listitem>
	<para>An application frequently dumps core.</para>
      </listitem>

      <listitem>
	<para>Documentation is not installed with the port and can be
	  found either on the web or under the port's <filename
	    class='directory'>work</filename>
	  directory.</para>
      </listitem>

    </orderedlist>

    <para>Many applications may also exhibit
      <quote>&linux;-isms</quote>.  There may be issues resulting from
      the way some standard libraries are implemented in the &linux;
      distributions, or some features of the &linux; kernel which have
      been assumed by the authors of the applications.  These issues
      are not always noticed and worked around by the port
      maintainers, which can lead to problems like these:</para>

    <orderedlist>
      <listitem>
	<para>The use of <filename>/proc/cpuinfo</filename> to detect
	  processor characteristics.</para>
      </listitem>

      <listitem>
	<para>A misuse of threads which causes a program to hang upon
	  completion instead of truly terminating.</para>
      </listitem>

      <listitem>
	<para>Relies on software which is not yet available in the
	  &os; Ports Collection.</para>
      </listitem>
    </orderedlist>

    <sect3 id="video-mplayer">
      <title>MPlayer</title>

      <para><application>MPlayer</application> is a command-line video
	player with an optional graphical interface which aims to
	provide speed and flexibility.  This application, as well as
	other graphical front-ends, is available from the &os; Ports
	Collection.</para>

      <sect4 id="video-mplayer-building">
	<title>Building MPlayer</title>

	<indexterm><primary>MPlayer</primary>
	  <secondary>making</secondary></indexterm>

	<para><application>MPlayer</application> is available as a
	  package or port in <filename
	    role="package">multimedia/mplayer</filename>.  Several
	  compile options are available and a variety of hardware
	  checks occur during the build process.  For these reasons,
	  some users prefer to build the port rather than install the
	  package.  The available options will be displayed in a
	  menu after these commands are input:</para>

	<screen>&prompt.root; <userinput>cd /usr/ports/multimedia/mplayer</userinput>
&prompt.root; <userinput>make</userinput></screen>

	<para>The menu options should be reviewed to determine the
	  type of support to compile into the port.  If an option is
	  not selected, <application>MPlayer</application> will not be
	  able to display that type of video format.  Use the arrow
	  keys and spacebar to select the required formats.  When
	  finished, press <keycap>Enter</keycap> to continue the port
	  compile and installation.</para>

	<para>By default, this package or port will build the
	  <command>mplayer</command> command line utility and the
	  <command>gmplayer</command> graphical utility.  To encode
	  videos, install the <filename
	    role="package">multimedia/mencoder</filename> port.  Due
	  to licensing restrictions, a package is not available for
	  <command>MEncoder</command>.</para>

      </sect4>

      <sect4 id="video-mplayer-using">
	<title>Using MPlayer</title>

	<indexterm><primary>MPlayer</primary>
	  <secondary>use</secondary></indexterm>

	<para>The first time <application>MPlayer</application> is
	  run, it will create <filename
	    class="directory">~/.mplayer</filename> in the user's
	  home directory.  This subdirectory contains default versions
	  of the user-specific configuration files.</para>

	<para>This section describes only a few common uses.  Refer
	  to the <command>mplayer</command> manual page for a complete
	  description of its numerous options.</para>

	<para>To play the file
	  <filename><replaceable>testfile.avi</replaceable></filename>,
	  specify the video interfaces with
	  <option>-vo</option>:</para>

	  <screen>&prompt.user; <userinput>mplayer -vo xv <replaceable>testfile.avi</replaceable></userinput></screen>

	  <screen>&prompt.user; <userinput>mplayer -vo sdl <replaceable>testfile.avi</replaceable></userinput></screen>

<screen>&prompt.user; <userinput>mplayer -vo x11 <replaceable>testfile.avi</replaceable></userinput></screen>

<screen>&prompt.root; <userinput>mplayer -vo dga <replaceable>testfile.avi</replaceable></userinput></screen>

<screen>&prompt.root; <userinput>mplayer -vo 'sdl:dga' <replaceable>testfile.avi</replaceable></userinput></screen>

	<para>It is worth trying all of these options, as their
	  relative performance depends on many factors and will vary
	  significantly with hardware.</para>

	<para>To play a DVD, replace the
	  <filename><replaceable>testfile.avi</replaceable></filename>
	  with <option>dvd://<replaceable>N</replaceable> -dvd-device
	   <replaceable>DEVICE</replaceable></option>, where
	  <replaceable>N</replaceable> is the title number to play
	  and <filename><replaceable>DEVICE</replaceable></filename>
	  is the device node for the DVD-ROM.  For example, to play
	  title 3 from <devicename>/dev/dvd</devicename>:</para>

	<screen>&prompt.root; <userinput>mplayer -vo xv dvd://3 -dvd-device /dev/dvd</userinput></screen>

	<note>
	  <para>The default DVD device can be defined during the build
	    of the <application>MPlayer</application> port by
	    including the
	    <makevar>WITH_DVD_DEVICE=/path/to/desired/device</makevar>
	    option.  By default, the device is
	    <filename>/dev/acd0</filename>.  More details can be found
	    in the port's
	    <filename>Makefile.options</filename>.</para>
	</note>

	<para>To stop, pause, advance, and so on, consult the
	  keybindings, which are displayed by running <command>mplayer
	    -h</command>, or read the manual page.</para>

	<para>Additional playback options include
	  <option>-fs -zoom</option>, which engages fullscreen mode,
	  and <option>-framedrop</option>, which helps
	  performance.</para>

	<para>Each user can add commonly used options to their
	  <filename>~/.mplayer/config</filename> like so:</para>

	<programlisting>vo=xv
fs=yes
zoom=yes</programlisting>

	<para><command>mplayer</command> can be used to rip a DVD
	  title to a <filename>.vob</filename>.  To dump the second
	  title from a DVD:</para>

	  <screen>&prompt.root; <userinput>mplayer -dumpstream -dumpfile out.vob dvd://2 -dvd-device /dev/dvd</userinput></screen>

	<para>The output file, <filename>out.vob</filename>, will be
	  MPEG and can be manipulated by the other packages described
	  in this section.</para>

	<para>The <ulink url="http://www.mplayerhq.hu/DOCS/">MPlayer
	    documentation</ulink> is technically informative and
	  should be consulted by anyone wishing to obtain a high level
	  of expertise with &unix; video.  The
	  <application>MPlayer</application> mailing list is hostile
	  to anyone who has not bothered to read the documentation, so
	  before making a bug report, read the documentation
	  first.</para>

      </sect4>
      <sect4 id="video-mencoder">
	<title><application>MEncoder</application></title>

	<indexterm>
	  <primary>mencoder</primary>
	</indexterm>

	<para>Before using <command>mencoder</command>, it is a good
	  idea to become familiar with the options described in the
	  <ulink
	    url="http://www.mplayerhq.hu/DOCS/HTML/en/mencoder.html">HTML
	  documentation</ulink>.  There are innumerable ways to
	  improve quality, lower bitrate, and change formats, and some
	  of these options may make the difference between good or bad
	  performance.  Improper combinations of command line options
	  can yield output files that are unplayable even by
	  <command>mplayer</command>.</para>

	<para>Here is an example of a simple copy:</para>

	 <screen>&prompt.user; <userinput>mencoder <replaceable>input.avi</replaceable> -oac copy -ovc copy -o <replaceable>output.avi</replaceable></userinput></screen>

	<para>To rip to a file, use <option>-dumpfile</option> with
	  <command>mplayer</command>.</para>

	<para>To convert
	  <filename><replaceable>input.avi</replaceable></filename>
	  to the MPEG4 codec with MPEG3 audio encoding, first install
	  the <filename role="package">audio/lame</filename> port.
	  Due to licensing restrictions, a package is not available.
	  Once installed, type:</para>

	<screen>&prompt.user; <userinput>mencoder <replaceable>input.avi</replaceable> -oac mp3lame -lameopts br=192 \
	 -ovc lavc -lavcopts vcodec=mpeg4:vhq -o <replaceable>output.avi</replaceable></userinput></screen>

	<para>This will produce output playable by applications such
	  as <command>mplayer</command> and
	  <command>xine</command>.</para>

	<para><filename><replaceable>input.avi</replaceable></filename>
	  can be replaced with <option>dvd://1 -dvd-device
	    /dev/dvd</option> and run as <username>root</username>
	  to re-encode a DVD title directly.  Since it may take a few
	  tries to get the desired result, it is recommended to dump
	  the title to a file and to work on the file.</para>
      </sect4>

    </sect3>

    <sect3 id="video-xine">
      <title>The <application>xine</application> Video Player</title>

      <para><application>xine</application> is a video player with a
	reusable base library and a modular executable which can be
	extended with plugins.  It can be installed using the
	<filename role="package">multimedia/xine</filename> package or
	port.</para>

      <para>In practice, <application>xine</application> requires
	either a fast CPU with a fast video card, or support for the
	XVideo extension.  The <application>xine</application> video
	player performs best on XVideo interfaces.</para>

      <para>By default, the <application>xine</application> player
	starts a graphical user interface.  The menus can then be used
	to open a specific file.</para>

      <para>Alternatively, <application>xine</application> may be
	invoked to play a file immediately without the graphical
	interface:</para>

      <screen>&prompt.user; <userinput>xine</userinput></screen>

      <para>Alternatively, it may be invoked to play a file
	immediately without the GUI with the command:</para>

      <screen>&prompt.user; <userinput>xine -g -p <replaceable>mymovie.avi</replaceable></userinput></screen>

      <para>The <ulink
	  url="http://dvd.sourceforge.net/xine-howto/en_GB/html/howto.html">
	xine HOWTO</ulink> contains a chapter on performance
	improvement which is general to all players.</para>
    </sect3>

    <sect3 id="video-ports-transcode">
      <title>The <application>transcode</application>
	Utilities</title>

      <para><application>transcode</application> provides a suite of
	tools for re-encoding video and audio files.
	<application>transcode</application> can be used to merge
	video files or repair broken files using command line tools
	with <filename>stdin/stdout</filename> stream
	interfaces.</para>

      <para><application>transcode</application> can be installed
	using the <filename
	  role="package">multimedia/transcode</filename> package or
	port.  Many users prefer to compile the port as it provides a
	menu of compile options for specifying the support and codecs
	to compile in.  If an option is not selected,
	<application>transcode</application> will not be able to
	encode that format.  Use the arrow keys and spacebar to select
	the required formats.  When finished, press
	<keycap>Enter</keycap> to continue the port compile and
	installation.</para>

      <para>This example demonstrates how to convert a DivX file into
	a PAL MPEG-1 file (PAL VCD):</para>

    <screen>&prompt.user; <userinput>transcode -i
<replaceable>input.avi</replaceable> -V --export_prof vcd-pal -o output_vcd</userinput>
&prompt.user; <userinput>mplex -f 1 -o <replaceable>output_vcd.mpg output_vcd.m1v output_vcd.mpa</replaceable></userinput></screen>

    <para>The resulting MPEG file,
      <filename><replaceable>output_vcd.mpg</replaceable></filename>,
      is ready to be played with <application>MPlayer</application>.
      The file can be burned on a CD-R media to create a Video CD.  In
      this, install and use the <filename
	role="package">multimedia/vcdimager</filename> and <filename
	role="package">sysutils/cdrdao</filename> programs.</para>

    <para>In addition to the manual page for
      <command>transcode</command>, refer to the <ulink
	url="http://www.transcoding.org/cgi-bin/transcode">transcode
	wiki</ulink> for further information and examples.</para>
  </sect3>
</sect2>
</sect1>

<sect1 id="tvcard">
  <sect1info>
    <authorgroup>
      <author>
	<firstname>Josef</firstname>
	<surname>El-Rayes</surname>
	<contrib>Original contribution by </contrib>
      </author>
    </authorgroup>
    <authorgroup>
      <author>
	<firstname>Marc</firstname>
	<surname>Fonvieille</surname>
	<contrib>Enhanced and adapted by </contrib>
	<!-- 02 January 2004 -->
      </author>
    </authorgroup>
  </sect1info>

  <title>Setting Up TV Cards</title>

  <indexterm>
    <primary>TV cards</primary>
  </indexterm>

  <sect2>
    <title>Introduction</title>

    <para>TV cards allow can be used to watch broadcast or cable TV on
      a computer.  Most cards accept composite video via an RCA or
      S-video input and some cards include a FM radio tuner.</para>

    <para>&os; provides support for PCI-based TV cards using a
      Brooktree Bt848/849/878/879 or a Conexant CN-878/Fusion 878a
      video capture chip with the &man.bktr.4; driver.  Ensure the
      board comes with a supported tuner.  Consult &man.bktr.4; for a
      list of supported tuners.</para>
  </sect2>

  <sect2>
    <title>Loading the Driver</title>

    <para>In order to use the card, the &man.bktr.4; driver must be
      loaded.  To automate this at boot time, add the following line
      to <filename>/boot/loader.conf</filename>:</para>

    <programlisting>bktr_load="YES"</programlisting>

      <para>Alternatively, one can statically compile support for
	the TV card into a custom kernel.  In that case, add the
	following lines to the custom kernel configuration
	file:</para>

      <programlisting>device	 bktr
device	iicbus
device	iicbb
device	smbus</programlisting>

      <para>These additional devices are necessary as the card
	components are interconnected via an I2C bus.  Then, build and
	install a new kernel.</para>

      <para>To test the driver, reboot the system.  The TV card
	should appear in the boot messages, as seen in this
	example:</para>

      <programlisting>bktr0: &lt;BrookTree 848A&gt; mem 0xd7000000-0xd7000fff irq 10 at device 10.0 on pci0
iicbb0: &lt;I2C bit-banging driver&gt; on bti2c0
iicbus0: &lt;Philips I2C bus&gt; on iicbb0 master-only
iicbus1: &lt;Philips I2C bus&gt; on iicbb0 master-only
smbus0: &lt;System Management Bus&gt; on bti2c0
bktr0: Pinnacle/Miro TV, Philips SECAM tuner.</programlisting>

      <para>The messages will differ according to the hardware.  Check
	the messages to determine if the tuner is correctly detected.
	It is still possible to override some of the detected
	parameters with &man.sysctl.8; MIBs and kernel configuration
	file options.  For example, to force the tuner to a Philips
	SECAM tuner, add the following line to a custom kernel
	configuration file:</para>

      <programlisting>options OVERRIDE_TUNER=6</programlisting>

      <para>or, use &man.sysctl.8;:</para>

      <screen>&prompt.root; <userinput>sysctl hw.bt848.tuner=6</userinput></screen>

      <para>Refer to &man.bktr.4; and
	<filename>/usr/src/sys/conf/NOTES</filename> for more
	details on the available options.</para>
    </sect2>

    <sect2>
      <title>Useful Applications</title>

      <para>To use the TV card, install one of the following
	applications:</para>

      <itemizedlist>
	<listitem>
	  <para><filename role="package">multimedia/fxtv</filename>
	    provides TV-in-a-window and image/audio/video capture
	    capabilities.</para>
	</listitem>
	<listitem>
	  <para><filename role="package">multimedia/xawtv</filename>
	    is another TV application with similar features.</para>
	</listitem>
	<listitem>
	  <para><filename role="package">audio/xmradio</filename>
	    provides an application for using the FM radio tuner of a
	    TV card.</para>
	</listitem>
      </itemizedlist>

      <para>More applications are available in the &os; Ports
	Collection.</para>
    </sect2>

    <sect2>
      <title>Troubleshooting</title>

      <para>If any problems are encountered with the TV card,
	check that the video capture chip and the tuner are
	supported by &man.bktr.4; and that the right configuration
	options were used.  For more support and various questions
	about TV cards, refer to the archives of the
	&a.multimedia.name; mailing list.</para>
    </sect2>
  </sect1>

  <sect1 id="mythtv">
    <title>MythTV</title>

    <para>MythTV is a popular, open source <acronym
	role="Personal Video Recorder">PVR</acronym>
      application.  This section demonstrates how to install and
      setup MythTV on &os;.  Refer to the <ulink
	url="http://www.mythtv.org/wiki/">MythTV wiki</ulink> for
      more information on how to use MythTV.</para>

      <para>MythTV requires a frontend and a backend; however,
	it allows the user to have the frontend and backend on
	different machines.</para>

      <para>For the frontend, <filename
	  role="package">multimedia/mythtv-frontend</filename> is
	required, as well as an X server, which can be found in
	<filename role="package">x11/xorg</filename>.  Ideally, the
	frontend computer also has a video card that supports <acronym
	  role="X-Video Motion Compensation">XvMC</acronym> and,
	optionally, a <acronym role="Linux Infrared Remote
	  Control">LIRC</acronym>-compatible remote.</para>

      <para>For the backend, <filename
	  role="package">multimedia/mythtv</filename> is required,
	along with the &mysql; database server.  Optionally a tuner
	and storage for any recorded data.  The &mysql; package should
	be automatically installed as a dependency when installing
	<filename role="package">multimedia/mythtv</filename>.</para>

    <sect2>
      <title>Hardware</title>

      <para>MythTV is designed to utilize <acronym
	  role="Video for Linux">V4L</acronym> to access video input
	devices such as encoders and tuners.  At this time, MythTV
	works best with <acronym role="Universal Serial
	  Bus">USB</acronym> DVB-S/C/T cards supported by <filename
	  role="package">multimedia/webcamd</filename>, as it provides
	a <acronym
	  role="Video for Linux">V4L</acronym> userland application.
	Any <acronym role="Digital Video Broadcasting">DVB</acronym>
	card supported by <application>webcamd</application> should
	work with MythTV.  A list of known working cards can be
	found <ulink
	  url="http://wiki.freebsd.org/WebcamCompat">here</ulink>.
	Drivers are also available for Hauppauge cards in the
	following ports: <filename
	  role="package">multimedia/pvr250</filename> and <filename
	  role="package">multimedia/pvrxxx</filename>, but they
	provide a non-standard driver interface that does not work
	with versions of MythTV greater than 0.23.  Due to licensing
	restrictions, no packages are available and these two ports
	must be compiled.</para>

      <para>The <ulink url="http://wiki.freebsd.org/HTPC">HTPC
	  wiki page</ulink> contains a list of all available <acronym
	  role="Digital Video Broadcasting">DVB</acronym>
	drivers.</para>
    </sect2>

    <sect2>
      <title>Setting up MythTV</title>

      <para>To install the MythTV port:</para>

      <screen>&prompt.root; <userinput>cd /usr/ports/multimedia/mythtv</userinput>
&prompt.root; <userinput>make install</userinput></screen>

      <para>Once installed, set up the MythTV database:</para>

      <screen>&prompt.root; <userinput>mysql -uroot -p &lt; /usr/local/share/mythtv/database/mc.sql</userinput></screen>

      <para>Configure the backend:</para>

      <screen>&prompt.root; <userinput>mythtv-setup</userinput></screen>

      <para>Start the backend:</para>

      <screen>&prompt.root; <userinput>echo 'mythbackend_enable="YES"' &gt;&gt; /etc/rc.conf</userinput>
&prompt.root; <userinput>service mythbackend start</userinput></screen>
    </sect2>
  </sect1>

  <sect1 id="scanners">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Marc</firstname>
	  <surname>Fonvieille</surname>
	  <contrib>Written by </contrib>
	  <!-- 04 August 2004 -->
	</author>
      </authorgroup>
    </sect1info>

    <title>Image Scanners</title>

    <indexterm>
      <primary>image scanners</primary>
    </indexterm>

    <para>In &os;, access to image scanners is provided by the
      <application>SANE</application> (Scanner Access Now Easy)
      <acronym role="Application Programming
      Interface">API</acronym> available through the &os; Ports
      Collection.  <application>SANE</application> will also use
      some &os; device drivers to provide access to the scanner
      hardware.</para>

    <para>&os; supports both SCSI and USB scanners.  Be sure the
      scanner is supported by <application>SANE</application> prior
      to performing any configuration.  Refer to the <ulink
        url="http://www.sane-project.org/sane-supported-devices.html">
      supported devices list</ulink> for more information about supported
      scanners.</para>

    <sect2>
      <title>Kernel Configuration</title>

      <para>Both SCSI and USB interfaces are supported.  Depending
	upon the scanner interface, different device drivers are
	required.</para>

      <sect3 id="scanners-kernel-usb">
	<title>USB Interface</title>

	<para>The <filename>GENERIC</filename> kernel by default
	  includes the device drivers needed to support USB scanners.
	  Users with a custom kernel should ensure that the following
	  lines are present in the custom kernel configuration
	  file:</para>

	<programlisting>device usb
device uhci
device ohci
device ehci</programlisting>

	<para>Plug in the USB scanner.  Use &man.dmesg.8; to determine
	  whether the scanner appears in the system message
	  buffer:</para>

	<screen>ugen0.2: &lt;EPSON&gt; at usbus0</screen>

	<para>These messages indicate that the scanner is using
	  either <filename>/dev/ugen0.2</filename> or
	  <filename>/dev/uscanner0</filename>, depending on the &os;
	  version.  For this example, a
	  &epson.perfection;&nbsp;1650 USB scanner was used.</para>
      </sect3>

      <sect3>
	<title>SCSI Interface</title>

	<para>If the scanner uses a SCSI interface, it is important to
	  know which SCSI controller board it will use.  Depending
	  upon the SCSI chipset, a custom kernel configuration file
	  may be needed. The <filename>GENERIC</filename> kernel
	  supports the most common SCSI controllers.  Refer to
	  <filename>/usr/src/sys/conf/NOTES</filename> to determine
	  the correct line to add to a custom kernel configuration
	  file.  In addition to the SCSI adapter driver, the following
	  lines are needed in the kernel configuration file:</para>

	<programlisting>device scbus
device pass</programlisting>

	<para>Verify that the device is displayed in the system
	  message buffer:</para>

	<screen>pass2 at aic0 bus 0 target 2 lun 0
pass2: &lt;AGFA SNAPSCAN 600 1.10&gt; Fixed Scanner SCSI-2 device
pass2: 3.300MB/s transfers</screen>

	<para>If the scanner was not powered-on at system boot, it
	  is still possible to manually force the detection by
	  performing a SCSI bus scan with the &man.camcontrol.8;
	  command:</para>

	<screen>&prompt.root; <userinput>camcontrol rescan all</userinput>
Re-scan of bus 0 was successful
Re-scan of bus 1 was successful
Re-scan of bus 2 was successful
Re-scan of bus 3 was successful</screen>

	<para>The scanner should now appear in the SCSI devices
	  list:</para>

	<screen>&prompt.root; <userinput>camcontrol devlist</userinput>
&lt;IBM DDRS-34560 S97B&gt;              at scbus0 target 5 lun 0 (pass0,da0)
&lt;IBM DDRS-34560 S97B&gt;              at scbus0 target 6 lun 0 (pass1,da1)
&lt;AGFA SNAPSCAN 600 1.10&gt;           at scbus1 target 2 lun 0 (pass3)
&lt;PHILIPS CDD3610 CD-R/RW 1.00&gt;     at scbus2 target 0 lun 0 (pass2,cd0)</screen>

	<para>Refer to &man.scsi.4; and &man.camcontrol.8; for more
	  details about SCSI devices on &os;.</para>
      </sect3>
    </sect2>

    <sect2>
      <title>SANE Configuration</title>

      <para>The <application>SANE</application> system is split in two
	parts: the backends (<filename
	  role="package">graphics/sane-backends</filename>) and the
	frontends (<filename
	  role="package">graphics/sane-frontends</filename>).  The
	backends provide access to the scanner.  The
	<application>SANE</application>'s <ulink
	  url="http://www.sane-project.org/sane-supported-devices.html">supported
	devices</ulink> list specifies which backend will support the
	image scanner.  The correct backend is needed in order to use
	the scanner.  The frontends provide the graphical scanning
	interface, <application>xscanimage</application>.</para>

      <para>After installing the <filename
	  role="package">graphics/sane-backends</filename> port or
	package, use <command>sane-find-scanner</command> to check the
	scanner detection by the
	<application>SANE</application> system:</para>

      <screen>&prompt.root; <userinput>sane-find-scanner -q</userinput>
found SCSI scanner "AGFA SNAPSCAN 600 1.10" at /dev/pass3</screen>

      <para>The output should show the interface type of the scanner
	and the device node used to attach the scanner to the system.
	The vendor and the product model may or may not appear.</para>

      <note>
	<para>Some USB scanners require firmware to be loaded.  Refer
	  to &man.sane-find-scanner.1; and &man.sane.7; for
	  details.</para>
      </note>

      <para>Next, check if the scanner will be identified by a
	scanning frontend.  By default, the
	<application>SANE</application> backends come with a command
	line tool called &man.scanimage.1;.  This command can be used
	to list the devices and perform an image acquisition.  Use
	<option>-L</option> to list the scanner devices:</para>

      <screen>&prompt.root; <userinput>scanimage -L</userinput>
device `snapscan:/dev/pass3' is a AGFA SNAPSCAN 600 flatbed scanner</screen>

      <para>Here is the output for the USB scanner used in <xref
	  linkend="scanners-kernel-usb"/>:</para>

      <screen>&prompt.root; <userinput>scanimage -L</userinput>
device 'epson2:libusb:/dev/usb:/dev/ugen0.2' is a Epson GT-8200 flatbed scanner</screen>

      <para>In this output,
	<literal>'epson2:libusb:/dev/usb:/dev/ugen0.2'</literal> is
	the backend name (<literal>epson2</literal>) and the device
	node (<literal>/dev/ugen0.2</literal>) used by the
	scanner.</para>

      <note>
	<para>No output or a message saying that no scanners were
	  identified indicates that &man.scanimage.1; is unable to
	  identify the scanner.  If this happens, edit the backend
	  configuration file in <filename
	    class="directory">/usr/local/etc/sane.d/</filename>
	  and define the scanner device used.</para>

	<para>In the above example, the USB scanner is perfectly
	  detected and working.</para>

	<para>To determine if the scanner is correctly
	  identified:</para>

	<screen>&prompt.root; <userinput>scanimage -L</userinput>

No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).</screen>

      <para>Since the scanner is not identified, edit
	<filename>/usr/local/etc/sane.d/epson2.conf</filename>.  In
	this example, the scanner model is
	&epson.perfection;&nbsp;1650 and it uses the
	<literal>epson2</literal> backend.  When editing, read the
	help comments in the backend configuration file.  Line
	changes are simple: comment out all lines that have the
	wrong interface for the scanner.  In this example, comment
	out all lines starting with the word <literal>scsi</literal>
	as the scanner uses the USB interface.  Then, at the end
	of the file, add a line specifying the interface and the
	device node used.  In this case, add the following
	line:</para>

      <programlisting>usb /dev/uscanner0</programlisting>

      <para>Save the edits and verify that the scanner is
	identified:</para>

      <screen>&prompt.root; <userinput>scanimage -L</userinput>
device `epson:/dev/uscanner0' is a Epson GT-8200 flatbed scanner</screen>

      <para>The <literal>`epson:/dev/uscanner0'</literal> field now
	gives the right backend name and the device node.</para>
    </note>

    <para>Once <command>scanimage -L</command> sees the scanner, the
      configuration is complete and the device is now ready to
      scan.</para>

    <para>While &man.scanimage.1; can be used to perform an image
      acquisition from the command line, it is often preferable to
      use a graphical interface to perform image scanning.  The
      <filename role="package">graphics/sane-frontends</filename>
      package or port installs a simple but efficient graphical
      interface, <application>xscanimage</application>.</para>

    <para><application>Xsane</application>, which is installed with
      the <filename role="package">graphics/xsane</filename> package
      or port, is another popular graphical scanning frontend.  It
      offers advanced features such as various scanning modes, color
      correction, and batch scans.  Both of these applications are
      usable as a <application>GIMP</application> plugin.</para>
  </sect2>

  <sect2>
    <title>Giving Other Users Access to the Scanner</title>

    <para>In order to have access to the scanner, a user needs
      read and write permissions to the device node used by the
      scanner.  In the previous example, the USB scanner uses the
      device node <filename>/dev/ugen0.2</filename> which is really a
      symlink to the real device node
      <filename>/dev/usb/0.2.0</filename>.  The symlink and the device
      node are owned, respectively, by the
      <groupname>wheel</groupname> and
      <groupname>operator</groupname> groups.  Adding the user to
      these groups will allow access to the scanner.  However, for
      security reasons, always think twice before adding a user
      to any group, especially <groupname>wheel</groupname>.  A better
      solution is to create a group to make the scanner device
      accessible to members of this group.</para>

    <para>This example creates a group called
      <groupname><replaceable>usb</replaceable></groupname> using
      &man.pw.8;:</para>

    <screen>&prompt.root; <userinput>pw groupadd usb</userinput></screen>

      <para>Then, make the <filename>/dev/ugen0.2</filename> symlink
	and the <filename>/dev/usb/0.2.0</filename> device node
	accessible to the <groupname>usb</groupname> group with write
	permissions of (<literal>0660</literal> or
	<literal>0664</literal>.  All of this is done by adding the
	following lines to
	<filename>/etc/devfs.rules</filename>:</para>

      <programlisting>[system=5]
add path ugen0.2 mode 0660 group usb
add path usb/0.2.0 mode 0666 group usb</programlisting>

      <para>Finally, add the users to
	<groupname><replaceable>usb</replaceable></groupname> in order
	to allow access to the scanner:</para>

      <screen>&prompt.root; <userinput>pw groupmod usb -m <replaceable>joe</replaceable></userinput></screen>

      <para>For more details refer to &man.pw.8;.</para>
    </sect2>
  </sect1>
</chapter>