aboutsummaryrefslogtreecommitdiff
path: root/zh_CN.GB2312/books/handbook/multimedia/chapter.xml
blob: 2d8f3a1340a3cddfea055af67dde4e60ba39362f (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
<?xml version="1.0" encoding="gb2312"?>
<!--
     The FreeBSD Documentation Project
     The FreeBSD Simplified Chinese Documentation Project

     Original Revision: 1.143
     $FreeBSD$
-->

<chapter id="multimedia">
 <chapterinfo>
  <authorgroup>
   <author>
	<firstname>Ross</firstname>
	<surname>Lippert</surname>
	<contrib>编辑: </contrib>
   </author>
  </authorgroup>
  <authorgroup>
	 <author>
	<firstname></firstname>
	<surname>雪平</surname>
	<contrib>中文翻译: </contrib>
   </author>
  </authorgroup>
 </chapterinfo>

 <title>多媒体</title>
  <sect1 id="multimedia-synopsis">
  <title>概述</title>

    <para>FreeBSD 广泛地支持各种声卡,
      让您可以从容地享受来自您的计算机的高保真输出。
      这包括了录制和播放 MPEG Audio Layer
      3 (MP3)、 WAV、 以及 Ogg Vorbis 等许多种格式声音的能力。
      FreeBSD 同时也包括了许多的应用程序,让您可以录音、
      增加声音效果以及控制附加的MIDI设备。</para>

    <para>要是乐于动手, FreeBSD 也能支持播放一般的视频文件和
      DVD。 对各种视频媒体进行编码、
      转换和播放的应用程序比起处理声音的应用程序略少一些。
      例如, 在撰写这章时,
      FreeBSD Ports Collection 中还没有类似 <filename
      role="package">audio/sox</filename>
      那样好的重编码工具能够用来在不同的格式之间转换。
      不过, 这个领域的软件研发进展是很快的。</para>

    <para>本章将介绍配置声卡的必要步骤。 X11 的安装和配置
      (<xref linkend="x11"/>) 里已经考虑到了您显卡的问题,
      但要想有更好的播放效果, 仍需要调整一些东西。</para>

	<para>读了本章后,您将知道:</para>

    <itemizedlist>
      <listitem>
        <para>如何配置系统识别声卡。</para>
      </listitem>

      <listitem>
        <para>测试声卡是否正常工作的方法。</para>
      </listitem>

      <listitem>
        <para>如何排除声卡安装中的问题。</para>
      </listitem>

      <listitem>
        <para>如何播放和编码MP3以及其它格式的音频。</para>
      </listitem>

      <listitem>
        <para>X 服务器如何支持视频。</para>
      </listitem>

      <listitem>
        <para>哪些好的视频播放/压缩<quote>ports</quote></para>
	  </listitem>

      <listitem>
        <para>如何播放 DVD、 <filename>.mpg</filename> 以及
          <filename>.avi</filename> 文件。</para>
      </listitem>

      <listitem>
        <para>如何从 CD 和 DVD 中提取文件。</para>
      </listitem>

      <listitem>
        <para>怎样配置电视卡。</para>
      </listitem>

      <listitem>
        <para>如何配置图像扫描仪。</para>
      </listitem>
    </itemizedlist>

	<para>在读本章这前,您应该:</para>

    <itemizedlist>
      <listitem><para>知道如何配置、安装一个新的内核 (<xref
		linkend="kernelconfig"/>)</para></listitem>
    </itemizedlist>

    <warning>
      <para>用&man.mount.8; 命令去装载CD光盘,至少会产生一个错误,
        更糟的情况下会产生 <emphasis>kernel panic</emphasis>。
        这种媒体所用的编码与通常的ISO文件系统是不同的。</para>
    </warning>

  </sect1>

  <sect1 id="sound-setup">
    <sect1info>
      <authorgroup>
        <author>
	 <firstname>Moses</firstname>
	 <surname>Moore</surname>
	 <contrib>贡献者 </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>安装声卡</title>

  <sect2 id="sound-device">
    <title>配置系统</title>

    <indexterm><primary>PCI</primary></indexterm>
    <indexterm><primary>ISA</primary></indexterm>
    <indexterm><primary>声卡</primary></indexterm>
    <para>在开始之前,您应该清楚声卡类型、所用的芯片以及它是 PCI 还是 ISA 卡。
      FreeBSD 支持种类繁多的 PCI 和 ISA 卡。检查 <ulink
      url="&rel.current.hardware;">硬件兼容说明</ulink>
      中支持的音频设备列表看看是否支持您的声卡,
      硬件兼容说明也会说明支持您声卡的是哪个驱动程序。</para>

    <indexterm>
      <primary>内核</primary>
      <secondary>配置</secondary>
    </indexterm>

    <para>要使用声卡, 就应装载正确的驱动程序。完成的方式有两种:
      最简单的是使用命令 &man.kldload.8; 来装载一个内核模块,在命令行输入</para>

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

    <para>或者在文件 <filename>/boot/loader.conf</filename> 里加入一行,内容如下</para>

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

    <para>上边实例用于 Creative &soundblaster; Live! 声卡。
      其它可装载的模块列在文件
      <filename>/boot/defaults/loader.conf</filename> 里边。
      如果不知道应该使用哪个驱动, 您可以尝试加载
      <filename>snd_driver</filename> module:</para>

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

    <para>这是个 meta 驱动,一次加载了最常见的设备驱动。
      这会提高搜索正确驱动的速度。也可以通过
      <filename>/boot/loader.conf</filename> 工具来加载所有的声卡驱动。</para>

    <para>如果希望在加载了 <filename>snd_driver</filename>
      meta 驱动之后了解到底选择了哪种声卡, 可以通过使用
      <command>cat /dev/sndstat</command> 来查询 <filename>/dev/sndstat</filename>
      文件。</para>

    <para>另外,您也可以把支持您声卡的代码静态地编译到内核里去。
      下一节就采用这种方式支持硬件给出提示。 关于重新编译内核,请参考 <xref
      linkend="kernelconfig"/></para>

    <sect3>
      <title>定制内核使其支持声卡</title>

      <para>要做的第一件事情就是添加通用音频框架驱动
	&man.sound.4; 到内核中, 您需要添加下面这行到内核配置文件中:</para>

      <programlisting>device sound</programlisting>

      <para>接下来就是加入对我们所用声卡的支持了。
	首先需要确定我们的声卡需要使用哪一个驱动。
	您可以参考 <ulink
	url="&rel.current.hardware;">硬件兼容列表</ulink>
	所列出的音频设备, 以确定您声卡的驱动。
	例如, Creative &soundblaster; Live! 声卡由
	&man.snd.emu10k1.4; 驱动来支持。 要添加它,
	需要在内核编译配置文件中加入下面一行:</para>

      <programlisting>device snd_emu10k1</programlisting>

      <para>一定要阅读驱动的联机手册了解如何使用它们。
	关于内核配置文件中声卡驱动的具体写法, 也可以在
	<filename>/usr/src/sys/conf/NOTES</filename> 文件中找到。</para>

      <para>非即插即用的 ISA 卡可能需要您为内核提供一些关于声卡配置的信息
	(IRQ、 I/O 端口, 等等), 这一点与其他不支持即插即用的 ISA 卡类似。 这项工作可以通过
	<filename>/boot/device.hints</filename> 文件来完成。
	系统启动时, &man.loader.8; 将读取这个文件,
	并将其中的配置传给内核。 例如, 旧式的
	Creative &soundblaster; 16 ISA 非即插即用卡需要使用
	&man.snd.sbc.4; 驱动并配合 snd_sb16(4)。
	您可以在内核编译配置文件中增加如下配置:</para>

      <programlisting>device snd_sbc
device snd_sb16</programlisting>

      <para>还有下面这些到
	<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>这样,声卡使用 <literal>0x220</literal>
	I/O 端口和 IRQ <literal>5</literal></para>

      <para><filename>/boot/device.hints</filename> 文件中所使用的语法, 在
	&man.sound.4; 联机手册中以及所用的具体声卡驱动的联机手册中,
	会进行进一步的讲解。</para>

      <para>上面所展示的是默认的配置。 有时候,
	您可能需要更改 IRQ 或其他配置, 以适应声卡的实际情况。
	查看 &man.snd.sbc.4; 联机手册了解更多信息。</para>
    </sect3>
  </sect2>

  <sect2 id="sound-testing">
    <title>测试声卡</title>

    <para>用修改过的内核重起,或者加载了需要的模块之后,
      声卡将会出现在您的系统消息缓存中
      (&man.dmesg.8;),就像这样:</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>声卡的状态可以通过
      <filename>/dev/sndstat</filename> 文件来查询:</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>您系统的输出可能与此不同。如果没有看到
      <devicename>pcm</devicename> 设备,回顾并检查一下前面做的。
      重新检查您的内核配置文件并保证选择了正确的设备。
      常见问题列在 <xref linkend="troubleshooting"/> 一节。</para>

    <para>如果一切正常,您现在应该拥有一个多功能声卡了。
      如果您的 CD-ROM 或者 DVD-ROM 驱动器的音频输出线已经与声卡连在一起,
      您可以把 CD 放入驱动器并用 &man.cdcontrol.1; 来播放:</para>

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

    <para>许多应用程序,比如 <filename
      role="package">audio/workman</filename> 可以提供一个友好的界面。
      您可能想要安装一个应用程序比如
      <filename role="package">audio/mpg123</filename> 来听
      MP3 音频文件。</para>

    <para>另一种快速测试声卡的方法, 是将数据发送到
      <filename>/dev/dsp</filename>, 像这样做:</para>

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

    <para>这里 <filename><replaceable>filename</replaceable></filename> 可以是任意文件。
      这行命令会产生一些噪音,证明声卡果真在工作。</para>

    <note>
      <para>设备节点 <filename>/dev/dsp*</filename> 会在需要的时候自动产生。
	如果没有使用它们, 则它们不会出现在
	&man.ls.1; 的输出中。</para>
    </note>

    <para>声卡混音级别可以通过 &man.mixer.8; 命令更改。
      更多细节可以在 &man.mixer.8; 联机手册中找到。</para>

    <sect3 id="troubleshooting">
      <title>常见问题</title>

      <indexterm><primary>设备节点</primary></indexterm>
      <indexterm><primary>I/O 端口</primary></indexterm>
      <indexterm><primary>IRQ</primary></indexterm>
      <indexterm><primary>DSP</primary></indexterm>

      <informaltable frame="none" pgwide="1">
         <tgroup cols="2">
  	  <thead>
	    <row>
	     <entry>错误信息</entry>
	      <entry>解决方法</entry>
	    </row>
          </thead>

	  <tbody>
            <row>
              <entry><errorname>sb_dspwr(XX) timed out</errorname></entry>
              <entry><para>I/O端口没有设置正确。</para></entry>
            </row>

            <row>
              <entry><errorname>bad irq XX</errorname></entry>
	      <entry><para>IRQ设置不正确。确信设定的IRQ和声卡的IRQ是一样的。</para></entry>
            </row>

            <row>
              <entry><errorname>xxx: gus pcm not attached, out of memory</errorname></entry>
	      <entry><para>没有足够的内存空间供设置使用。</para></entry>
            </row>

            <row>
              <entry><errorname>xxx: can't open /dev/dsp!</errorname></entry>
              <entry><para>使用命令 <command>fstat | grep dsp</command>
                进行检查是否有其它的程序打开了设备。 值得注意的是
                <application>esound</application><application>KDE</application> 提供的声卡支持经常是造成麻烦的祸根。</para></entry>
            </row>
          </tbody>
        </tgroup>
      </informaltable>

      <para>另一个问题是许多新式的显卡本身包含它们自己的声音驱动,
        用以配合 <acronym>HDMI</acronym> 这样的设备使用。
        这个声音设备有时会在真正的声卡之前被探测到,
        从而成为默认的回放设备, 而使真正的声卡无法发声。
        要检查这种情况, 运行
        <application>dmesg</application> 并观察 <literal>pcm</literal>。
        其输出类似下面这样:</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>此处显卡 (<literal>NVidia</literal>) 先于真正的声卡
        (<literal>Realtek ALC889</literal>) 被探测到。
        要使用声卡作为默认的回放设备, 将
        <literal>hw.snd.default_unit</literal> 改为对应的设备编号:</para>

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

      <para>这里的 <literal>n</literal> 是希望使用的声音设备编号,
        在这个例子中是 <literal>4</literal>。 您可以在
        <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>贡献者</contrib>
      </author>
     </authorgroup>
    </sect2info>
    <title>利用多个声源</title>

    <para>通常而言, 会希望多个音源能够同时播放, 例如,
      <application>esound</application> 或者 <application>artsd</application>
      就可能不支持与其它程序共享音频设备。</para>

    <para>FreeBSD 可以通过 <emphasis>虚拟声道(Virtual Sound
      Channels)</emphasis> 来达到这样的效果, 它可以用 &man.sysctl.8; 来启用。
      虚拟的声道可以能过在内核里混合声音来混合声卡里播放的声道。</para>

    <para>使用三条sysctl命令来设置虚拟声道的数目。 如果您是
      <username>root</username> 用户, 执行下面的操作:</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>上面的实例设定了4个虚拟声道,这也是实际上所使用的数目。
      <varname>dev.pcm.0.play.vchans=4</varname><varname>dev.pcm.0.rec.vchans=4</varname><devicename>pcm0</devicename> 用来播放与录音的虚拟声道数,
      一当链接上一个设备它就可配置了。
      <literal>hw.snd.maxautovchans</literal> 是分配给新的音频设备的虚拟声道数,
      此时这个设备要用 &man.kldload.8; 来链接。 因为 <devicename>pcm</devicename>
      模块可以独立装载许多硬件驱动程序, 因此 <varname>hw.snd.maxautovchans</varname>
      也就可以存储分配给以后链接到的设备的虚拟声道数。
      可参阅 &man.pcm.4; 手册页义获取更多细节。</para>

    <note>
      <para>您不能在使用某个设备的时候改变其虚拟通道数。
	首先需要关闭所有使用该设备的程序, 如音乐播放器或声音服务。</para>
    </note>

    <para>当应用程序请求 <filename>/dev/dsp0</filename>
      时, 系统会自动为其分配正确的 <devicename>pcm</devicename>
      设备。</para>
   </sect2>

  <sect2>
    <sect2info>
      <authorgroup>
	<author>
	  <firstname>Josef</firstname>
	  <surname>El-Rayes</surname>
	  <contrib>这一节的作者是 </contrib>
	</author>
      </authorgroup>
    </sect2info>

    <title>如何设置混音器通道值</title>

    <para>不同的混音通道的默认音量是硬编码进 &man.pcm.4; 驱动程序的。
      同时, 也有很多应用或服务程序提供了允许用户直接设置并记住这些值的功能。
      不过这并不是一个很好的解决方案, 您可能希望在驱动一级有一个可以设置的默认值。
      这可以通过在 <filename>/boot/device.hints</filename> 定义适当的值来实现。
      例如:</para>

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

    <para>这将在 &man.pcm.4; 模块加载时, 将通道音量设置为默认的
      50</para>
  </sect2>
</sect1>

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

    <title>MP3音频</title>

    <para>MP3 (MPEG Layer 3 Audio)达到过CD音质的效果,FreeBSD工作站没理由会缺少这样的好东东。</para>

    <sect2 id="mp3-players">
      <title>MP3播放器</title>

      <para>目前为止, 最为流行的 X11 MP3 播放器是
	<application>XMMS</application> (X 多媒体系统)。
	<application>Winamp</application>
	的肤面可以直接用于 <application>XMMS</application>, 因为它的
	GUI 几乎和 Nullsoft 的
	<application>Winamp</application> 完全一样。 另外,
	<application>XMMS</application> 也提供了内建的插件支持。</para>

      <para><application>XMMS</application> 可以通过
	<filename role="package">multimedia/xmms</filename> port 或 package
	来安装。</para>

      <para><application>XMMS</application> 的界面很直观,
	它提供了播放列表、 图形化均衡器等等。
	如果您熟悉 <application>Winamp</application>, 就会感觉
	<application>XMMS</application> 很容易使用。</para>

      <para><filename role="package">audio/mpg123</filename> port
	提供了一个命令行界面的 MP3 播放器。</para>

      <para><application>mpg123</application>
	可以在执行时通过命令行指定声音设备和要播放的 MP3
	文件, 假设你的声音设备是 <devicename>/dev/dsp1.0</devicename>
        并且你想要播放的 MP3 文件为
        <replaceable>Foobar-GreatestHits.mp3</replaceable>
        你可以键入以下的命令:</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>抓取CD音轨</title>

      <para>在对CD或CD音轨编码成MP3之前, CD上的音频数据应先抓到硬盘里。
	这个可以通过复制原始的CDDA(CD数字音频)数据成为波形(WAV)文件。</para>

      <para>工具 <command>cdda2wav</command><filename role="package">sysutils/cdrtools</filename>
	套件的一部份,可用来从CD中获取音频及其相关信息。</para>

      <para>把CD放到光驱里,下面的命令可以完成 (作为 <username>root</username>用户)
	把整张 CD 分割成单个 (每个音轨) 的WAV文件:</para>

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

      <para><application>cdda2wav</application> 支持 ATAPI (IDE)光驱。
	从IDE光驱中抓取音轨, 需要用设备名称代替SCSI的单元号。 例如, 想从
	IDE 光驱中抓取第7道音轨:</para>

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

      <para>参数 <option>-D <replaceable>0,1,0</replaceable></option> 表示
	SCSI 设备 <devicename>0,1,0</devicename>, 与命令
	<command>cdrecord -scanbus</command> 的输出相对应。</para>

      <para>抓取单轨,要使用选项 <option>-t</option>,如下所示:</para>

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

      <para>这个实例用于抓取第七个音轨。要抓取一定范围的音轨,如从17</para>

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

      <para>利用&man.dd.1;也可以从ATAPI光驱中抓取音轨,从
	<xref linkend="duplicating-audiocds"/> 可以了解更多。</para>

    </sect2>

    <sect2 id="mp3-encoding">
      <title>MP3 编码</title>

      <para>现今,可选的MP3编码器是 <application>lame</application><application>Lame</application> 可以从ports树里的
	<filename role="package">audio/lame</filename> 处找到。</para>

      <para>利用抓取的WAV文件,下边的命令就可以把
	<filename><replaceable>audio01.wav</replaceable></filename>
	转换成 <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 是标准的MP3位率(bitrate)。
	许多人可能喜欢更高的品质例如 160 或 192。 更高的位率, 会使 MP3
	占用更多的磁盘空间--但音质会更高。选项 <option>-h</option> 控制
	<quote>高品质但低速度 (higher quality
	but a little slower)</quote> 模式的开关。 选项 <option>--t</option>
	表示把 ID3 标签--通常包含了歌曲的信息, 植入到MP3文件里。
	其它的编码选项可以查询 <application>lame</application> 的联机手册。</para>
    </sect2>

    <sect2 id="mp3-decoding">
      <title>MP3 解码</title>

      <para>要把MP3歌曲刻录成音乐CD,就需要把它转换成非压缩的波形(WAV)格式。
	<application>XMMS</application> 和
	<application>mpg123</application> 都支持把MP3输出成非压缩格式文件。</para>

      <para>在 <application>XMMS</application> 中输出到磁盘:</para>

      <procedure>
	<step>
	  <para>启动 <application>XMMS</application>.</para>
	</step>

	<step>
	  <para>在窗口里右击鼠标,弹出 <application>XMMS</application> 菜单。</para>
	</step>

	<step>
	  <para>在 <literal>选项(Options)</literal> 里选择
	    <literal>设定(Preference)</literal>。</para>
	</step>

	<step>
	  <para>改变输出插件成 <quote>写磁盘插件(Disk Writer
		  Plugin)</quote>。</para>
	</step>

	<step>
	  <para>按 <literal>配置(Configure)</literal>。</para>
	</step>

	<step>
	  <para>输入或选择一个目录用于存放解压的文件。</para>
	</step>

	<step>
	  <para>象平常一样,把MP3文件装入到 <application>XMMS</application> 里边,
	    把音量调节到100%并且关掉EQ设定。</para>
	</step>

	<step>
	  <para>按一下 <literal>播放(Play)</literal> &mdash;
	    <application>XMMS</application> 如同在播放mp3一样,只是听不到声音。
	    实际上是在播放mp3到一个文件里。</para>
	</step>

	<step>
	  <para>要想再听MP3歌曲,记得把默认的输出插件设回原来的值。</para>
	</step>
      </procedure>

      <para>用 <application>mpg123</application> 进行标准输出:</para>

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

      <para> <application>XMMS</application> 输出的文件是波形(WAV)格式,
	而 <application>mpg123</application> 则把MP3转换成无压缩的PCM
	音频数据。两种格式都支持用 <application>cdrecord</application>
	刻录成音乐CD。 使用 &man.burncd.8; 您就必须使用无压缩的PCM。
	如果选择波形格式, 就要注意在每道开始时的一小点杂音,
	这段声音是波形文件的头部份。 可以使用工具
	<application>SoX</application> 来轻松去除。
	<application>SoX</application> 可从 <filename role="package">audio/sox</filename>
	port 或包(package)中安装得到:</para>

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

      <para>阅读 <xref linkend="creating-cds"/> 这部份可以了解到更多在
	FreeBSD 里刻盘的信息。</para>
    </sect2>
 </sect1>

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

  <title>视频回放</title>

    <para>视频回放是个很新并且迅速发展中的应用领域。
      一定要有耐心,因为不是所有的事情都象处音频那么顺利。</para>

    <para>在开始之前,您要了解显卡的类型以及它所用的芯片的类型。
      尽管 <application>&xorg;</application>
      支持大量的显卡, 但能达到好的回放效果的却寥寥无几。
      在X11运行时,您可以使用命令 &man.xdpyinfo.1;
      获得使用您的显卡的X服务器所支持的扩展列表。</para>

    <para>为了评估各种播放器和设置,您需要有一小段用作测试的MPEG文件。
      由于一些DVD播放器会默认地在
      <filename>/dev/dvd</filename> 里去找DVD文件, 因此,
      您会发现建立符号链接到恰当的设备会很有用:</para>

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

    <para>注意:由于 &man.devfs.5; 本身的原因,
      像这样手工建立的链接在重启后将不会存在。
      想要无论什么时候您启动系统都能自动建立符号链接,
      那就把下边这行加到 <filename>/etc/devfs.conf</filename> 里边:</para>

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

    <para>另外,DVD解密要求调用专用的DVD-ROM函数,要求把许可定到DVD设备里。</para>

    <para>为了改善 X11 界面使用共享内存的能力, 建议提高一些 &man.sysctl.8; 变量的值:</para>

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

  <sect2 id="video-interface">
    <title>测定视频的性能</title>

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

    <para>在X11下有几种可以显示图像的方式。
      到底哪个能工作很大程度上依赖于硬件。 首先,
      下边描述的每一种方法在不同的硬件上都会有不同的品质。
      其次, 在X11里的图像显示近来引起普遍的关注,
      随着 <application>&xorg;</application> 的每一个版本,
      都会有很大的突破。</para>

    <para>常见图像接口列表:</para>

    <orderedlist>
    <listitem>
      <para>X11: 一般性的使用共享内存的X11输出。</para>
    </listitem>
    <listitem>
      <para>XVideo: 一种X11接口扩展,支持任何X11图像的可拖拉。</para>
    </listitem>
    <listitem>
      <para>SDL: 简单直接媒体层。</para>
    </listitem>
    <listitem>
      <para>DGA: 直接图片存取。</para>
    </listitem>
    <listitem>
      <para>SVGAlib: 低层次掌控图片层。</para>
    </listitem>
    </orderedlist>

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

      <para><application>&xorg;</application>
        有种扩展叫做 <emphasis>XVideo</emphasis>
        (或称Xvideo, Xv, xv),
        它可以通过一个特殊的加速器直接把图像显示在可拖拉的对象里。
        即使在低端的计算机 (例如我的PIII&nbsp;400&nbsp;Mhz膝上电脑),
        这个扩展也提供了很好的播放质量。</para>

      <para>要了解这一扩展是否在正常工作, 使用
      <command>xvinfo</command> 命令:</para>

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

      <para>如果显示结果如下,那您的显卡就支持XVideo:</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>同时注意:列出来的格式(YUV2, YUV12, 等等) 并不总是随着
      XVdieo的每一次执行而存在。没有它们可能会迷惑某些人。</para>

    <para>如果结果看起来是这样:</para>
<screen>X-Video Extension version 2.2
screen #0
no adaptors present</screen>

    <para>那么您的显卡可以就不支持XVideo功能。</para>

    <para>如果您的卡不支持XVideo,
      则只是说明您的显示器在满足刷新图像的计算要求上存在更大的困难。
      尽管显卡和处理器很重要,您仍然会有个不错的显示效果。
      此外, 您也可以参考我们提供的文献, 在 <xref
      linkend="video-further-reading"/> 中有所介绍。</para>

    </sect3>

    <sect3 id="video-interface-SDL">
    <title>简单直接媒体层</title>

    <para>简单直接媒体层(SDL),原意是做为 &microsoft.windows;、BeOS 以及 &unix;
      之间的端口层,允许跨平台应用发展,更高效地利用声卡和图形卡。SDL
      层可以在低层访问硬件, 有时这样做就比 X11 接口层更为高效。</para>

    <para>关于 SDL, 可以参考 <filename role="package">devel/sdl12</filename></para>

    </sect3>

    <sect3 id="video-interface-DGA">
    <title>直接图形存取</title>

    <para>直接图形存取 (Direct Graphics Access) 是一种 X11 扩展,
      通过它, 应用程序能够绕过 X 服务, 并直接修改画面缓存 (framebuffer)。
      由于它依赖一种底层的内存映射来实现其功能,
      因此使用它的程序必须以
      <username>root</username> 身份来执行。</para>

    <para>DGA 扩展可以通过
      &man.dga.1; 来完成测试和性能测量。 运行
      <command>dga</command> 时, 它将随按键改变现实的颜色。
      按 <keycap>q</keycap> 退出这个程序。</para>

    </sect3>

  </sect2>

  <sect2 id="video-ports">
    <title>Ports 和 包(Packages) 对视频的解决</title>

    <indexterm><primary>视频 ports</primary></indexterm>
    <indexterm><primary>视频 包</primary></indexterm>

    <para>这部份主要讨论在 FreeBSD Ports 集中提供的可用于视频回放的软件。
      视频回放在软件发展中是个很活跃的领域,
      并且各种不同程序的功能可能与这里的描述不尽相同。</para>

    <para>首先要弄清楚的重要一点是在 FreeBSD 上使用的视频程序其发展与在
      Linux 里使用的是一样的。 大部份程序都还处在β阶段。使用 FreeBSD
      的包可能面对的问题:</para>

      <orderedlist>

      <listitem>
        <para>一个应用程序不能播放其它程序制作的文件。</para>
      </listitem>

      <listitem>
        <para>一个应用程序不能播放其自已制作的文件。</para>
      </listitem>

      <listitem>
        <para>不同机上的同样的程序,各自重新建立(rebuild)了一次,
          播放同一个文件结果也会有不同。</para>
      </listitem>

      <listitem>
        <para>一个看起来没什么的过滤器, 如图像尺寸的调整,
          也有可能因为一个调整例程的问题变得很不象样。</para>
      </listitem>

      <listitem>
        <para>应用程序频繁地留下垃圾(dumps core)。</para>
      </listitem>

      <listitem>
        <para>没有随 port 一起安装的文档可以在网上或者
          port 的 <filename class='directory'>work</filename>
          目录中找到。</para>
      </listitem>

      </orderedlist>

    <para>这些程序中许多也体现了 <quote>Linux主义</quote>。即,
      有些问题来自于(程序)使用的标准库存在于Linux的发行版中,
      或者有些是 Linux 内核的功能, 而该程序的作者事先所假定了的是
      Linux内核。这些问题并不总是被 port 编护人员注意到或处理过,
      这也就可能导致如下问题:</para>

      <orderedlist>

      <listitem>
        <para>使用<filename>/proc/cpuinfo</filename>去检测处理器的特性。</para>
      </listitem>

      <listitem>
        <para>滥用线程可能导致一个程序悬挂完成,而不是完全中止。</para>
      </listitem>

      <listitem>
        <para>软件还不属于FreeBSD Ports集,而又与其它程序经常地一起使用。</para>
      </listitem>

      </orderedlist>

      <para>现在,这些程序的开发人员也已同 port 的维护人员进行了联合,
        以减少制作port时出错。</para>

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

      <para><application>MPlayer</application>
        是近来开发的同时也正迅速发展着的一个视频播放器。
        <application>MPlayer</application> 团队的目标是在
        Linux 和其它 UNIX 系统中的速度和机动性能。
        在团队的创始人实在受不了当时可用的播放器的性能时,
        这个计划就开始了。 有人也许会说图形接口已经成为新型设计的牺牲品。
        但是一旦您习惯了命令行选项和按键控制方式,它就能表现得很好。</para>

      <sect4 id="video-mplayer-building">
        <title>创建MPlayer</title>
        <indexterm><primary>MPlayer</primary>
	           <secondary>making</secondary></indexterm>

	<para><application>MPlayer</application> 可以从 <filename
	  role="package">multimedia/mplayer</filename> 找到。
	  <application>MPlayer</application> 在联编过程中会进行许多硬件检测,
	  而得到的可执行文件因此将无法移植到其他系统中使用。
	  因此, 从 ports 完成联编而不是安装预编译的包就很重要。
	  另外, 在 <command>make</command> 命令行还可以指定许多选项,
	  在 <filename>Makefile</filename> 中有所描述, 接下来我们开始联编:</para>

	<screen>&prompt.root; <userinput>cd /usr/ports/multimedia/mplayer</userinput>
&prompt.root; <userinput>make</userinput>
N - O - T - E

Take a careful look into the Makefile in order
to learn how to tune mplayer towards you personal preferences!
For example,
make WITH_GTK1
builds MPlayer with GTK1-GUI support.
If you want to use the GUI, you can either install
/usr/ports/multimedia/mplayer-skins
or download official skin collections from
http://www.mplayerhq.hu/homepage/dload.html
</screen>

	<para>默认的 port 选项对于绝大多数用户来说是够用了。
	  不过, 如果您需要 XviD 编解码器, 则必须指定
	  <makevar>WITH_XVID</makevar> 这个命令行选项。
	  默认的 DVD 设备也可以用 <makevar>WITH_DVD_DEVICE</makevar>
	  选项来定义, 其默认值是 <filename>/dev/acd0</filename></para>

        <para>撰写这一章的时候, <application>MPlayer</application> port 的联编过程包括了
          HTML 文档和两个可执行文件,
          <command>mplayer</command><command>mencoder</command>, 后者是一个视频再编码工具。</para>

        <para><application>MPlayer</application> 的 HTML 文档提供了丰富的内容。
          如果读者发现本章中缺少关于视频硬件的一些信息,
          则 <application>MPlayer</application> 的文档将是十分详尽的补充。
          如果您正在找关于 &unix; 中的视频支持的资料,
          您绝对应该花一些时间来阅读 <application>MPlayer</application>
          的文档。</para>

      </sect4>

      <sect4 id="video-mplayer-using">
        <title>使用MPlayer</title>
        <indexterm><primary>MPlayer</primary>
	           <secondary>使用</secondary></indexterm>

        <para>任何 <application>MPlayer</application> 用户必须在其用户主目录下建立一个叫
	  <filename>.mplayer</filename> 的子目录。
	  输入下边的内容来建立这个必须的子目录:</para>

<screen>&prompt.user; <userinput>cd /usr/ports/multimedia/mplayer</userinput>
&prompt.user; <userinput>make install-user</userinput></screen>

	<para><command>mplayer</command> 的手册里列出了它的命令选项。
	  HTML文档里有更为详细的信息。 这部份里, 我们只是描述了很少的常见应用。</para>

	<para>要播放一个文件,如
	  <filename><replaceable>testfile.avi</replaceable></filename>,
	  可以通过各种视频接口当中的某一个去设置 <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>所有这些选项都是值得一试的,
	  因为它们的性能依赖很多因素,并且都与硬件密切相关。</para>

	<para>要播放 DVD, 需要把
	 <filename><replaceable>testfile.avi</replaceable></filename> 改为
	 <option>dvd://<replaceable>N</replaceable> -dvd-device
	 <replaceable>DEVICE</replaceable></option>。 这里 <replaceable>N</replaceable>
	 是要播放的节目编号, 而
	 <filename><replaceable>DEVICE</replaceable></filename> 则是
	 DVD-ROM 的设备节点。 例如, 要播放 <filename>/dev/dvd</filename>
	 的第三个节目:</para>

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

	<note>
	  <para>可以在编译 <application>MPlayer</application> 时, 通过
	    <makevar>WITH_DVD_DEVICE</makevar> 来指定默认的
	    DVD 设备。 系统内定的默认设备是 <filename>/dev/acd0</filename>。
	    更多细节, 请参考 port 的
	    <filename>Makefile</filename></para>
	</note>

	<para>要停止、暂停、前进等等,可以参考设定的按键---这些可以通过
	  <command>mplayer -h</command> 得到或查看手册。</para>

	<para>另外,回放的重要选项是:用于全屏模式的 <option>-fs -zoom</option>
	  和起辅助完成作用的<option>-framedrop</option></para>

	<para>为了让 mplayer 的命令行不是太长,使用者可以通过建立一个文件
	  <filename>.mplayer/config</filename> 来设定如下默认选项:</para>
<programlisting>vo=xv
fs=yes
zoom=yes</programlisting>

	<para>最后,<command>mplayer</command> 可以把DVD题目(title)抓取成为
	  <filename>.vob</filename> 文件。为了从DVD中导出第二个题目,请输入:</para>

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

        <para>输出文件 <filename>out.vob</filename> 将是 MPEG
	  并且可以被这部份描述的其它 <quote></quote> 利用。</para>

      </sect4>
      <sect4 id="video-mencoder">
        <title>mencoder</title>
        <indexterm>
	  <primary>mencoder</primary>
	</indexterm>

	<para>在使用
         <command>mencoder</command> 之前, 首先熟悉其 HTML
	 文档中所介绍的选项是一个不错的主意。 它提供了联机手册,
	 但如果没有 HTML 文档则帮助不大。 有无数种方法来提高视频品质、
	 降低比特率、 修改格式, 而这些技巧可能会影响性能。
	 下面是几个例子, 第一个是简单地复制:</para>

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

         <para>不正确的命令选项组合可能使生成的文件不能被
	   <command>mplayer</command> 播放。因此,如果您只是想抓取文件,
	   一定在 <command>mplayer</command> 里使用
	   <quote><option>-dumpfile</option></quote></para>

	 <para>转换 <filename><replaceable>input.avi</replaceable></filename>
	   成为带有MPEG3音频编码 (要求
	   <filename role="package">audio/lame</filename> )
	   的MPEG4编码:</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>这样就产生了可被 <command>mplayer</command><command>xine</command>播放的输出。</para>

	 <para><filename><replaceable>input.avi</replaceable></filename> 可以换成
	   <option>dvd://1 -dvd-device /dev/dvd</option> 并以
	   <username>root</username> 的身份来执行, 以重新对 DVD 节目进行编码。
	   由于您第一次做这样的工作时很可能会对结果不太满意,
	   建议您首先把节目复制成文件, 然后对它进行操作。</para>
      </sect4>

    </sect3>

    <sect3 id="video-xine">
    <title>xine视频播放器</title>

    <para><application>xine</application> 视频播放器是一个关注范围很广的项目,
      它不仅看准多合一的视频解决,
      而且出品了一个可再用的基本库和一个可扩展插件的可执行模块。
      发行有 <quote></quote> 和port版本--
      <filename role="package">multimedia/xine</filename></para>

    <para><application>xine</application> 播放器仍然很粗糙,
      但这很显然与好开头无关。实际上 <application>xine</application>
      要求你有快速的 CPU 和快速的显卡来运行,或者需要支持 XVideo 扩展。
      图形界面(GUI)可以使用,但很勉强。</para>

    <para>到写这章时,还没有可用于播放CSS编码的DVD文件的输入模块随同
	   <application>xine</application> 一起发行。
	   第三方的建造(builds)里内建有这样的模块,
	   但都不属于FreeBSD Ports 集。</para>

    <para><application>MPlayer</application> 相比,
      <application>xine</application> 为用户考虑得更多,
      但同时,对用户来说也少了很多有条理的控制方式。
      <application>xine</application> 播放器在XVideo接口上做得不错。</para>

    <para>默认情况下,播放器 <application>xine</application>
      启动的时候会使用图形界面。那么就可以使用菜单打开指定的文件:</para>

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

    <para>另外,没有图形界面也可以使用如下命令立即打开播放文件:</para>

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

    </sect3>

    <sect3 id="video-ports-transcode">
    <title>使用transcode</title>

    <para><application>transcode</application> 这个软件并不是播放器,
      而是一系列用于对视频和音频文件进行重新编码的工具。
      通过使用 <application>transcode</application>,
      就可以拥有使用带 <filename>stdin/stdout</filename>
      接口的命令行工具来合并视频文件, 以及修复坏损文件的能力。</para>

    <para>在联编 <filename
      role="package">multimedia/transcode</filename> port 时可以指定大量选项,
      我们建议使用下面的命令行来构建
      <application>transcode</application></para>

    <screen>&prompt.root; <userinput>make WITH_OPTIMIZED_CFLAGS=yes WITH_LIBA52=yes WITH_LAME=yes WITH_OGG=yes \
WITH_MJPEG=yes -DWITH_XVID=yes</userinput></screen>

    <para>对于多数用户而言, 前述配置已经足够了。</para>

    <para>为了说明 <command>transcode</command> 的功能,
      下面的例子展示了如何将 DivX 转换为 PAL MPEG-1 文件 (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>生成的 MPEG 文件,
      <filename><replaceable>output_vcd.mpg</replaceable></filename>, 可以通过
      <application>MPlayer</application> 来播放。
      您甚至可以直接将这个文件刻录到 CD-R 介质上来创建 Video CD,
      如果希望这样做的话, 需要安装 <filename
      role="package">multimedia/vcdimager</filename><filename
      role="package">sysutils/cdrdao</filename> 这两个程序。</para>

    <para><command>transcode</command> 提供了联机手册, 但您仍应参考 <ulink
      url="http://www.transcoding.org/cgi-bin/transcode">transcode
      wiki</ulink> 以了解更多信息和例子。</para>
    </sect3>

  </sect2>

  <sect2 id="video-further-reading">
    <title>进一步了解</title>

    <para>FreeBSD里不同的视频软件包正迅速发展中。
      很可能在不久的将来,这里所谈到的问题都将得到解决。
      同时,有些人想超越FreeBSD的音/像(A/V)能力,
      那他们就不得不从一些FAQ和指南里学知识,
      并使用一些不同的应用程序。
      这里就给这些读者指出一些补充信息。</para>

    <para><ulink url="http://www.mplayerhq.hu/DOCS/"> MPlayer 文档 </ulink>
      是很技术性的。
      这些文档可以给那些希望获得关于&unix;视频高级技术的人们提供参考。
      <application>MPlayer</application> 邮件列表很不喜欢没耐心阅读文档的人,
      如果您发现什么问题想报告给他们,请首先RTFM。</para>

    <para><ulink url="http://dvd.sourceforge.net/xine-howto/en_GB/html/howto.html">xine HOWTO</ulink>
      里边有一章是关于提高性能的,对所有的播放器都很适应。</para>

    <para>最后是一些很有前途的程序,读者可以试一下:</para>

    <itemizedlist>

       <listitem>
         <para><ulink
	   url="http://avifile.sourceforge.net/">Avifile</ulink>,它就是 <filename
	   role='package'>multimedia/avifile</filename> port。</para>
       </listitem>

       <listitem>
         <para><ulink
	   url="http://www.dtek.chalmers.se/groups/dvd/">Ogle</ulink>
	   它就是 <filename
	   role='package'>multimedia/ogle</filename> port。</para>
       </listitem>

       <listitem>
         <para><ulink url="http://xtheater.sourceforge.net/">Xtheater</ulink></para>
       </listitem>

	<listitem>
         <para><filename
           role="package">multimedia/dvdauthor</filename>,
	   一个制作 DVD 节目的源码开放包。</para>
        </listitem>

    </itemizedlist>

  </sect2>
 </sect1>

  <sect1 id="tvcard">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Josef</firstname>
	  <surname>El-Rayes</surname>
	  <contrib>原创: </contrib>
	</author>
      </authorgroup>
      <authorgroup>
	<author>
	  <firstname>Marc</firstname>
	  <surname>Fonvieille</surname>
	  <contrib>改编:</contrib>
	  <!-- 02 January 2004 -->
	</author>
      </authorgroup>
    </sect1info>

    <title>安装电视卡</title>
    <indexterm>
      <primary>电视卡</primary>
    </indexterm>

    <sect2>
      <title>介绍</title>

      <para>电视卡可以让您在您的计算机里观看到无线或有线电视。
	许多卡是通过RCA或S-video输入接收复合视频,
	而且有些卡还带有调频广播接收器。</para>

      <para>&os; 通过&man.bktr.4;驱动程序,提供了对基于PCI的电视卡的支持,
	要求这些卡使用的是Brooktree Bt848/849/878/879 或
	Conexant CN-878/Fusion 878a视频采集芯片。
	您还要确保这个板上带的有被支持的调谐器,
	参考&man.bktr.4;手册查看所支持的调谐器列表。</para>
    </sect2>

    <sect2>
      <title>增加驱动程序</title>

      <para>要使用您的卡,您就要装载&man.bktr.4;驱动程序。
	这个可以通过往 <filename>/boot/loader.conf</filename>
	里边添加下边一行来实现。象这样:</para>

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

      <para>另外,您也可以把这个驱动编译进内核,
	要是这样的话,就把下边几行加到内核配置里去:</para>

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

      <para>这些附加的设备驱动程序是必须的,
	因为卡的各组成部分是能过一根I2C总线相互连接在一起的。
	然后建立安装新的内核。</para>

      <para>一旦这个支持被加到了您的系统里,您须要重启系统。
	在启动过程中,您的电视卡应该显示为up(启动),象这样:</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>当然,这些信息可能因您的硬件不同而有所区别。
	但是您应该能检查那个调制器是否被正确检测到了,
	可能要忽略一些检测到的同&man.sysctl.8;
	MIB(管理系统库)和内核配置文件选项一起的参数。
	例如,如果您想强制使用Philips(飞利浦) SECAM制式的调谐器 ,
	您就应把下列行加到内核配置文件里:</para>

      <programlisting>options OVERRIDE_TUNER=6</programlisting>

      <para>或者,您直接使用&man.sysctl.8;:</para>

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

      <para>请参见 &man.bktr.4; 手册和
	<filename>/usr/src/sys/conf/NOTES</filename> 文件,
	以了解更多详细关于可用选项的资料。</para>
    </sect2>

    <sect2>
      <title>有用的应用程序</title>

      <para>要使用您的电视卡,您需要安装下列应用程序之一:</para>

      <itemizedlist>
	<listitem>
	  <para><filename role="package">multimedia/fxtv</filename>
	    提供 <quote>窗口电视(TV-in-a-window)</quote>
	    功能和图像/声音/图像采集功能。</para>
	</listitem>
	<listitem>
	  <para><filename role="package">multimedia/xawtv</filename>
	    也是一款电视应用程序,功能同
	    <application>fxtv</application> 一样。</para>
	</listitem>
	<listitem>
	  <para><filename role="package">misc/alevt</filename>
	    解码和显示Videotext/Teletext。</para>
	</listitem>
	<listitem>
	  <para><filename role="package">audio/xmradio</filename>,
	    一款用于一些电视卡的调频电台调谐器的程序。</para>
	</listitem>
	<listitem>
	  <para><filename role="package">audio/wmtune</filename>,
	    一款用于电台调谐器的便捷的桌面程序。</para>
	</listitem>
      </itemizedlist>

      <para>更多的程序在&os; Ports Collection(Ports 集)里。</para>
    </sect2>

    <sect2>
      <title>问题解决</title>

      <para>如果您的电视卡遇到了什么问题,
	您应该首先检查一下您的视频采集芯片和调谐器是不是真正的被&man.bktr.4;
	驱动程序支持,并且是不是使用了正确的配置选项。
	想得到更多支持和关于您的电视卡的各种问题,
	您可以接触和使用&a.multimedia.name; 邮件列表的压缩包。</para>
    </sect2>
  </sect1>

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

    <title>图象扫描仪</title>
    <indexterm>
      <primary>图象扫描仪</primary>
    </indexterm>

    <sect2>
      <title>介绍</title>

      <para>&os; 中, 访问扫描仪的能力,
	是通过 <application>SANE</application> (Scanner Access Now
	Easy) <acronym role="Application Programming
	Interface">API</acronym> 提供的。
	<application>SANE</application> 也会使用一些
	&os; 设备驱动来访问扫描仪硬件。</para>

      <para>&os; 支持 SCSI 和 USB 扫描仪。
	在做任何配置之前请确保您的扫描仪被 <application>SANE</application>
	支持。 <application>SANE</application> 有一个 <ulink
	url="http://www.sane-project.org/sane-supported-devices.html">
	支持的设备</ulink> 列表,
	可以为您提供有关扫描仪的支持情况和状态的信息。
	在 &os;&nbsp;8.X 之前版本的系统中,
	&man.uscanner.4; 手册页也提供了系统支持的 USB 扫描仪列表。</para>
    </sect2>

    <sect2>
      <title>内核配置</title>

      <para>上面提到 SCSI 和 USB 接口都是支持的。
	取决于您的扫描仪接口,
	需要不同的设备驱动程序。</para>

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

	<para>默认的 <filename>GENERIC</filename>
	  内核包含了支持 USB 扫描仪需要的设备驱动。
	  如果您决定使用一个定制的内核,
	  确保下面在您的内核配置文件中存在下面这些行:</para>

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

	<para>&os;&nbsp;8.X 之前的版本中, 还需要下面这行配置:</para>

	<programlisting>device uscanner</programlisting>

	<para>在这些 &os; 版本中, 是通过设备驱动程序 &man.uscanner.4;
	  来提供对 USB 扫描仪的支持的。 从
	  &os;&nbsp;8.0 开始, 这些支持则直接由
	  &man.libusb.3; 函数库提供。</para>

	<para>使用正确的内核重新引导系统之后, 插入 USB 扫描仪。
	  系统消息缓冲区 (使用 &man.dmesg.8; 查看)
	  中会出现下面的信息, 表示检测到了扫描仪:</para>

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

	<para>或者, 对于 &os;&nbsp;7.X 系统而言:</para>

	<screen>uscanner0: EPSON EPSON Scanner, rev 1.10/3.02, addr 2</screen>

	<para>&os; 版本不同, 这些信息表示扫描仪设备位于设备节点
	  <filename>/dev/ugen0.2</filename><filename>/dev/uscanner0</filename>。 在这个例子中, 我们使用的是
	  &epson.perfection;&nbsp;1650 USB 扫描仪。</para>
      </sect3>

      <sect3>
	<title>SCSI 接口</title>

	<para>如果您的扫描仪是 SCSI 接口的,
	  重要的是要知道您使用哪种 SCSI 控制器。
	  取决于所使用的 SCSI 芯片,
	  您需要调整内核配置文件。
	  <filename>GENERIC</filename> 的内核支持最常用的
	  SCSI 控制器。 请阅读
	  <filename>NOTES</filename> 文件并在您的内核配置文件中添加正确的行。
	  除了 SCSI 适配器驱动之外,
	  您还需要在内核配置文件中增加下述配置:</para>

	<programlisting>device scbus
device pass</programlisting>

	<para>在正确地联编并安装了内核之后, 就应该可以在系统启动时,
	  从系统消息缓冲中看到这些设备:</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>如果您的扫描仪没有在系统启动的时候加电,
	  很可能还需要强制手动检测一下,用 &man.camcontrol.8;
	  命令执行一次 SCSI 总线扫描:</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>然后扫描仪就会出现在 SCSI 设备列表里:</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>有关 SCSI 设备的更多细节, 可查看
	  &man.scsi.4; 和 &man.camcontrol.8; 手册页。</para>
      </sect3>
    </sect2>

    <sect2>
      <title>SANE 配置</title>

      <para><application>SANE</application> 系统分为两部分:
	后端 (<filename
	role="package">graphics/sane-backends</filename>)
	和前端 (<filename
	role="package">graphics/sane-frontends</filename>)。
	后端部分提供到扫描仪自身的访问。
	<application>SANE</application><ulink
	url="http://www.sane-project.org/sane-supported-devices.html">
	支持设备</ulink>列表详细说明了哪一个后端可以支持您的图象扫描仪。
	如果您想使用您的设备,就必须为您的扫描仪选定正确的后端。
	前端部分提供图形化的扫描界面
	(<application>xscanimage</application>)。</para>

      <para>要做的第一步就是安装 <filename
	role="package">graphics/sane-backends</filename> port 或者
	package。然后,使用 <command>sane-find-scanner</command>
	命令来检查 <application>SANE</application>
	系统做的扫描仪检测:</para>

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

      <para>输出显示了扫描仪的接口类型和扫描仪连接到系统上的设备节点。
	生产厂家和产品型号可能没有显示,不过不重要。</para>

      <note>
	<para>一些 USB 扫描仪需要您加载固件,后端的手册页中有这方面的解释。
	  您也应该阅读 &man.sane-find-scanner.1; 和 &man.sane.7;
	  手册页。</para>
      </note>

      <para>现在我们需要检查扫描仪是否可以被扫描前端识别。
	默认情况下,
	<application>SANE</application> 后端自带一个叫做
	&man.scanimage.1; 的命令行工具。
	这个命令允许您列出设备以及从命令行执行图片扫描。
	<option>-L</option> 选项用来列出扫描仪设备:</para>

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

      <para>或者, 如果使用的是 <xref
	linkend="scanners-kernel-usb"/> 中的 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>上述输出来自于 &os;&nbsp;8.X 系统。
	<literal>'epson2:libusb:/dev/usb:/dev/ugen0.2'</literal>
	给出了扫描仪所使用的后台名字 (<literal>epson2</literal>)
	和设备节点 (<literal>/dev/ugen0.2</literal>)。</para>

      <note>
      <para>如果没有输出任何信息, 或提示没有识别到扫描仪,
	则说明 &man.scanimage.1; 无法识别它。
	如果发生这种情况, 您就需要修改扫描仪支持后端的配置文件,
	并定义所使用的扫描设备。 <filename
	class="directory">/usr/local/etc/sane.d/</filename>
	目录中包含了所有的后端配置文件。
	这类识别问题经常会在某些 USB
	扫描仪上发生。</para>

      <para>
	linkend="scanners-kernel-usb"> 中所使用的 USB 扫描仪,
	<command>sane-find-scanner</command> 会给出下面的信息:</para>
      <para>例如, 对于在 <xref
	linkend="scanners-kernel-usb"/>, 在 &os;&nbsp;8.X 中,
	扫描仪已经被很好地识别并能够正常工作了; 而对于更早版本的 &os;
	而言 (使用 &man.uscanner.4; 驱动程序)
	<command>sane-find-scanner</command> 则会给出这样的信息:</para>

      <screen>&prompt.root; <userinput>sane-find-scanner -q</userinput>
found USB scanner (UNKNOWN vendor and product) at device /dev/uscanner0</screen>
      <para>扫描仪被正确的探测到了,它使用 USB
	接口,连接在
	<filename>/dev/uscanner0</filename> 设备节点上。
	我们现在可以检查看看扫描仪是否被正确的识别:</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>由于扫描仪没有识别成功, 我们就需要编辑
	<filename>/usr/local/etc/sane.d/epson2.conf</filename>
	文件。 所用的扫描仪型号是 &epson.perfection;&nbsp;1650,
	这样我们知道扫描仪应使用 <literal>epson</literal>
	后端。确保阅读后端配置文件中的帮助注释。
	改动非常简单:注释掉导致您的扫描仪使用错误接口的所有行
	(在我们这种情况下,我们将注释掉从
	<literal>scsi</literal> 开始的所有行,因为我们的扫描仪使用 USB
	接口),然后在文件的结尾添加指定的接口和所用的设备节点。
	这种情况下, 添加下面这行:</para>

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

      <para>请确保阅读后端配置文件提供的注释以及后端手册页了解更多细节,
	并使用正确的语法。我们现在可以检验扫描仪是否被识别到了:</para>

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

      <para>我们的 USB 扫描仪被识别到了。 此时如果商标和型号与扫描仪的实际情况不符,
	并不会带来太大的麻烦。 您需要关注的是
	<literal>`epson:/dev/uscanner0'</literal> 字段,
	这个给了我们正确地后端名称和正确的设备节点。</para>
      </note>

      <para>一旦 <command>scanimage -L</command> 命令可以看到扫描仪,
	配置就完成了。设备现在准备好等待扫描了。</para>

      <para>&man.scanimage.1; 允许我们从命令行执行图片扫描,
	相比之下使用图形用户界面来执行图片扫描会更好。
	<application>SANE</application> 提供了一个简单但实用的图形界面:
	<application>xscanimage</application>
	(<filename
	role="package">graphics/sane-frontends</filename>)。</para>

      <para><application>Xsane</application> (<filename
	role="package">graphics/xsane</filename>)是另一个流行的图形扫描前端。
	这个前端提供了一些高级特性,
	比如多样的扫描模式(photocopy,fax,等。),
	色彩校正,批量扫描,等等。这两个程序都可以作为
	<application>GIMP</application>
	的插件使用。</para>
    </sect2>

    <sect2>
      <title>授权其他用户访问扫描仪</title>

      <para>前面所有的操作都是用
	<username>root</username> 权限来完成的。
	然而您可能需要让其他的用户也可以访问扫描仪。
	用户需要有扫描仪所用的设备节点的读和写权限。
	比如,我们的 USB 扫描仪使用设备节点
	<filename>/dev/ugen0.2</filename>
	实际上只是到实际设备节点
	<filename>/dev/usb/0.2.0</filename> 的符号连接
	(可以通过查看 <filename class="directory">/dev</filename>
	目录的内容来确认这一点)。 设备节点本身和这个符号连接分别属于
	<groupname>wheel</groupname><groupname>operator</groupname> 组。 将用户
	<username><replaceable>joe</replaceable></username> 添加到
	这些组中, 就可以允许他使用扫描仪了, 不过,
	出于显而易见的安全方面的原因, 在将用户加到特定的用户组, 特别是
	<groupname>wheel</groupname> 组时, 无疑需三思而后行。
	更好的解决方法是创建一个专门用于访问 USB 设备的组,
	并让这个组的成员能够访问 USB 设备。</para>

      <para>这里作为示例, 我们将会使用名为
	<groupname><replaceable>usb</replaceable></groupname> 的组。
	第一步是借助
	&man.pw.8; 命令来创建它:</para>

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

      <para>接下来, 令 <filename>/dev/ugen0.2</filename>
	符号连接和 <filename>/dev/usb/0.2.0</filename> 设备节点能够以 <groupname>usb</groupname> 组的身份来访问,
	具体而言是配置正确的写权限 (<literal>0660</literal><literal>0664</literal>), 因为默认情况下只有属主 (<username>root</username>)
	才能写这些设备。 这些配置是通过在
	<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>&os;&nbsp;7.X 用户需要将上面的配置改为使用与之对应的
	<filename>/dev/uscanner0</filename></para>

      <programlisting>[system=5]
add path uscanner0 mode 660 group usb</programlisting>

      <para>随后您还需要在
	<filename>/etc/rc.conf</filename>
	中添加下面的内容并重新启动:</para>

      <programlisting>devfs_system_ruleset="system"</programlisting>

      <para>关于这些配置的进一步细节请参考联机手册
	&man.devfs.8;。</para>

      <para>现在, 只需将用户添加到
	<groupname><replaceable>usb</replaceable></groupname> 组,
	就可以使用扫描仪了:</para>

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

      <para>更多详情, 请参见联机手册 &man.pw.8;。</para>
    </sect2>
  </sect1>
</chapter>