diff --git a/documentation/content/zh-tw/books/handbook/multimedia/_index.adoc b/documentation/content/zh-tw/books/handbook/multimedia/_index.adoc index cdb453fddb8..360efbdaccf 100644 --- a/documentation/content/zh-tw/books/handbook/multimedia/_index.adoc +++ b/documentation/content/zh-tw/books/handbook/multimedia/_index.adoc @@ -9,7 +9,7 @@ path: "/books/handbook/multimedia/" --- [[multimedia]] -= 多媒體 += Multimedia :doctype: book :toc: macro :toclevels: 1 @@ -46,1006 +46,708 @@ toc::[] include::../../../../../shared/asciidoctor.adoc[] endif::[] + [[multimedia-synopsis]] == 概述 -FreeBSD 廣泛地支援各種音效卡, 讓使用者可以享受來自電腦上的高傳真音質(Hi-Fi), 此外還包括了錄製和播放 MPEG Audio Layer 3 (MP3)、 Waveform Audio File (WAV)、Ogg Vorbis 以及其他許多種格式聲音的能力。同時 FreeBSD Port 套件集也包含了許多可讓您可以錄音、編修音效以及控制 MIDI 配備的應用程式。 - -FreeBSD 也能播放一般的視訊檔和 DVD。 FreeBSD Port 套件集中含有可編碼、轉換以及播放格種影像媒體的應用程式。 - -本章會說明如何設定 FreeBSD 上的音效卡、影像播放器、電視卡及掃描器。同時會說明有那些應用程式可以使用這些裝置。 - -讀完這章,您將了解: - -* 設定 FreeBSD 上的音效卡。 -* 音效設定疑難排解。 -* 播放、錄製 MP3 及其他聲音檔案格式。 -* FreeBSD 系統播放影像的準備工具。 -* 播放 DVD 的 [.filename]#.mpg# 及 [.filename]#.avi# 檔。 -* 擷取(Rip) CD 和 DVD的內容至檔案。 -* 設定電視卡。 -* 在 FreeBSD 安裝 MythTV -* 設定影像掃描機。 -* 設定藍芽耳機。 - -在開始閱讀這章之前,您需要: - -* 知道如何安裝應用程式如 crossref:ports[ports,安裝應用程式:套件與 Port] 所敘述。 +此章節提供了 FreeBSD 對於多媒體支援的概述。 +多媒體應用程式和技術已成為現今電腦的不可或缺的部分,而 FreeBSD 提供了廣泛且可靠的多媒體硬體和軟體支援。 +此章節涵蓋了各種多媒體元件,如音訊、視頻和影像處理。 +同時也討論了各種媒體格式和編解碼器,以及用於多媒體創作和播放的工具和應用程式。 +此外,該章節還介紹了多媒體系統的配置、故障排除和優化。 +無論你是多媒體愛好者還是專業內容創作者,FreeBSD 都為多媒體工作提供了一個強大的平台。本章旨在幫助你充分利用 FreeBSD 的多媒體功能,提供有用的信息和實用的範例來幫助你入門。 [[sound-setup]] == 設定音效卡 -開始設定之前,必須先知道你的音效卡型號、晶片為何。 FreeBSD 支援許多種音效卡,請檢查支援的音效硬體表 https://www.FreeBSD.org/releases/12.0r/hardware/[Hardware Notes],以確認你的音效卡是否支援以及如何在 FreeBSD 上驅動。 - -要使用音效裝置,必須要載入正確的驅動程式才行。最簡單方式就是以 man:kldload[8] 來載入核心模組。以下範例示範載入 Intel 規格內建的音效晶片驅動程式: - -[source,shell] -.... -# kldload snd_hda -.... +預設情況下,FreeBSD 會自動偵測系統所使用的音效卡。 +FreeBSD 支援各式各樣的音效卡。 +支援的音效卡清單可以參考 man:sound[4]。 -要開機時自動載入驅動程式,需將驅動程式加到 [.filename]#/boot/loader.conf# 檔,以此驅動程式為例: - -[.programlisting] -.... -snd_hda_load="YES" -.... +[NOTE] +==== +只有在 FreeBSD 未正確偵測到音效卡模組時,才需要載入音效卡模組。 +==== -其他可用的音效卡模組清單列於 [.filename]#/boot/defaults/loader.conf#。當不確認要使用何種驅動程式時,可載入 [.filename]#snd_driver# 模組: +如果不知道系統使用哪一塊音效卡或哪一個模組,可以執行下列指令載入 metadriver `snd_driver` : [source,shell] .... # kldload snd_driver .... -它是 metadriver 會載入所有最通用的音效驅動程式並且用來加速尋找正確的驅動程式。也可以把 metadriver 加入 [.filename]#/boot/loader.conf# 檔來載入所有音效驅動程式。 - -要知道載入 [.filename]#snd_driver# metadriver 後使用了那個音效卡驅動程式,請輸入 `cat /dev/sndstat`。 - -=== 設定自訂核心支援音效 - -This section is for users who prefer to statically compile in support for the sound card in a custom kernel. For more information about recompiling a kernel, refer to crossref:kernelconfig[kernelconfig,設定 FreeBSD 核心]. - -When using a custom kernel to provide sound support, make sure that the audio framework driver exists in the custom kernel configuration file: - -[.programlisting] -.... -device sound -.... - -Next, add support for the sound card. To continue the example of the built-in audio chipset based on the Intel specification from the previous section, use the following line in the custom kernel configuration file: +另外,若要在開機時以模組方式載入驅動程式,請在 [.filename]#/boot/loader.conf# 中加入: [.programlisting] .... -device snd_hda +snd_driver_load="YES" .... -Be sure to read the manual page of the driver for the device name to use for the driver. +[[sound-testing]] +=== 測試音效 -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#. During the boot process, man:loader[8] reads this file and passes the settings to the kernel. For example, an old Creative SoundBlaster(TM) 16 ISA non-PnP card will use the man:snd_sbc[4] driver in conjunction with `snd_sb16`. For this card, the following lines must be added to the kernel configuration file: +若要確認偵測到音效卡,可執行下列指令: -[.programlisting] +[source,shell] .... -device snd_sbc -device snd_sb16 +% dmesg | grep pcm .... -If the card uses the `0x220` I/O port and IRQ `5`, these lines must also be added to [.filename]#/boot/device.hints#: +輸出應與下列內容相似: [.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" -.... - -The syntax used in [.filename]#/boot/device.hints# is described in man:sound[4] and the manual page for the driver of the sound card. - -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. - -[[sound-testing]] -=== 測試音效 - -After loading the required module or rebooting into the custom kernel, the sound card should be detected. To confirm, run `dmesg | grep pcm`. This example is from a system with a built-in Conexant CX20590 chipset: - -[source,shell] -.... -pcm0: at nid 5 on hdaa0 -pcm1: at nid 6 on hdaa0 -pcm2: at nid 31,25 and 35,27 on hdaa1 +pcm0: at nid 26,22 and 24 on hdaa0 +pcm1: at nid 29 on hdaa0 .... -The status of the sound card may also be checked using this command: +也可以使用此指令檢查音效卡的狀態: [source,shell] .... # cat /dev/sndstat -FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64) -Installed devices: -pcm0: (play) -pcm1: (play) -pcm2: (play/rec) default .... -The output will vary depending upon the sound card. If no [.filename]#pcm# devices are listed, double-check that the correct device driver was loaded or compiled into the kernel. The next section lists some common problems and their solutions. +輸出應與下列內容相似: -If all goes well, the sound card should now work in FreeBSD. If the CD or DVD drive is properly connected to the sound card, one can insert an audio CD in the drive and play it with man:cdcontrol[1]: - -[source,shell] +[.programlisting] .... -% cdcontrol -f /dev/acd0 play 1 +Installed devices: +pcm0: (play/rec) default +pcm1: (rec) .... -[WARNING] -==== +如果沒有列出 `pcm` 裝置,請再次檢查是否載入了正確的裝置驅動程式。 +如果一切順利,音效卡就可以在 FreeBSD 運作了。 -Audio CDs have specialized encodings which means that they should not be mounted using man:mount[8]. -==== - -Various applications, such as package:audio/workman[], provide a friendlier interface. The package:audio/mpg123[] port can be installed to listen to MP3 audio files. - -Another quick way to test the card is to send data to [.filename]#/dev/dsp#: +man:beep[1] 可以用來產生一些聲音,確認音效卡正在運作: [source,shell] .... -% cat filename > /dev/dsp +% beep .... -where [.filename]#filename# can be any type of file. This command should produce some noise, confirming that the sound card is working. - -[NOTE] -==== -The [.filename]#/dev/dsp*# 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]. -==== +[[sound-mixer]] +=== 混音器 -[[bluetooth-headset]] -=== 設定藍芽音效裝置 +FreeBSD 在音效系統上建立了不同的方式來設定和顯示音效卡混音器的值: -Connecting to a Bluetooth device is out of scope for this chapter. Refer to crossref:advanced-networking[network-bluetooth,藍牙] for more information. +.支援的混音器套件 +[options="header", cols="1,1,1,1"] +|=== +| Name | License | Package | Toolkit -To get Bluetooth sound sink working with FreeBSD's sound system, users have to install package:audio/virtual_oss[] first: +| man:mixer[8] +| BSD-2 +| Included in base system +| CLI -[source,shell] -.... -# pkg install virtual_oss -.... +| dsbmixer +| BSD-2 +| package:audio/dsbmixer[] +| Qt -package:audio/virtual_oss[] requires `cuse` to be loaded into the kernel: +| KDE Plasma audio widget +| GPL 2.0 +| package:audio/plasma5-plasma-pa[] +| Qt -[source,shell] -.... -# kldload cuse -.... +| mixertui +| BSD-2 +| package:audio/mixertui[] +| TUI -To load `cuse` during system startup, run this command: +|=== -[source,shell] -.... -# sysrc -f /boot/loader.conf cuse_load=yes -.... +[[graphics-card-sound]] +=== 顯示卡音效 -To use headphones as a sound sink with package:audio/virtual_oss[], users need to create a virtual device after connecting to a Bluetooth audio device: +顯示卡通常會附帶內建的音效設備,有時可能無法確定哪一個被設定為預設設備。要確認這一點,可以執行 dmesg 命令,並查看 pcm 項目,以暸解系統如何列出輸出設備。執行以下指令: [source,shell] .... -# virtual_oss -C 2 -c 2 -r 48000 -b 16 -s 768 -R /dev/null -P /dev/bluetooth/headphones -d dsp +% dmesg | grep pcm .... -[NOTE] -==== -_headphones_ in this example is a hostname from [.filename]#/etc/bluetooth/hosts#. `BT_ADDR` could be used instead. -==== - -請參考 man:virtual_oss[8] 取得更多資訊。 - -[[troubleshooting]] -=== 疑難排解音效 - -<> lists some common error messages and their solutions: - -[[multimedia-sound-common-error-messages]] -.常見錯誤訊息 -[cols="1,1", frame="none", options="header"] -|=== -| 錯誤 -| 解決方式 - -|`sb_dspwr(XX) timed out` -| - -The I/O port is not set correctly. - -|`bad irq XX` -| - -The IRQ is set incorrectly. Make sure that the set IRQ and the sound IRQ are the same. - -|`xxx: gus pcm not attached, out of memory` -| - -There is not enough available memory to use the device. - -|`xxx: can't open /dev/dsp!` -| - -Type `fstat \| grep dsp` to check if another application is holding the device open. Noteworthy troublemakers are esound and KDE's sound support. -|=== - -Modern graphics cards often come with their own sound driver for use with HDMI. This sound device is sometimes enumerated before the sound card meaning that the sound card will not be used as the default playback device. To check if this is the case, run dmesg and look for `pcm`. The output looks something like this: +輸出應與下列內容相似: [.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: at cad 0 nid 1 on hdac0 -pcm1: at cad 1 nid 1 on hdac0 -pcm2: at cad 2 nid 1 on hdac0 -pcm3: at cad 3 nid 1 on hdac0 +pcm0: at cad 0 nid 1 on hdac0 +pcm1: at cad 1 nid 1 on hdac0 +pcm2: at cad 2 nid 1 on hdac0 +pcm3: at cad 3 nid 1 on hdac0 hdac1: HDA Codec #2: Realtek ALC889 pcm4: at cad 2 nid 1 on hdac1 pcm5: at cad 2 nid 1 on hdac1 pcm6: at cad 2 nid 1 on hdac1 pcm7: at cad 2 nid 1 on hdac1 -... .... -In this example, the graphics card (`NVidia`) has been enumerated before the sound card (`Realtek ALC889`). To use the sound card as the default playback device, change `hw.snd.default_unit` to the unit that should be used for playback: +顯示卡(NVIDIA(R))已在音效卡(Realtek(R))之前列出,音效卡顯示為「pcm4」。 +您可以執行下列指令,將系統設定為以音效卡為預設裝置: [source,shell] .... -# sysctl hw.snd.default_unit=n +# sysctl hw.snd.default_unit=4 .... -where `n` is the number of the sound device to use. In this example, it should be `4`. Make this change permanent by adding the following line to [.filename]#/etc/sysctl.conf#: +若要將此變更永久化,請在 [.filename]#/etc/sysctl.conf# 中加入: [.programlisting] .... hw.snd.default_unit=4 .... -[[sound-multiple-sources]] -=== 使用多個音效來源 +[[automatically-switching-headphones]] +=== 自動切換至耳機 +有些系統在切換音訊輸出時可能會很麻煩,幸好 FreeBSD 允許在 [.filename]#device.hints# 中設定自動切換。 -It is often desirable to have multiple sources of sound that are able to play simultaneously. FreeBSD uses "Virtual Sound Channels" to multiplex the sound card's playback by mixing sound in the kernel. - -Three man:sysctl[8] knobs are available for configuring virtual channels: +藉由執行下列指令來辨識系統如何列出音訊輸出: [source,shell] .... -# sysctl dev.pcm.0.play.vchans=4 -# sysctl dev.pcm.0.rec.vchans=4 -# sysctl hw.snd.maxautovchans=4 +% dmesg | grep pcm .... -This example allocates four virtual channels, which is a practical number for everyday use. Both `dev.pcm.0.play.vchans=4` and `dev.pcm.0.rec.vchans=4` are configurable after a device has been attached and represent the number of virtual channels [.filename]#pcm0# has for playback and recording. Since the [.filename]#pcm# module can be loaded independently of the hardware drivers, `hw.snd.maxautovchans` indicates how many virtual channels will be given to an audio device when it is attached. Refer to man:pcm[4] for more information. - -[NOTE] -==== -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. -==== +輸出應與下列內容相似: -The correct [.filename]#pcm# device will automatically be allocated transparently to a program that requests [.filename]#/dev/dsp0#. - -=== 設定混音器頻道的預設值 +[.programlisting] +.... +pcm0: at nid 23 and 26 on hdaa0 +pcm1: at nid 22 on hdaa0 +.... -The default values for the different mixer channels are hardcoded in the source code of the man:pcm[4] driver. While sound card mixer levels can be changed using man:mixer[8] or third-party applications and daemons, this is not a permanent solution. To instead set default mixer values at the driver level, define the appropriate values in [.filename]#/boot/device.hints#, as seen in this example: +在 [.filename]#/boot/device.hints# 中加入以下幾行: [.programlisting] .... -hint.pcm.0.vol="50" +hint.hdac.0.cad0.nid22.config="as=1 seq=15 device=Headphones" +hint.hdac.0.cad0.nid26.config="as=2 seq=0 device=speakers" .... -This will set the volume channel to a default value of `50` when the man:pcm[4] module is loaded. +[NOTE] +==== +請記住,這些訊息是針對上述範例而言。 +它們可能會因系統而異。 +==== -[[sound-mp3]] -== MP3 音樂 +[[troubleshooting-sound]] +=== 音效疑難排解 -This section describes some MP3 players available for FreeBSD, how to rip audio CD tracks, and how to encode and decode MP3s. +一些常見的錯誤訊息及其解決方案: -[[mp3-players]] -=== MP3 播放器 +[[multimedia-sound-common-error-messages]] +.常見錯誤訊息 +[cols="1,1", frame="none", options="header"] +|=== +| Error +| Solution -A popular graphical MP3 player is Audacious. It supports Winamp skins and additional plugins. The interface is intuitive, with a playlist, graphic equalizer, and more. Those familiar with Winamp will find Audacious simple to use. On FreeBSD, Audacious can be installed from the package:multimedia/audacious[] port or package. Audacious is a descendant of XMMS. +|`xxx: can't open /dev/dsp!` +|輸入 `fstat \| grep dsp` 來檢查是否有其他應用程式佔用了該設備。需要注意的潛在問題來源包括 esound 和 KDE 的音效支援。 +|=== -The package:audio/mpg123[] package or port provides an alternative, command-line MP3 player. Once installed, specify the MP3 file to play on the command line. If the system has multiple audio devices, the sound device can also be specified: +使用 package:audio/pulseaudio[] 的程式可能需要重新啟動 package:audio/pulseaudio[] 的常駐程式,才能讓 `hw.snd.default_unit` 中的變更生效。 +另外,package:audio/pulseaudio[] 的設定也可以即時變更。 +man:pacmd[1] 會開啟與 package:audio/pulseaudio[] 常駐程式的命令列連線: [source,shell] .... -# mpg123 -a /dev/dsp1.0 Foobar-GreatestHits.mp3 -High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3 - version 1.18.1; written and copyright by Michael Hipp and others - free software (LGPL) without any warranty but with best wishes +# pacmd +Welcome to PulseAudio 14.2! Use "help" for usage information. +>>> +.... + +以下指令將預設的音效輸出設備更改為編號 4 的卡片,如前面的範例所示 -Playing MPEG stream from Foobar-GreatestHits.mp3 ... -MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo +[.programlisting] +.... +set-default-sink 4 .... -Additional MP3 players are available in the FreeBSD Ports Collection. +[WARNING] +==== +請勿使用 `exit` 指令離開指令列介面。這會終止 package:audio/pulseaudio[] 的常駐程式。請改用 kbd:[Ctrl+D]。 +==== -[[rip-cd]] -=== 擷取 CD 音軌 +[[audio-ports]] +== 音訊播放器 -Before encoding a CD or CD track to MP3, the audio data on the CD must be ripped to the hard drive. This is done by copying the raw CD Digital Audio (CDDA) data to WAV files. +本節將介紹 FreeBSD Ports Collection 中一些可用於音訊播放的軟體。 -The `cdda2wav` tool, which is installed with the package:sysutils/cdrtools[] suite, can be used to rip audio information from CDs. +.音訊播放器套件 +[options="header", cols="1,1,1,1"] +|=== +| Name | License | Package | Toolkit -With the audio CD in the drive, the following command can be issued as `root` to rip an entire CD into individual, per track, WAV files: +| Elisa +| LGPL 3.0 +| package:audio/elisa[] +| Qt -[source,shell] -.... -# cdda2wav -D 0,1,0 -B -.... +| GNOME Music +| GPL 2.0 +| package:audio/gnome-music[] +| GTK+ -In this example, the `-D _0,1,0_` indicates the SCSI device [.filename]#0,1,0# containing the CD to rip. Use `cdrecord -scanbus` to determine the correct device parameters for the system. +| Audacious +| BSD-2 +| package:multimedia/audacious[] +| Qt -To rip individual tracks, use `-t` to specify the track: +| MOC (music on console) +| GPL 2.0 +| package:audio/moc[] +| TUI -[source,shell] -.... -# cdda2wav -D 0,1,0 -t 7 -.... +|=== -To rip a range of tracks, such as track one to seven, specify a range: +[[elisa]] +=== Elisa -[source,shell] -.... -# cdda2wav -D 0,1,0 -t 1+7 -.... +Elisa 是 KDE 社群開發的音樂播放器,力求簡單好用。 -To rip from an ATAPI (IDE) CDROM drive, specify the device name in place of the SCSI unit numbers. For example, to rip track 7 from an IDE drive: +要安裝 Elisa,請執行 [source,shell] .... -# cdda2wav -D /dev/acd0 -t 7 +# pkg install elisa .... -Alternately, `dd` can be used to extract audio tracks on ATAPI drives, as described in crossref:disks[duplicating-audiocds,複製音樂 CD]. +[[gnome-music]] +=== GNOME Music -[[mp3-encoding]] -=== MP3 編碼與解碼 +GNOME Music 是全新的 GNOME 音樂播放應用程式。 +它的目標是結合沈浸式的體驗與簡潔明瞭的控制。 -Lame is a popular MP3 encoder which can be installed from the package:audio/lame[] port. Due to patent issues, a package is not available. - -The following command will convert the ripped WAV file [.filename]#audio01.wav# to [.filename]#audio01.mp3#: +要安裝 GNOME 音樂,請執行 [source,shell] .... -# lame -h -b 128 --tt "Foo Song Title" --ta "FooBar Artist" --tl "FooBar Album" \ ---ty "2014" --tc "Ripped and encoded by Foo" --tg "Genre" audio01.wav audio01.mp3 +# pkg install gnome-music .... -The specified 128 kbits is a standard MP3 bitrate while the 160 and 192 bitrates provide higher quality. The higher the bitrate, the larger the size of the resulting MP3. The `-h` turns on the "higher quality but a little slower" mode. The options beginning with `--t` indicate ID3 tags, which usually contain song information, to be embedded within the MP3 file. Additional encoding options can be found in the lame manual page. +[[audacious]] +=== Audacious -In order to burn an audio CD from MP3s, they must first be converted to a non-compressed file format. XMMS can be used to convert to the WAV format, while mpg123 can be used to convert to the raw Pulse-Code Modulation (PCM) audio data format. +Audacious 是一款開放原始碼的音訊播放器。 +Audacious 是 XMMS 的後代,它能以你想要的方式播放音樂,而不會從其他任務中搶走電腦資源。 -To convert [.filename]#audio01.mp3# using mpg123, specify the name of the PCM file: +要安裝 Audacious,請執行 [source,shell] .... -# mpg123 -s audio01.mp3 > audio01.pcm +# pkg install audacious-qt6 audacious-plugins-qt6 .... -To use XMMS to convert a MP3 to WAV format, use these steps: - -[.procedure] +[NOTE] ==== -*Procedure: Converting to WAV Format in XMMS* -. Launch XMMS. -. Right-click the window to bring up the XMMS menu. -. Select `Preferences` under `Options`. -. Change the Output Plugin to "Disk Writer Plugin". -. Press `Configure`. -. Enter or browse to a directory to write the uncompressed files to. -. Load the MP3 file into XMMS as usual, with volume at 100% and EQ settings turned off. -. Press `Play`. The XMMS will appear as if it is playing the MP3, but no music will be heard. It is actually playing the MP3 to a file. -. When finished, be sure to set the default Output Plugin back to what it was before in order to listen to MP3s again. +Audacious 原生支援 OSS,但必須在 Audio tab 中設定。 ==== -Both the WAV and PCM formats can be used with cdrecord. When using WAV files, there will be a small tick sound at the beginning of each track. This sound is the header of the WAV file. The package:audio/sox[] port or package can be used to remove the header: +[[moc-music-on-console]] +=== MOC (music on console) -[source,shell] -.... -% sox -t wav -r 44100 -s -w -c 2 track.wav track.raw -.... - -Refer to crossref:disks[creating-cds,建立與使用 CD 媒體] for more information on using a CD burner in FreeBSD. -[[video-playback]] -== 影片播放 +MOC(Music on Console)是一款設計為功能強大且易於使用的控制台音頻播放器。 -Before configuring video playback, determine the model and chipset of the video card. While Xorg supports a wide variety of video cards, not all provide good playback performance. To obtain a list of extensions supported by the Xorg server using the card, run `xdpyinfo` while Xorg is running. +MOC 可以在不受系統或 I/O 負載影響的情況下平穩播放,因為它在單獨的線程中處理輸出緩衝區。 +播放文件之間不會出現間隙,因為在播放當前文件的同時,下一個文件已經預先緩存好。 -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]#/dev/dvd# by default, or have this device name hardcoded in them, it might be useful to make a symbolic link to the proper device: +若要安裝 MOC (控制台音樂),請執行: [source,shell] .... -# ln -sf /dev/cd0 /dev/dvd +# pkg install moc .... -Due to the nature of man:devfs[5], manually created links will not persist after a system reboot. In order to recreate the symbolic link automatically when the system boots, add the following line to [.filename]#/etc/devfs.conf#: +[[video-ports]] +== 影片播放器 -[.programlisting] -.... -link cd0 dvd -.... +本節將介紹 FreeBSD Ports Collection 中一些可用於播放影片的軟體。 -DVD decryption invokes certain functions that require write permission to the DVD device. +.影片播放器套件 +[options="header", cols="1,1,1,1"] +|=== +| Name | License | Package | Toolkit -To enhance the shared memory Xorg interface, it is recommended to increase the values of these man:sysctl[8] variables: +| MPlayer +| GPL 2.0 +| package:multimedia/mplayer[] +| CLI -[.programlisting] -.... -kern.ipc.shmmax=67108864 -kern.ipc.shmall=32768 -.... +| SMPlayer +| GPL 2.0 +| package:multimedia/smplayer[] +| Qt -[[video-interface]] -=== 偵測影像處理能力 +| VLC media player +| GPL 2.0 +| package:multimedia/vlc[] +| Qt -There are several possible ways to display video under Xorg and what works is largely hardware dependent. Each method described below will have varying quality across different hardware. +| Kodi (XBMC) +| GPL 2.0 +| package:multimedia/kodi[] +| X11 -Common video interfaces include: +|=== -. Xorg: normal output using shared memory. -. XVideo: an extension to the Xorg interface which allows video to be directly displayed in drawable objects through a special acceleration. This extension provides good quality playback even on low-end machines. The next section describes how to determine if this extension is running. -. SDL: the Simple Directmedia Layer is a porting layer for many operating systems, allowing cross-platform applications to be developed which make efficient use of sound and graphics. SDL provides a low-level abstraction to the hardware which can sometimes be more efficient than the Xorg interface. On FreeBSD, SDL can be installed using the package:devel/sdl20[] package or port. -. DGA: the Direct Graphics Access is an Xorg extension which allows a program to bypass the Xorg server and directly alter the framebuffer. Because it relies on a low level memory mapping, programs using it must be run as `root`. The DGA extension can be tested and benchmarked using man:dga[1]. When `dga` is running, it changes the colors of the display whenever a key is pressed. To quit, press kbd:[q]. -. SVGAlib: a low level console graphics layer. +[[mplayer]] +=== MPlayer -[[video-interface-xvideo]] -==== XVideo +MPlayer 是多媒體播放器和編碼套件,可在多種平台上執行,並可在命令列上運作。 +它可播放大量不同的檔案格式和編解碼器,包括流行的 DivX、XviD、H.264 串流、DVD 和 SVCD,以及許多常見的音訊編解碼器。 -To check whether this extension is running, use `xvinfo`: +要安裝 MPlayer,請執行: [source,shell] .... -% xvinfo +# pkg install mplayer .... -XVideo is supported for the card if the result is similar to: +有關 MPlayer 如何運作的範例,請參閱 man:mplayer[1]。 -[source,shell] -.... -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 -.... - -The formats listed, such as YUV2 and YUV12, are not present with every implementation of XVideo and their absence may hinder some players. - -If the result instead looks like: +[[smplayer]] +=== SMPlayer + +SMPlayer 是 MPlayer 的完整前端,提供從播放影片、DVD 和 VCD 等基本功能到支持 MPlayer 過濾器等更高級功能。 + +要安裝 SMPlayer,請執行: [source,shell] .... -X-Video Extension version 2.2 -screen #0 -no adaptors present +# pkg install smplayer .... -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. - -[[video-ports]] -=== 可處理影像的 Port 與套件 - -This section introduces some of the software available from the FreeBSD Ports Collection which can be used for video playback. - -[[video-mplayer]] -==== MPlayer 與 MEncoder - -MPlayer is a command-line video player with an optional graphical interface which aims to provide speed and flexibility. Other graphical front-ends to MPlayer are available from the FreeBSD Ports Collection. - -MPlayer can be installed using the package:multimedia/mplayer[] package or port. 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. - -When compiling the port, the menu options should be reviewed to determine the type of support to compile into the port. If an option is not selected, MPlayer 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 kbd:[Enter] to continue the port compile and installation. +[[vlc]] +=== VLC media player -By default, the package or port will build the `mplayer` command line utility and the `gmplayer` graphical utility. To encode videos, compile the package:multimedia/mencoder[] port. Due to licensing restrictions, a package is not available for MEncoder. +VLC 媒體播放器是一款高度便攜的多媒體播放器,支持各種音訊和影片格式(如 MPEG-1、MPEG-2、MPEG-4、DivX、mp3、ogg 等)以及 DVD、VCD 和各種串流協議。 +它也可以作為伺服器,在高頻寬網路中以 IPv4 或 IPv6 單播或多播方式串流 +VLC 也具備即時轉碼功能,可以用於即時串流媒體或將其保存到磁碟中。 -The first time MPlayer is run, it will create [.filename]#~/.mplayer# in the user's home directory. This subdirectory contains default versions of the user-specific configuration files. - -This section describes only a few common uses. Refer to mplayer(1) for a complete description of its numerous options. - -To play the file [.filename]#testfile.avi#, specify the video interfaces with `-vo`, as seen in the following examples: +要安裝 VLC,請執行: [source,shell] .... -% mplayer -vo xv testfile.avi +# pkg install vlc .... -[source,shell] -.... -% mplayer -vo sdl testfile.avi -.... +[[kodi]] +=== Kodi (XBMC) -[source,shell] -.... -% mplayer -vo x11 testfile.avi -.... +Kodi (以前稱為 XBMC) 是免費的開放原始碼跨平台媒體播放器和娛樂中心。 +它允許使用者從本機、網路儲存媒體和網際網路播放和觀看大部分影片、音樂、podcast 和其他數位媒體檔案。 -[source,shell] -.... -# mplayer -vo dga testfile.avi -.... +若要安裝 Kodi,請執行: [source,shell] .... -# mplayer -vo 'sdl:dga' testfile.avi +# pkg install kodi .... -It is worth trying all of these options, as their relative performance depends on many factors and will vary significantly with hardware. +[[conferencing-meetings]] +== 視訊會議 -To play a DVD, replace [.filename]#testfile.avi# with `dvd://_N_ -dvd-device _DEVICE_`, where _N_ is the title number to play and _DEVICE_ is the device node for the DVD. For example, to play title 3 from [.filename]#/dev/dvd#: +FreeBSD 桌面環境可以用來加入視訊會議。 +本章節將介紹如何設定網路攝影機,以及 FreeBSD 支援哪些視訊會議應用程式。 -[source,shell] -.... -# mplayer -vo xv dvd://3 -dvd-device /dev/dvd -.... - -[NOTE] -==== -The default DVD device can be defined during the build of the MPlayer port by including the `WITH_DVD_DEVICE=/path/to/desired/device` option. By default, the device is [.filename]#/dev/cd0#. More details can be found in the port's [.filename]#Makefile.options#. -==== +[[webcam-setup]] +=== 設定網路攝影機 -To stop, pause, advance, and so on, use a keybinding. To see the list of keybindings, run `mplayer -h` or read mplayer(1). +為了允許 FreeBSD 存取網路攝影機並執行其設定,必須安裝某些工具: -Additional playback options include `-fs -zoom`, which engages fullscreen mode, and `-framedrop`, which helps performance. +* package:multimedia/webcamd[] 是一個 常駐程式,可以使用數百種不同的 USB 網路攝影機和 DVB USB 裝置。 +* package:multimedia/pwcview[] 是一個應用程式,可用於觀看網路攝影機的串流影片。 -Each user can add commonly used options to their [.filename]#~/.mplayer/config# like so: +若要安裝所需的程式,請執行 -[.programlisting] +[source,shell] .... -vo=xv -fs=yes -zoom=yes +# pkg install webcamd pwcview .... -`mplayer` can be used to rip a DVD title to a [.filename]#.vob#. To dump the second title from a DVD: +在 `/etc/rc.conf` 中啟用 man:webcamd[8] 服務,以便在系統啟動時啟動它: [source,shell] .... -# mplayer -dumpstream -dumpfile out.vob dvd://2 -dvd-device /dev/dvd +# sysrc webcamd_enable="YES" .... -The output file, [.filename]#out.vob#, will be in MPEG format. - -Anyone wishing to obtain a high level of expertise with UNIX(TM) video should consult http://www.mplayerhq.hu/DOCS/[mplayerhq.hu/DOCS] as it is technically informative. This documentation should be considered as required reading before submitting any bug reports. - -Before using `mencoder`, it is a good idea to become familiar with the options described at http://www.mplayerhq.hu/DOCS/HTML/en/mencoder.html[mplayerhq.hu/DOCS/HTML/en/mencoder.html]. 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 `mplayer`. - -Here is an example of a simple copy: +該使用者必須屬於 `webcamd` 群組。 +要將使用者加入 `webcamd` 群組,請執行下列指令: [source,shell] .... -% mencoder input.avi -oac copy -ovc copy -o output.avi +# pw groupmod webcamd -m username .... -To rip to a file, use `-dumpfile` with `mplayer`. - -To convert [.filename]#input.avi# to the MPEG4 codec with MPEG3 audio encoding, first install the package:audio/lame[] port. Due to licensing restrictions, a package is not available. Once installed, type: +由於 package:multimedia/webcamd[] 需要 man:cuse[3] 模組,因此必須執行下列指令才能載入此模組: [source,shell] .... -% mencoder input.avi -oac mp3lame -lameopts br=192 \ - -ovc lavc -lavcopts vcodec=mpeg4:vhq -o output.avi +# kldload cuse .... -This will produce output playable by applications such as `mplayer` and `xine`. - -[.filename]#input.avi# can be replaced with `dvd://1 -dvd-device /dev/dvd` and run as `root` to re-encode a DVD title directly. Since it may take a few tries to get the desired result, it is recommended to instead dump the title to a file and to work on the file. - -[[video-xine]] -==== xine 影像播放器 - -xine 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 package:multimedia/xine[] package or port. - -In practice, xine requires either a fast CPU with a fast video card, or support for the XVideo extension. The xine video player performs best on XVideo interfaces. - -By default, the xine player starts a graphical user interface. The menus can then be used to open a specific file. - -Alternatively, xine may be invoked from the command line by specifying the name of the file to play: +若要在系統啟動時載入 man:cuse[3],請執行指令: [source,shell] .... -% xine -g -p mymovie.avi +# sysrc kld_list += "cuse" .... -Refer to http://www.xine-project.org/faq[ xine-project.org/faq] for more information and troubleshooting tips. - -[[video-ports-transcode]] -==== Transcode 工具 - -Transcode provides a suite of tools for re-encoding video and audio files. Transcode can be used to merge video files or repair broken files using command line tools with stdin/stdout stream interfaces. - -In FreeBSD, Transcode can be installed using the package:multimedia/transcode[] 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, Transcode will not be able to encode that format. Use the arrow keys and spacebar to select the required formats. When finished, press kbd:[Enter] to continue the port compile and installation. - -This example demonstrates how to convert a DivX file into a PAL MPEG-1 file (PAL VCD): +一旦安裝完該程式後,可用的網路攝影機可以用 man:webcamd[8] 列出: [source,shell] .... -% transcode -i input.avi -V --export_prof vcd-pal -o output_vcd -% mplex -f 1 -o output_vcd.mpg output_vcd.m1v output_vcd.mpa +# webcamd -l .... -The resulting MPEG file, [.filename]#output_vcd.mpg#, is ready to be played with MPlayer. The file can be burned on a CD media to create a video CD using a utility such as package:multimedia/vcdimager[] or package:sysutils/cdrdao[]. - -In addition to the manual page for `transcode`, refer to http://www.transcoding.org/cgi-bin/transcode[transcoding.org/cgi-bin/transcode] for further information and examples. - -[[tvcard]] -== 電視卡 - -電視卡 (TV card) 可以讓您用電腦來看無線、有線電視節目。許多卡都是透過 RCA 或 S-video 輸入端子來接收視訊,而且有些卡還可接收 FM 廣播的功能。 - -FreeBSD 可透過 man:bktr[4] 驅動程式,來支援 PCI 介面的電視卡,只要這些卡使用的是 Brooktree Bt848/849/878/879 或 Conexant CN-878/Fusion 878a 視訊擷取晶片。此外,要再確認哪些卡上所附的選台功能是否有支援,可以參考 man:bktr[4] 說明,以查看所支援的硬體清單。 - -=== 載入驅動程式 - -要用電視卡的話,就要載入 man:bktr[4] 驅動程式,這個可以透過在 [.filename]#/boot/loader.conf# 檔加上下面這一行就可以了: +輸出應與下列內容相似: [.programlisting] .... -bktr_load="YES" +webcamd [-d ugen0.2] -N SunplusIT-Inc-HP-TrueVision-HD-Camera -S unknown -M 0 <.> +webcamd [-d ugen1.3] -N Realtek-802-11n-WLAN-Adapter -S 00e04c000001 -M 0 .... +<.> 可用的網路攝影機 -或者可以將電視卡支援靜態編譯到自訂的核心當中,若要這麼做則可在自訂核心設定檔加入以下行: +執行下列指令設定可用的網路攝影機: -[.programlisting] +[source,shell] .... -device bktr -device iicbus -device iicbb -device smbus +# sysrc webcamd_0_flags="-d ugen0.2" <.> .... -之所以要加上這些額外的驅動程式,是因為卡的各組成部分都是透過 I2C 匯流排而相互連接的。接下來,請編譯、安裝新的核心 。 +[NOTE] +==== +請注意,如果這是隨插即用的 USB 網路攝影機,變更 USB 連接埠就會改變 `webcamd -l` 的輸出,而且 rc.conf 中的項目可能需要更新。 +對於使用 USB 整合式網路攝影機的筆記型電腦,這應該不是問題。 +==== -要測試調諧器 (Tuner) 是否被正確的偵測,請先重新啟動系統。電視卡應該會出現在開機訊息檔中,如同此範例: +必須執行下列指令來啟動 man:webcamd[8] 服務: -[.programlisting] +[source,shell] .... -bktr0: mem 0xd7000000-0xd7000fff irq 10 at device 10.0 on pci0 -iicbb0: on bti2c0 -iicbus0: on iicbb0 master-only -iicbus1: on iicbb0 master-only -smbus0: on bti2c0 -bktr0: Pinnacle/Miro TV, Philips SECAM tuner. +# service webcamd start .... -該訊息會依硬體不同而有所不同。若必要,可以使用 man:sysctl[8] 系統偵測的參數或者自訂核心設定選項。例如要強制使用 Philips SECAM 調諧器則可加入下列行至自訂核心設定檔: +輸出應與下列內容相似: [.programlisting] .... -options OVERRIDE_TUNER=6 +Starting webcamd. +webcamd 1616 - - Attached to ugen0.2[0] .... -或使用 man:sysctl[8]: +package:multimedia/pwcview[] 可用於檢查網路攝影機是否正常運作。 +下列指令可用於執行 package:multimedia/pwcview[]: [source,shell] .... - -# sysctl hw.bt848.tuner=6 +% pwcview -f 30 -s vga .... -請參考 man:bktr[4] 查看 man:sysctl[8] 可用的參數說明及核心選項。 - -=== 好用的應用程式 - -To use the TV card, install one of the following applications: - -* package:multimedia/fxtv[] provides TV-in-a-window and image/audio/video capture capabilities. -* package:multimedia/xawtv[] is another TV application with similar features. -* package:audio/xmradio[] provides an application for using the FM radio tuner of a TV card. - -More applications are available in the FreeBSD Ports Collection. - -=== 疑難排解 +然後 package:multimedia/pwcview[] 就會顯示網路攝影機: -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 or to ask questions about supported TV cards, refer to the http://lists.FreeBSD.org/mailman/listinfo/freebsd-multimedia[freebsd-multimedia] mailing list. +image::pwcview.png[pwcview showing Absolute FreeBSD 3rd edition as an example] -[[mythtv]] -== MythTV +[[meetings-software-status]] +=== 會議軟體 -MythTV is a popular, open source Personal Video Recorder (PVR) application. This section demonstrates how to install and setup MythTV on FreeBSD. Refer to http://www.mythtv.org/wiki/[mythtv.org/wiki] for more information on how to use MythTV. +FreeBSD 目前支援下列用於執行視訊會議的工具。 -MythTV requires a frontend and a backend. These components can either be installed on the same system or on different machines. +.會議軟體 +[options="header", cols="1,1,1,1"] +|=== +| Name | Firefox status | Chromium status | Website -The frontend can be installed on FreeBSD using the package:multimedia/mythtv-frontend[] package or port. Xorg must also be installed and configured as described in crossref:x11[x11,X Window 系統]. Ideally, this system has a video card that supports X-Video Motion Compensation (XvMC) and, optionally, a Linux Infrared Remote Control (LIRC)-compatible remote. +| Microsoft Teams +| Does not work +| Works +| link:https://teams.live.com[] -To install both the backend and the frontend on FreeBSD, use the package:multimedia/mythtv[] package or port. A MySQL(TM) database server is also required and should automatically be installed as a dependency. Optionally, this system should have a tuner card and sufficient storage to hold recorded data. +| Google Meet +| Does not work +| Works +| link:https://meet.google.com/[] -=== 硬體 +| Zoom +| Works +| Works +| link:https://zoom.us[] -MythTV uses Video for Linux (V4L) to access video input devices such as encoders and tuners. In FreeBSD, MythTV works best with USB DVB-S/C/T cards as they are well supported by the package:multimedia/webcamd[] package or port which provides a V4L userland application. Any Digital Video Broadcasting (DVB) card supported by webcamd should work with MythTV. A list of known working cards can be found at https://wiki.freebsd.org/WebcamCompat[wiki.freebsd.org/WebcamCompat]. Drivers are also available for Hauppauge cards in the package:multimedia/pvr250[] and package:multimedia/pvrxxx[] ports, 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. +| Jitsi +| Does not work +| Works +| link:https://meet.jit.si/[] -The https://wiki.freebsd.org/HTPC[wiki.freebsd.org/HTPC] page contains a list of all available DVB drivers. +| BigBlueButton +| Does not work +| Works +| link:https://bigbluebutton.org/[] -=== 設定 MythTV 後端 +|=== -要使用 Binary 套件安裝 MythTV 可: +[[scanners]] +== 影像掃描器 -[source,shell] -.... -# pkg install mythtv -.... +在 FreeBSD 中, 存取影像掃描器是由 link:http://www.sane-project.org[SANE (Scanner Access Now Easy)]提供的, 它可以在 FreeBSD Ports Collection 中找到。 -或從 Port 套件集安裝: +[[scanners-kernel-usb]] +=== 檢查掃瞄器 -[source,shell] -.... -# cd /usr/ports/multimedia/mythtv -# make install -.... +在嘗試任何設定之前,請務必檢查掃瞄器是否被 SANE 支援。 -Once installed, set up the MythTV database: +連接掃瞄器後,執行下列指令以取得所有已連接的 USB 裝置: [source,shell] .... -# mysql -uroot -p < /usr/local/shared/mythtv/database/mc.sql +# usbconfig list .... -Then, configure the backend: +輸出應與下列內容相似: -[source,shell] +[.programlisting] .... -# mythtv-setup +ugen4.2: at usbus4, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (70mA) +ugen4.3: at usbus4, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA) +ugen3.2: at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA) .... -Finally, start the backend: +執行下列指令以取得 `idVendor` 和 `idProduct` : [source,shell] .... -# sysrc mythbackend_enable=yes -# service mythbackend start +# usbconfig -d 3.2 dump_device_desc .... -[[scanners]] -== 影像掃描器 - -In FreeBSD, access to image scanners is provided by SANE (Scanner Access Now Easy), which is available in the FreeBSD Ports Collection. SANE will also use some FreeBSD device drivers to provide access to the scanner hardware. - -FreeBSD supports both SCSI and USB scanners. Depending upon the scanner interface, different device drivers are required. Be sure the scanner is supported by SANE prior to performing any configuration. Refer to http://www.sane-project.org/sane-supported-devices.html[ http://www.sane-project.org/sane-supported-devices.html] for more information about supported scanners. - -This chapter describes how to determine if the scanner has been detected by FreeBSD. It then provides an overview of how to configure and use SANE on a FreeBSD system. - -[[scanners-kernel-usb]] -=== 檢查掃描器 +[NOTE] +==== +請注意,掃瞄器是隨插即用的裝置,變更連接的 USB 連接埠將改變來自 `usbconfig list` 的輸出。 +==== -The [.filename]#GENERIC# kernel 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: +輸出應與下列內容相似: [.programlisting] .... -device usb -device uhci -device ohci -device ehci -.... - -To determine if the USB scanner is detected, plug it in and use `dmesg` to determine whether the scanner appears in the system message buffer. If it does, it should display a message similar to this: +ugen3.2: at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA) -[source,shell] -.... -ugen0.2: at usbus0 +bLength = 0x0012 +bDescriptorType = 0x0001 +bcdUSB = 0x0200 +bDeviceClass = 0x0000 +bDeviceSubClass = 0x0000 +bDeviceProtocol = 0x0000 +bMaxPacketSize0 = 0x0040 +idVendor = 0x03f0 +idProduct = 0x8911 +bcdDevice = 0x0100 +iManufacturer = 0x0001 +iProduct = 0x0002 +bNumConfigurations = 0x0001 .... -In this example, an EPSON Perfection(TM) 1650 USB scanner was detected on [.filename]#/dev/ugen0.2#. +一旦取得 `idVendor` 和 `idProduct` 之後,就必須在 link:http://www.sane-project.org/lists/sane-mfgs-cvs.html[SANE支援的裝置清單] 中,透過idProduct過濾,檢查掃瞄器是否被支援。 -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# kernel supports the most common SCSI controllers. Refer to [.filename]#/usr/src/sys/conf/NOTES# 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 a custom kernel configuration file: +[[_sane_configuration]] +=== SANE Configuration -[.programlisting] -.... -device scbus -device pass -.... - -Verify that the device is displayed in the system message buffer: +SANE 透過後端提供掃描器的存取。 +若要使用 FreeBSD 掃描,必須執行下列指令來安裝 package:graphics/sane-backends[] 套件: [source,shell] .... -pass2 at aic0 bus 0 target 2 lun 0 -pass2: Fixed Scanner SCSI-2 device -pass2: 3.300MB/s transfers +# pkg install sane-backends .... -If the scanner was not powered-on at system boot, it is still possible to manually force detection by performing a SCSI bus scan with `camcontrol`: +[TIP] +==== +有些 USB 掃瞄器需要載入韌體。 +就像上面範例中使用的 HP 掃瞄器,需要安裝 package:print/hplip[] 套件。 +==== -[source,shell] -.... -# camcontrol rescan all -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 -.... +安裝必要的套件之後 man:devd[8] 必須設定為允許 FreeBSD 存取掃描器。 -The scanner should now appear in the SCSI devices list: +在 [.filename]#/usr/local/etc/devd/saned.conf# 中加入 `saned.conf` 檔案,內容如下: -[source,shell] +[.programlisting] .... -# camcontrol devlist - at scbus0 target 5 lun 0 (pass0,da0) - at scbus0 target 6 lun 0 (pass1,da1) - at scbus1 target 2 lun 0 (pass3) - at scbus2 target 0 lun 0 (pass2,cd0) +notify 100 { + match "system" "USB"; + match "subsystem" "INTERFACE"; + match "type" "ATTACH"; + match "cdev" "ugen[0-9].[0-9]"; + match "vendor" "0x03f0"; <.> + match "product" "0x8911"; <.> + action "chown -L cups:saned /dev/\$cdev && chmod -L 660 /dev/\$cdev"; +}; .... -Refer to man:scsi[4] and man:camcontrol[8] for more details about SCSI devices on FreeBSD. - -=== SANE 設定 +<.> `vendor`: 是之前執行 `usbconfig -d 3.2 dump_device_desc` 指令取得的 idVendor。 +<.> `product`: 是之前透過執行 `usbconfig -d 3.2 dump_device_desc` 指令取得的 idProduct。 -The SANE system is split in two parts: the backends (package:graphics/sane-backends[]) and the frontends (package:graphics/sane-frontends[] or package:graphics/xsane[]). The backends provide access to the scanner. Refer to http://www.sane-project.org/sane-supported-devices.html[http://www.sane-project.org/sane-supported-devices.html] to determine which backend supports the scanner. The frontends provide the graphical scanning interface. package:graphics/sane-frontends[] installs xscanimage while package:graphics/xsane[] installs xsane. - -要由 Binary 套件安裝這兩個部份可: +之後,必須執行下列指令重新啟動 man:devd[8]: [source,shell] .... -# pkg install xsane sane-frontends +# service devd restart .... -或由 Port 套件集安裝 +SANE 後端包含 man:scanimage[1],可用來列出裝置並執行影像擷取。 -[source,shell] -.... -# cd /usr/ports/graphics/sane-frontends -# make install clean -# cd /usr/ports/graphics/xsane -# make install clean -.... - -After installing the package:graphics/sane-backends[] port or package, use `sane-find-scanner` to check the scanner detection by the SANE system: +使用 `-L` 參數執行 man:scanimage[1],以列出掃瞄器裝置: [source,shell] .... -# sane-find-scanner -q -found SCSI scanner "AGFA SNAPSCAN 600 1.10" at /dev/pass3 +# scanimage -L .... -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. +輸出應與下列內容相似: -[NOTE] -==== -Some USB scanners require firmware to be loaded. Refer to sane-find-scanner(1) and sane(7) for details. -==== - -Next, check if the scanner will be identified by a scanning frontend. The SANE backends include `scanimage` which can be used to list the devices and perform an image acquisition. Use `-L` to list the scanner devices. The first example is for a SCSI scanner and the second is for a USB scanner: - -[source,shell] +[.programlisting] .... -# scanimage -L -device `snapscan:/dev/pass3' is a AGFA SNAPSCAN 600 flatbed scanner -# scanimage -L -device 'epson2:libusb:/dev/usb:/dev/ugen0.2' is a Epson GT-8200 flatbed scanner +device `hpaio:/usb/Deskjet_1050_J410_series?serial=XXXXXXXXXXXXXX' is a Hewlett-Packard Deskjet_1050_J410_series all-in-one .... -In this second example, `'epson2:libusb:/dev/usb:/dev/ugen0.2'` is the backend name (`epson2`) and `/dev/ugen0.2` is the device node used by the scanner. +如果 man:scanimage[1] 無法識別掃瞄器,則會顯示此訊息: -If `scanimage` is unable to identify the scanner, this message will appear: - -[source,shell] +[.programlisting] .... -# scanimage -L - 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). .... -If this happens, edit the backend configuration file in [.filename]#/usr/local/etc/sane.d/# and define the scanner device used. For example, if the undetected scanner model is an EPSON Perfection(TM) 1650 and it uses the `epson2` backend, edit [.filename]#/usr/local/etc/sane.d/epson2.conf#. When editing, add a line specifying the interface and the device node used. In this case, add the following line: - -[.programlisting] -.... -usb /dev/ugen0.2 -.... +一旦 man:scanimage[1] 看到掃瞄器,設定就完成了,可以立即使用掃瞄器。 -Save the edits and verify that the scanner is identified with the right backend name and the device node: +若要啟動服務並讓它在開機時執行,請執行下列指令: [source,shell] .... -# scanimage -L -device 'epson2:libusb:/dev/usb:/dev/ugen0.2' is a Epson GT-8200 flatbed scanner +# sysrc saned_enable="YES" .... -Once `scanimage -L` sees the scanner, the configuration is complete and the scanner is now ready to use. - -While `scanimage` 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 package:graphics/sane-frontends[] package or port installs a simple but efficient graphical interface, xscanimage. - -Alternately, xsane, which is installed with the package:graphics/xsane[] 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 GIMP plugin. - -=== 掃描器權限 - -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# which is really a symlink to the real device node [.filename]#/dev/usb/0.2.0#. The symlink and the device node are owned, respectively, by the `wheel` and `operator` groups. While adding the user to these groups will allow access to the scanner, it is considered insecure to add a user to `wheel`. A better solution is to create a group and make the scanner device accessible to members of this group. - -This example creates a group called `_usb_`: - -[source,shell] -.... -# pw groupadd usb -.... +雖然 man:scanimage[1] 可以在命令列執行影像擷取,但最好還是使用圖形介面來執行影像掃描。 -Then, make the [.filename]#/dev/ugen0.2# symlink and the [.filename]#/dev/usb/0.2.0# device node accessible to the `usb` group with write permissions of `0660` or `0664` by adding the following lines to [.filename]#/etc/devfs.rules#: +.圖形掃描器程式 +[options="header", cols="1,1,1"] +|=== +| Name | License | Package -[.programlisting] -.... -[system=5] -add path ugen0.2 mode 0660 group usb -add path usb/0.2.0 mode 0666 group usb -.... +| skanlite +| GPL 2.0 +| graphics/skanlite -Finally, add the users to `_usb_` in order to allow access to the scanner: +| GNOME Simple Scan +| GPL 3.0 +| graphics/simple-scan -[source,shell] -.... -# pw groupmod usb -m joe -.... +| XSANE +| GPL 2.0 +| graphics/xsane -For more details refer to man:pw[8]. +|===