Index: head/en_US.ISO8859-1/books/handbook/multimedia/chapter.xml =================================================================== --- head/en_US.ISO8859-1/books/handbook/multimedia/chapter.xml (revision 42680) +++ head/en_US.ISO8859-1/books/handbook/multimedia/chapter.xml (revision 42681) @@ -1,1797 +1,1797 @@ Ross Lippert Edited by Multimedia Synopsis &os; supports a wide variety of sound cards, allowing users to enjoy high fidelity output from a &os; system. This includes the ability to record and playback audio in the MPEG Audio Layer 3 (MP3), Waveform Audio File (WAV), Ogg Vorbis, and other formats. The &os; Ports Collection contains many applications for editing recorded audio, adding sound effects, and controlling attached MIDI devices. &os; also supports the playback of video files and DVDs. The &os; Ports Collection contains applications to encode, convert, and playback various video media. This chapter describes how to configure sound cards, video playback, TV tuner cards, and scanners on &os;. It also describes some of the applications which are available for using these devices. After reading this chapter, you will know how to: - Configure a sound card on os;. + Configure a sound card on &os;. Troubleshoot the sound setup. Playback and encode MP3s and other audio. Prepare a &os; system for video playback. Playback DVDs, .mpg, and .avi files. Rip CD and DVD content into files. Configure a TV card. Install and setup MythTV on &os; Configure an image scanner. How to configure an image scanner. Before reading this chapter, you should: Know how to configure and install a new kernel (). Audio CDs have specialized encodings which differ from the usual ISO-filesystem. This means that they should not be mounted using &man.mount.8;. Moses Moore Contributed by Marc Fonvieille Enhanced by Setting Up the Sound Card Configuring the System PCI sound cards Before beginning the configuration, determine the model of the sound card and the chip it uses. &os; supports a wide variety of sound cards. Check the supported audio devices list of the Hardware Notes to see if the card is supported and which &os; driver it uses. kernel configuration In order to use the sound device, the proper device driver must be loaded. This may be accomplished in one of two ways. The easiest way is to load a kernel module for the sound card with &man.kldload.8;. This example loads the driver for a Creative &soundblaster; Live! sound card: &prompt.root; kldload snd_emu10k1 To automate the loading of this driver at boot time, add the driver to /boot/loader.conf. The line for this driver is: snd_emu10k1_load="YES" Other available sound modules are listed in /boot/defaults/loader.conf. When unsure which driver to use, load the snd_driver module: &prompt.root; kldload snd_driver This is a metadriver which loads all of the most common sound drivers and can be used to speed up the search for the correct driver. It is also possible to load all sound drivers by adding the metadriver to /boot/loader.conf. To determine which driver was selected for the sound card after loading the snd_driver metadriver, type cat /dev/sndstat. Users who prefer to statically compile in support for the sound card in a custom kernel should refer to the instructions in the next section. For more information about recompiling a kernel, refer to . Configuring a Custom Kernel with Sound Support When using a custom kernel to provide sound support, make sure that the audio framework driver exists in the custom kernel configuration file: device sound Next, add support for the sound card. Therefore, you need to know which driver supports the card. To continue the example of the Creative &soundblaster; Live! sound card from the previous section, use the following line in the custom kernel configuration file: device snd_emu10k1 Be sure to read the manual page of the driver for the syntax to use. The explicit syntax for the kernel configuration of every supported sound driver can also be found in /usr/src/sys/conf/NOTES. Non-PnP ISA sound cards may require the IRQ and I/O port settings of the card to be added to /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; 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: device snd_sbc device snd_sb16 If the card uses the 0x220 I/O port and IRQ 5, these lines must also be added to /boot/device.hints: 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" In this case, the card uses the 0x220 I/O port and the IRQ 5. The syntax used in /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. Testing the Sound Card After rebooting into the custom kernel, or after loading the required module, the sound card should appear in the system message buffer. Run &man.dmesg.8; and look for a message like: pcm0: <Intel ICH3 (82801CA)> port 0xdc80-0xdcbf,0xd800-0xd8ff irq 5 at device 31.5 on pci0 pcm0: [GIANT-LOCKED] pcm0: <Cirrus Logic CS4205 AC97 Codec> The status of the sound card may also be checked using this command: &prompt.root; cat /dev/sndstat FreeBSD Audio Driver (newpcm) Installed devices: pcm0: <Intel ICH3 (82801CA)> at io 0xd800, 0xdc80 irq 5 bufsz 16384 kld snd_ich (1p/2r/0v channels duplex default) The output may vary between systems. If no pcm devices are listed, go back and review the kernel configuration file and make sure the correct device driver was chosen. Common problems are listed in . If all goes well, the sound card should now work in os;. If the CD-ROM or DVD-ROM drive's audio-out pins are properly connected to the sound card, one can insert an audio CD in the drive and play it with &man.cdcontrol.1;: &prompt.user; cdcontrol -f /dev/acd0 play 1 Various applications, such as audio/workman provide a friendlier interface. The audio/mpg123 port can be installed to listen to MP3 audio files. Another quick way to test the card is to send data to /dev/dsp: &prompt.user; cat filename > /dev/dsp where filename can be any file. This command should produce some noise, confirming that the sound card is actually working. The /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 card mixer levels can be changed using &man.mixer.8;. More details can be found in &man.mixer.8;. Common Problems device nodes I/O port IRQ DSP Error Solution 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! Check with fstat | grep dsp if another application is holding the device open. Noteworthy troublemakers are esound and KDE's sound support. Another issue is that modern graphics cards often come with their own sound driver, for use with HDMI and similar. This sound device will sometimes be enumerated before the sound card and the sound card will subsequently not be used as the default playback device. To check if this is the case, run dmesg and look for pcm. The output looks something like this: ... 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: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 0 nid 1 on hdac0 pcm1: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 1 nid 1 on hdac0 pcm2: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 2 nid 1 on hdac0 pcm3: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 3 nid 1 on hdac0 hdac1: HDA Codec #2: Realtek ALC889 pcm4: <HDA Realtek ALC889 PCM #0 Analog> at cad 2 nid 1 on hdac1 pcm5: <HDA Realtek ALC889 PCM #1 Analog> at cad 2 nid 1 on hdac1 pcm6: <HDA Realtek ALC889 PCM #2 Digital> at cad 2 nid 1 on hdac1 pcm7: <HDA Realtek ALC889 PCM #3 Digital> at cad 2 nid 1 on hdac1 ... Here 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: &prompt.root; sysctl hw.snd.default_unit=n Here, 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 /etc/sysctl.conf: hw.snd.default_unit=4 Munish Chopra Contributed by Utilizing Multiple Sound Sources It is often desirable to have multiple sources of sound that are able to play simultaneously. &os; uses Virtual Sound Channels, which can be enabled using &man.sysctl.8;. Virtual channels allow one to multiplex the sound card's playback by mixing sound in the kernel. To set the number of virtual channels, three &man.sysctl.8; knobs are available: &prompt.root; sysctl dev.pcm.0.play.vchans=4 &prompt.root; sysctl dev.pcm.0.rec.vchans=4 &prompt.root; sysctl hw.snd.maxautovchans=4 The above 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 the number of virtual channels pcm0 has for playback and recording, and are configurable after a device has been attached. hw.snd.maxautovchans is the number of virtual channels a new audio device is given when it is attached using &man.kldload.8;. Since the pcm module can be loaded independently of the hardware drivers, hw.snd.maxautovchans indicates how many virtual channels will be given to devices when they are attached. Refer to &man.pcm.4; for more information. 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 pcm device will automatically be allocated transparently to a program that requests /dev/dsp0. Josef El-Rayes Contributed by Setting Default Values for Mixer Channels The default values for the different mixer channels are hardcoded in the source code of the &man.pcm.4; driver. There are many different applications and daemons that allow values to be set for the mixer that are remembered between invocations, but this is not a clean solution. It is possible to set default mixer values at the driver level. This is accomplished by defining the appropriate values in /boot/device.hints, as seen in this example: hint.pcm.0.vol="50" This will set the volume channel to a default value of 50 when the &man.pcm.4; module is loaded. Chern Lee Contributed by MP3 Audio This section describes some MP3 players available for &os;, how to rip audio CD tracks, and how to encode and decode MP3s. MP3 Players A popular graphical MP3 player is XMMS. Winamp skins can be used with XMMS since the interface is almost identical to that of Nullsoft's Winamp. XMMS also has native plug-in support. XMMS can be installed from the multimedia/xmms port or package. XMMS's interface is intuitive, with a playlist, graphic equalizer, and more. Those familiar with Winamp will find XMMS simple to use. The audio/mpg123 port provides an alternative, command-line MP3 player. mpg123 can be run by specifying the sound device and the MP3 file on the command line. Assuming the audio device is /dev/dsp1.0 and the MP3 file is Foobar-GreatestHits.mp3, enter the following to play the file: &prompt.root; mpg123 -a /dev/dsp1.0 Foobar-GreatestHits.mp3 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 Ripping CD Audio Tracks 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. The cdda2wav tool, which is installed with the sysutils/cdrtools suite, is used for ripping audio information from CDs and the information associated with them. 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: &prompt.root; cdda2wav -D 0,1,0 -B The indicates the SCSI device 0,1,0, which corresponds to the output of cdrecord -scanbus. cdda2wav will support ATAPI (IDE) CDROM drives. To rip from an IDE drive, specify the device name in place of the SCSI unit numbers. For example, to rip track 7 from an IDE drive: &prompt.root; cdda2wav -D /dev/acd0 -t 7 To rip individual tracks, make use of the as shown: &prompt.root; cdda2wav -D 0,1,0 -t 7 This example rips track seven of the audio CDROM. To rip a range of tracks, such as track one to seven, specify a range: &prompt.root; cdda2wav -D 0,1,0 -t 1+7 &man.dd.1; can also be used to extract audio tracks on ATAPI drives, as described in . Encoding MP3s Lame is a popular MP3 encoder which can be installed from the audio/lame port. Due to licensing restrictions, a package is not available. The following command will convert the ripped WAV files audio01.wav to audio01.mp3: &prompt.root; lame -h -b 128 \ --tt "Foo Song Title" \ --ta "FooBar Artist" \ --tl "FooBar Album" \ --ty "2001" \ --tc "Ripped and encoded by Foo" \ --tg "Genre" \ audio01.wav audio01.mp3 128 kbits is a standard MP3 bitrate. The 160 and 192 bitrates provide higher quality. The higher the bitrate, the larger the size of the resulting MP3. turns on the higher quality but a little slower mode. The options beginning with 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. Decoding MP3s In order to burn an audio CD from MP3s, they must first be converted to a non-compressed WAV format. Both XMMS and mpg123 support the output of MP3 to an uncompressed file format. Writing to Disk 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. Writing to stdout in mpg123: Run mpg123 -s audio01.mp3 > audio01.pcm XMMS writes a file in the WAV format, while mpg123 converts the MP3 into raw PCM audio data. Both of these formats can be used with cdrecord to create audio CDs, whereas &man.burncd.8; requires a raw Pulse-Code Modulation (PCM. 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. One can remove the header with SoX, which can be installed from the audio/sox port or package: &prompt.user; sox -t wav -r 44100 -s -w -c 2 track.wav track.raw Refer to for more information on using a CD burner in &os;. Ross Lippert Contributed by Video Playback Before configuring video playback, determine the model of the video card and the chip it uses. While &xorg; supports a wide variety of video cards, fewer give good playback performance. To obtain a list of extensions supported by the &xorg; server using the card, run &man.xdpyinfo.1; while &xorg; is running. 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 /dev/dvd by default, or have this device name hardcoded in them, it might be useful to make symbolic links to the proper devices: &prompt.root; ln -sf /dev/acd0 /dev/dvd &prompt.root; ln -sf /dev/acd0 /dev/rdvd Due to the nature of &man.devfs.5;, manually created links will not persist after a system reboot. In order to create the symbolic links automatically when the system boots, add the following lines to /etc/devfs.conf: link acd0 dvd link acd0 rdvd DVD decryption invokes special DVD-ROM functions and requires write permission on the DVD devices. To enhance the shared memory &xorg; interface, it is recommended to increase the values of these &man.sysctl.8; variables: kern.ipc.shmmax=67108864 kern.ipc.shmall=32768 Determining Video Capabilities XVideo SDL DGA There are several possible ways to display video under &xorg;. What works is largely hardware dependent. Each method described below will have varying quality across different hardware. Common video interfaces include: &xorg;: normal output using shared memory. XVideo: an extension to the &xorg; interface which supports video in any drawable object. SDL: the Simple Directmedia Layer. DGA: the Direct Graphics Access. SVGAlib: low level console graphics layer. XVideo &xorg; has an extension called XVideo, also known as Xvideo, Xv, and xv. It allows video to be directly displayed in drawable objects through a special acceleration. This extension provides good quality playback even on low-end machines. To check whether the extension is running, use xvinfo: &prompt.user; xvinfo XVideo is supported for the card if the result looks like: 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 looks like: X-Video Extension version 2.2 screen #0 no adaptors present XVideo is probably not supported for the card. This means that it will be more difficult for the display to meet the computational demands of rendering video. Depending on the video card and processor, one might still be able to have a satisfying experience. Simple Directmedia Layer The Simple Directmedia Layer, SDL, is a porting layer for many operating systems allowing cross-platform applications to be developed which make efficient use of sound and graphics. The SDL layer provides a low-level abstraction to the hardware which can sometimes be more efficient than the &xorg; interface. SDL can be installed using the devel/sdl12 package or port. Direct Graphics Access DGA 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 q. Ports and Packages Dealing with Video video ports video packages This section introduces some of the software available from the &os; Ports Collection which can be used for video playback. Many of the video applications which run on &os; were developed as &linux; applications. Many of these applications are still beta-quality. Some of the problems commonly encountered with video packages on &os; include: An application cannot playback a file which another application produced. An application cannot playback a file which the application itself produced. The same application on two different machines, rebuilt on each machine for that machine, plays back the same file differently. A seemingly trivial filter, like rescaling of the image size, results in bad artifacts from a buggy rescaling routine. An application frequently dumps core. Documentation is not installed with the port and can be found either on the web or under the port's work directory. Many applications may also exhibit &linux;-isms. There may be issues resulting from the way some standard libraries are implemented in the &linux; distributions, or some features of the &linux; kernel which have been assumed by the authors of the applications. These issues are not always noticed and worked around by the port maintainers, which can lead to problems like these: The use of /proc/cpuinfo to detect processor characteristics. A misuse of threads which causes a program to hang upon completion instead of truly terminating. Relies on software which is not yet available in the &os; Ports Collection. MPlayer MPlayer is a command-line video player with an optional graphical interface which aims to provide speed and flexibility. This application, as well as other graphical front-ends, is available from the &os; Ports Collection. Building MPlayer MPlayer making MPlayer is available as a package or port in multimedia/mplayer. Several compile options are available and a variety of hardware checks occur during the build process. For these reasons, some users prefer to build the port rather than install the package. The available options will be displayed in a menu after these commands are input: &prompt.root; cd /usr/ports/multimedia/mplayer &prompt.root; make 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 Enter to continue the port compile and installation. By default, this package or port will build the mplayer command line utility and the gmplayer graphical utility. To encode videos, install the multimedia/mencoder port. Due to licensing restrictions, a package is not available for MEncoder. Using MPlayer MPlayer use The first time MPlayer is run, it will create ~/.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 the mplayer manual page for a complete description of its numerous options. To play the file testfile.avi, specify the video interfaces with : &prompt.user; mplayer -vo xv testfile.avi &prompt.user; mplayer -vo sdl testfile.avi &prompt.user; mplayer -vo x11 testfile.avi &prompt.root; mplayer -vo dga testfile.avi &prompt.root; mplayer -vo 'sdl:dga' testfile.avi It is worth trying all of these options, as their relative performance depends on many factors and will vary significantly with hardware. To play a DVD, replace the testfile.avi with , where N is the title number to play and DEVICE is the device node for the DVD-ROM. For example, to play title 3 from /dev/dvd: &prompt.root; mplayer -vo xv dvd://3 -dvd-device /dev/dvd 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 /dev/acd0. More details can be found in the port's Makefile.options. To stop, pause, advance, and so on, consult the keybindings, which are displayed by running mplayer -h, or read the manual page. Additional playback options include , which engages fullscreen mode, and , which helps performance. Each user can add commonly used options to their ~/.mplayer/config like so: vo=xv fs=yes zoom=yes mplayer can be used to rip a DVD title to a .vob. To dump the second title from a DVD: &prompt.root; mplayer -dumpstream -dumpfile out.vob dvd://2 -dvd-device /dev/dvd The output file, out.vob, will be MPEG and can be manipulated by the other packages described in this section. The MPlayer documentation is technically informative and should be consulted by anyone wishing to obtain a high level of expertise with &unix; video. The MPlayer mailing list is hostile to anyone who has not bothered to read the documentation, so before making a bug report, read the documentation first. <application>MEncoder</application> mencoder Before using mencoder, it is a good idea to become familiar with the options described in the HTML documentation. 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: &prompt.user; mencoder input.avi -oac copy -ovc copy -o output.avi To rip to a file, use with mplayer. To convert input.avi to the MPEG4 codec with MPEG3 audio encoding, first install the audio/lame port. Due to licensing restrictions, a package is not available. Once installed, type: &prompt.user; mencoder input.avi -oac mp3lame -lameopts br=192 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq -o output.avi This will produce output playable by applications such as mplayer and xine. input.avi can be replaced with 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 dump the title to a file and to work on the file. The <application>xine</application> Video Player 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 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 to play a file immediately without the graphical interface: &prompt.user; xine Alternatively, it may be invoked to play a file immediately without the GUI with the command: &prompt.user; xine -g -p mymovie.avi The xine HOWTO contains a chapter on performance improvement which is general to all players. The <application>transcode</application> Utilities 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. transcode can be installed using the 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 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): &prompt.user; transcode -i input.avi -V --export_prof vcd-pal -o output_vcd &prompt.user; mplex -f 1 -o output_vcd.mpg output_vcd.m1v output_vcd.mpa The resulting MPEG file, output_vcd.mpg, is ready to be played with MPlayer. The file can be burned on a CD-R media to create a Video CD. In this, install and use the multimedia/vcdimager and sysutils/cdrdao programs. In addition to the manual page for transcode, refer to the transcode wiki for further information and examples. Josef El-Rayes Original contribution by Marc Fonvieille Enhanced and adapted by Setting Up TV Cards TV cards Introduction TV cards allow can be used to watch broadcast or cable TV on a computer. Most cards accept composite video via an RCA or S-video input and some cards include a FM radio tuner. &os; provides support for PCI-based TV cards using a Brooktree Bt848/849/878/879 or a Conexant CN-878/Fusion 878a video capture chip with the &man.bktr.4; driver. Ensure the board comes with a supported tuner. Consult &man.bktr.4; for a list of supported tuners. Loading the Driver In order to use the card, the &man.bktr.4; driver must be loaded. To automate this at boot time, add the following line to /boot/loader.conf: bktr_load="YES" Alternatively, one can statically compile support for the TV card into a custom kernel. In that case, add the following lines to the custom kernel configuration file: device bktr device iicbus device iicbb device smbus These additional devices are necessary as the card components are interconnected via an I2C bus. Then, build and install a new kernel. To test the driver, reboot the system. The TV card should appear in the boot messages, as seen in this example: bktr0: <BrookTree 848A> mem 0xd7000000-0xd7000fff irq 10 at device 10.0 on pci0 iicbb0: <I2C bit-banging driver> on bti2c0 iicbus0: <Philips I2C bus> on iicbb0 master-only iicbus1: <Philips I2C bus> on iicbb0 master-only smbus0: <System Management Bus> on bti2c0 bktr0: Pinnacle/Miro TV, Philips SECAM tuner. The messages will differ according to the hardware. Check the messages to determine if the tuner is correctly detected. It is still possible to override some of the detected parameters with &man.sysctl.8; MIBs and kernel configuration file options. For example, to force the tuner to a Philips SECAM tuner, add the following line to a custom kernel configuration file: options OVERRIDE_TUNER=6 or, use &man.sysctl.8;: &prompt.root; sysctl hw.bt848.tuner=6 Refer to &man.bktr.4; and /usr/src/sys/conf/NOTES for more details on the available options. Useful Applications To use the TV card, install one of the following applications: multimedia/fxtv provides TV-in-a-window and image/audio/video capture capabilities. multimedia/xawtv is another TV application with similar features. audio/xmradio provides an application for using the FM radio tuner of a TV card. More applications are available in the &os; Ports Collection. Troubleshooting If any problems are encountered with the TV card, check that the video capture chip and the tuner are supported by &man.bktr.4; and that the right configuration options were used. For more support and various questions about TV cards, refer to the archives of the &a.multimedia.name; mailing list. MythTV MythTV is a popular, open source PVR application. This section demonstrates how to install and setup MythTV on &os;. Refer to the MythTV wiki for more information on how to use MythTV. MythTV requires a frontend and a backend; however, it allows the user to have the frontend and backend on different machines. For the frontend, multimedia/mythtv-frontend is required, as well as an X server, which can be found in x11/xorg. Ideally, the frontend computer also has a video card that supports XvMC and, optionally, a LIRC-compatible remote. For the backend, multimedia/mythtv is required, along with the &mysql; database server. Optionally a tuner and storage for any recorded data. The &mysql; package should be automatically installed as a dependency when installing multimedia/mythtv. Hardware MythTV is designed to utilize V4L to access video input devices such as encoders and tuners. At this time, MythTV works best with USB DVB-S/C/T cards supported by multimedia/webcamd, as it provides a V4L userland application. Any DVB card supported by webcamd should work with MythTV. A list of known working cards can be found here. Drivers are also available for Hauppauge cards in the following ports: multimedia/pvr250 and multimedia/pvrxxx, 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. The HTPC wiki page contains a list of all available DVB drivers. Setting up MythTV To install the MythTV port: &prompt.root; cd /usr/ports/multimedia/mythtv &prompt.root; make install Once installed, set up the MythTV database: &prompt.root; mysql -uroot -p < /usr/local/share/mythtv/database/mc.sql Configure the backend: &prompt.root; mythtv-setup Start the backend: &prompt.root; echo 'mythbackend_enable="YES"' >> /etc/rc.conf &prompt.root; service mythbackend start Marc Fonvieille Written by Image Scanners image scanners In &os;, access to image scanners is provided by the SANE (Scanner Access Now Easy) API available through the &os; Ports Collection. SANE will also use some &os; device drivers to provide access to the scanner hardware. &os; supports both SCSI and USB scanners. Be sure the scanner is supported by SANE prior to performing any configuration. Refer to the supported devices list for more information about supported scanners. Kernel Configuration Both SCSI and USB interfaces are supported. Depending upon the scanner interface, different device drivers are required. USB Interface The GENERIC kernel by default includes the device drivers needed to support USB scanners. Users with a custom kernel should ensure that the following lines are present in the custom kernel configuration file: device usb device uhci device ohci device ehci Plug in the USB scanner. Use &man.dmesg.8; to determine whether the scanner appears in the system message buffer: ugen0.2: <EPSON> at usbus0 These messages indicate that the scanner is using either /dev/ugen0.2 or /dev/uscanner0, depending on the &os; version. For this example, a &epson.perfection; 1650 USB scanner was used. SCSI Interface 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 GENERIC kernel supports the most common SCSI controllers. Refer to /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 the kernel configuration file: device scbus device pass Verify that the device is displayed in the system message buffer: pass2 at aic0 bus 0 target 2 lun 0 pass2: <AGFA SNAPSCAN 600 1.10> Fixed Scanner SCSI-2 device pass2: 3.300MB/s transfers If the scanner was not powered-on at system boot, it is still possible to manually force the detection by performing a SCSI bus scan with the &man.camcontrol.8; command: &prompt.root; 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 The scanner should now appear in the SCSI devices list: &prompt.root; camcontrol devlist <IBM DDRS-34560 S97B> at scbus0 target 5 lun 0 (pass0,da0) <IBM DDRS-34560 S97B> at scbus0 target 6 lun 0 (pass1,da1) <AGFA SNAPSCAN 600 1.10> at scbus1 target 2 lun 0 (pass3) <PHILIPS CDD3610 CD-R/RW 1.00> at scbus2 target 0 lun 0 (pass2,cd0) Refer to &man.scsi.4; and &man.camcontrol.8; for more details about SCSI devices on &os;. SANE Configuration The SANE system is split in two parts: the backends (graphics/sane-backends) and the frontends (graphics/sane-frontends). The backends provide access to the scanner. The SANE's supported devices list specifies which backend will support the image scanner. The correct backend is needed in order to use the scanner. The frontends provide the graphical scanning interface, xscanimage. After installing the graphics/sane-backends port or package, use sane-find-scanner to check the scanner detection by the SANE system: &prompt.root; sane-find-scanner -q found SCSI scanner "AGFA SNAPSCAN 600 1.10" at /dev/pass3 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. Some USB scanners require firmware to be loaded. Refer to &man.sane-find-scanner.1; and &man.sane.7; for details. Next, check if the scanner will be identified by a scanning frontend. By default, the SANE backends come with a command line tool called &man.scanimage.1;. This command can be used to list the devices and perform an image acquisition. Use to list the scanner devices: &prompt.root; scanimage -L device `snapscan:/dev/pass3' is a AGFA SNAPSCAN 600 flatbed scanner Here is the output for the USB scanner used in : &prompt.root; scanimage -L device 'epson2:libusb:/dev/usb:/dev/ugen0.2' is a Epson GT-8200 flatbed scanner In this output, 'epson2:libusb:/dev/usb:/dev/ugen0.2' is the backend name (epson2) and the device node (/dev/ugen0.2) used by the scanner. No output or a message saying that no scanners were identified indicates that &man.scanimage.1; is unable to identify the scanner. If this happens, edit the backend configuration file in /usr/local/etc/sane.d/ and define the scanner device used. In the above example, the USB scanner is perfectly detected and working. To determine if the scanner is correctly identified: &prompt.root; 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). Since the scanner is not identified, edit /usr/local/etc/sane.d/epson2.conf. In this example, the scanner model is &epson.perfection; 1650 and it uses the epson2 backend. When editing, read the help comments in the backend configuration file. Line changes are simple: comment out all lines that have the wrong interface for the scanner. In this example, comment out all lines starting with the word scsi as the scanner uses the USB interface. Then, at the end of the file, add a line specifying the interface and the device node used. In this case, add the following line: usb /dev/uscanner0 Save the edits and verify that the scanner is identified: &prompt.root; scanimage -L device `epson:/dev/uscanner0' is a Epson GT-8200 flatbed scanner The `epson:/dev/uscanner0' field now gives the right backend name and the device node. Once scanimage -L sees the scanner, the configuration is complete and the device is now ready to scan. While &man.scanimage.1; can be used to perform an image acquisition from the command line, it is often preferable to use a graphical interface to perform image scanning. The graphics/sane-frontends package or port installs a simple but efficient graphical interface, xscanimage. Xsane, which is installed with the 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. Giving Other Users Access to the Scanner 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 /dev/ugen0.2 which is really a symlink to the real device node /dev/usb/0.2.0. The symlink and the device node are owned, respectively, by the wheel and operator groups. Adding the user to these groups will allow access to the scanner. However, for security reasons, always think twice before adding a user to any group, especially wheel. A better solution is to create a group to make the scanner device accessible to members of this group. This example creates a group called usb using &man.pw.8;: &prompt.root; pw groupadd usb Then, make the /dev/ugen0.2 symlink and the /dev/usb/0.2.0 device node accessible to the usb group with write permissions of (0660 or 0664. All of this is done by adding the following lines to /etc/devfs.rules: [system=5] add path ugen0.2 mode 0660 group usb add path usb/0.2.0 mode 0666 group usb Finally, add the users to usb in order to allow access to the scanner: &prompt.root; pw groupmod usb -m joe For more details refer to &man.pw.8;.