Index: AUTHORS =================================================================== RCS file: /cvsroot/mplayer/main/AUTHORS,v retrieving revision 1.158 diff -u -r1.158 AUTHORS --- AUTHORS 2 Sep 2005 00:03:02 -0000 1.158 +++ AUTHORS 3 Sep 2005 23:22:48 -0000 @@ -331,6 +331,7 @@ Hickey, Corey * telecine/interlacing HOWTO for the MEncoder documentation + * advanced audio usage guide for the MPlayer documentation Hidvégi, Zoltán (Zoli) * filmdint video filter Index: ChangeLog =================================================================== RCS file: /cvsroot/mplayer/main/ChangeLog,v retrieving revision 1.241 diff -u -r1.241 ChangeLog --- ChangeLog 3 Sep 2005 14:41:09 -0000 1.241 +++ ChangeLog 3 Sep 2005 23:22:49 -0000 @@ -6,6 +6,7 @@ * improved encoding guide * new technical encoding guide in DOCS/tech/encoding-guide.txt which is to be merged into the existing guide + * new advanced audio usage guide * encoding tips for x264 and XviD * how to set up MEncoder for x264 support * Hungarian XML documentation translation finished Index: DOCS/xml/en/usage.xml =================================================================== RCS file: /cvsroot/mplayer/main/DOCS/xml/en/usage.xml,v retrieving revision 1.27 diff -u -r1.27 usage.xml --- DOCS/xml/en/usage.xml 18 May 2005 12:15:30 -0000 1.27 +++ DOCS/xml/en/usage.xml 3 Sep 2005 23:22:51 -0000 @@ -400,4 +400,591 @@ + + +Advanced Audio + + +Surround/Multichannel Playback + + +DVDs + +Most DVDs and many other files include surround sound. +MPlayer supports surround playback but does not +enable it by default because stereo equipment is by far more common. To play a +file that has more than 2-channel audio use . For +example, to play a DVD with 5.1 audio: + +mplayer dvd://1 -channels 6 + +Note that despite the name "5.1" there are actually six discrete channels. +If you have surround sound equipment it is safe to put the channels option in +your MPlayer configuration file +~/.mplayer/config. For example, to make quadraphonic +playback the default, add this line: + +channels=4 + +MPlayer will then output audio in four channels when +all four channels are available. + + + + + +Playing Stereo Files to Four Speakers + + +MPlayer does not duplicate any channels by default, +and nor do most audio drivers. If you want to do that manually: + +mplayer filename -af channels=2:2:0:1:0:0 + +See the section on +channel copying for an +explanation. + + + + + + +AC3/DTS Passthrough + + +DVDs usually have surround audio encoded in AC3 (Dolby Digital) or DTS +(Digital Theater System) format. Some modern audio equipment is capable of +decoding these formats internally. In this case +MPlayer sends out the original, undecoded audio data. +This will only work if you have a S/PDIF (Sony/Philips Digital Interface) jack +in your sound card. + + + +If your audio equipment can decode both AC3 and DTS, you can enable passthrough +for both formats. Otherwise, you can specify either one. + + + +To enable passthrough on the command line: + +For AC3 only, use + + +For DTS only, use + + +For both AC3 and DTS, use + + + + +To enable passthrough in the <application>MPlayer</application> +configuration file: + +For AC3 only, use + + +For DTS only, use + + +For both AC3 and DTS, use + + + + +Note that there is a comma (",") at the end of + and . This will make +MPlayer fall back to the codecs it normally uses when +playing a file that doesn't have AC3 or DTS audio. +does not need a comma; MPlayer will fall back anyway +when an audio family is specified. + + + + + + +Matrix-encoded Audio + + +***TODO*** +I don't know a thing about this. I don't even know if I have a matrix-encoded +sample to test with. Can somebody provide me a clue, a sample, or both? I asked +about this on -advusers last night but haven't gotten a response yet. +Otherwise I'll just drop this section. + + + +Good links: + + +http://electronics.howstuffworks.com/surround-sound5.htm + + +http://www.extremetech.com/article2/0,1697,1016875,00.asp + + + + + + + + +Surround Emulation in Headphones + + +MPlayer includes an HRTF (Head Related Transfer +Function) filter based on an MIT project wherein measurements were taken from +microphones mounted on a dummy human head. See the +project page for more +information. + + + +Although it is not possible to exactly imitate a surround system, +MPlayer's HRTF filter does provide more spatially +immersing audio in 2-channel headphones. Regular downmixing simply combines all +the channels into two; besides combining the channels, +generates subtle echoes, increases the stereo separation slightly, and alters +the volume of some frequencies. Whether HRTF sounds better may be dependant on +the source audio and a matter of personal taste, but it is definitely worth +trying out. + + + +To play a DVD with HRTF: + +mplayer dvd://1 -channels 6 -af hrtf + + + + + only works best with 5 or 6 channels. Also, + requires 48 kHz audio. DVD audio is already 48 kHz, but if +you have a file with a different sampling rate that you want to play using + you must resample it: + +mplayer filename -channels 6 -af resample=48000,hrtf + + + + + + + +Troubleshooting + + +If you don't hear any sound out of your surround channels, check your mixer +settings with a mixer program such as alsamixer; +audio outputs are often muted and set to zero volume by default. + + + + + + + + +Channel Manipulation + + +General Information + + +Unfortunately, there is no standard for how channels are ordered. The orders +listed below are those of AC3 and are fairly typical; try them and see if your +source matches. Channels are numbered starting with 0. + + +Mono +center + + + +Stereo +left +right + + + +Quadraphonic +left front +right front +left rear +right rear + + + +Surround 4.0 +left front +right front +center rear +center front + + + +Surround 5.0 +left front +right front +left rear +right rear +center front + + + +Surround 5.1 +left front +right front +left rear +right rear +center front +subwoofer + + + + + +The option is used to request the number of +channels from the audio decoder. Some audio codecs (such as liba52 for decoding +AC3) use the number of specified channels to decide if downmixing the source is +necessary. Note that this does not always affect the number of output channels. +For example, using to play a stereo mp3 file will +still result in 2-channel output since the mp3 codec will not produce the extra +channels. + + + +The audio filter can be used to create or remove +channels and is useful for controlling the number of channels sent to the sound +card. See the following sections for more information on channel manipulation. + + + + + + +Playing Mono in Two Speakers + + +Mono sounds a lot better when played through two speakers -- especially when +using headphones. Audio files that truly have 1 channel are automatically played +in two speakers; unfortunately, most files with mono sound are actually encoded +as stereo with one channel silent. The easiest and most foolproof way to make +both speakers output the same audio is with the +filter: + +mplayer filename -af extrastereo=0 + + + + +This averages both channels, resulting in both channels being half as loud as +the original. The next sections have examples of other ways to do this without a +volume decrease, but they are more complex and require different options +depending on which channel to keep. If you really need to maintain the volume +than an easier way is to experiment with the filter and +find the right value. For example: + +mplayer filename -af extrastereo=0,volume=5 + + + + + + + +Channel Copying/Moving + + +The filter can move any or all channels. Setting up all +the suboptions to channels can be complicated and takes a little care. + + + +Decide how many output channels you need. This is the first suboption. + + +Count how many channel moves you will do. This is the second suboption. Each +channel can be moved to several different channels at the same time, but keep in +mind that when a channel is moved (even if to only one destination) the source +channel will be empty unless another channel is moved into it. To copy a +channel, keeping the source the same, simply move the channel into both the +destination and the source. For example: + +channel 2 --> channel 3 +channel 2 --> channel 2 + + + +Write out the channel copies as pairs of suboptions. Note that the first channel +is 0, the second is 1, etc. The order of these suboptions does not matter as +long as they are properly grouped into +source:destination pairs. + + + + + + +Example: one channel in two speakers + + +Here's an example of another way to play one channel in both speakers. Suppose +for this example that the left channel should be played and the right channel +discarded. Following the steps above: + + +There should be two output channels: one for each speaker. The first suboption +is "2". + + +The left channel needs to be moved to the right channel, and also must be moved +to itself so it won't be empty. This is a total of two moves, making the second +suboption "2" as well. + + +To move the left channel (channel 0) into the right channel (channel 1), the +suboption pair is "0:1". To move the left channel into itself is "0:0". + + +Putting that all together gives: + +mplayer filename -af channels=2:2:0:1:0:0 + + + +The advantage this example has over is that the +volume of each output channel is the same as the input channel. The disadvantage +is that the suboptions must be changed to "2:2:1:0:1:1" when the desired audio +is in the right channel. Also, it's more difficult to remember and type. + + +Example: left channel in two speakers shortcut + + +There is actually a much easier way to use the filter +for playing the left channel in both speakers: + +mplayer filename -af channels=1 + +The second channel is discarded and, with no further suboptions, the single +remaining channel is left alone. Sound card drivers automatically play +single-channel audio in both speakers. This only works when the desired channel +is on the left. + + +Example: duplicate front channels to the rear + +Another common operation is to duplicate the front channels and play them back +on the rear speakers of a quadraphonic setup. + + +There should be four output channels. The first suboption is "4". + + +Each of the two front channels needs to be moved to the corresponding rear +channel and also to itself. This is four moves, so the second suboption is "4". + + +The left front (channel 0) needs to moved to the left rear (channel 2): "0:2". +The left front also needs to be moved to itself: "0:0". The right front (channel +1) is moved to the right rear (channel 3): "1:3", and also to itself: "1:1". + + +Combine all the suboptions to get: + +mplayer filename -af channels=4:4:0:2:0:0:1:3:1:1 + + + + + + + +Channel Mixing + + +The filter can mix channels in user-specified proportions. +This allows for everything the filter can do and +more. Unfortunately, the suboptions are much more complicated. + + +Decide how many channels to work with. You may need to specify this with + and/or . Later examples +will show when to use which. + + +Decide how many channels to input into (further decoded +channels are discarded). This is the first suboption, and also controls how many +channels are output. + + +The remaining suboptions specify how much of each channel gets mixed into each +other channel. This is the complicated part. To break the task down, split the +suboptions into several sets, one set for each output channel. Each suboption +within a set corresponds to an input channel. The number you specify will be the +percentage of the input channel that gets mixed into the output channel. + + + accepts values from 0 to 512, yielding 0% to 51200% of the +original volume. Be careful when using values greater than 1. Not only can this +give you very high volume, but if you exceed the sample range of your sound card +you may hear painful pops and clicks. If you want you can follow + with to enable clipping, but it's +best to keep the values of low enough that clipping is not +necessary. + + + + +Example: one channel in two speakers + + +Here is yet another example for playing the left channel in two speakers. Follow +the steps above: + + +The number of output channels is 2. Since this is the same as the number of +channels in the input file neither nor + needs to be specified. + + +Pan should receive and output two channels, so the first suboption is "2". + + +Since we have two output channels there will be two sets of suboptions. Since +there are also two input channels there will be two suboptions per set. The left +channel should consist of 100% of itself and 0% of the right channel. So, the +first set of suboptions is "1:0". The right channel should be 100% of the left +channel and 0% of itself. This is "1:0" as well. + + +Putting those options together gives: + +mplayer filename -af pan=2:1:0:1:0 + +If the right channel is desired instead of the left, the suboptions to + will be "2:0:1:0:1". + + + +Example: left channel in two speakers shortcut + + +As with , there is a shortcut that only works with the +left channel: + +mplayer filename -af pan=1:1 + +Since has only one channel of input (the other channel is +discarded), there is only one set with one suboption, which specifies that the +only channel gets 100% of itself. + + +Example: downmixing a 6-channel wave file + +MPlayer's decoder for 6-channel PCM is not capable of +downmixing. Here's a way to downmix a wave file using : + + +The number of output channels is 2. Since will be handling +6 channels, it may be necessary to put after pan to +get rid of the extra channels. If your sound card is capable of 6-channel +playback you can skip this, as the discarded channels will be empty by then anyway. + + + must receive all six channels to downmix, so the first +suboption is "6". + + +With six input channels there will be six suboptions per set. Fortunately, +since we only care about the output of the first two channels we only need to +make two sets; the remaining four sets can be omitted. Beware that not all +multichannel audio files have the same channel order! This example +demonstrates downmixing a file with the same channels as AC3 5.1: + +0 - front left +1 - front right +2 - rear left +3 - rear right +4 - center front +5 - subwoofer + +The first set of suboptions lists the percentages, in order, that each channel +listed above should be mixed into the front left channel: "1:0:1:0:0.5:1". For +the front right channel: "0:1:0:1:0.5:1". + + +Put all that together, for: + +mplayer 6-channel.wav -af pan=6:1:0:1:0:0.5:1:0:1:0:1:0.5:1,channels=2 + +The percentages listed above are only a rough example. Feel free to tweak them. + + +Example: Playing 5.1 audio on big speakers without a subwoofer + + +If you have a huge pair of front speakers you may not want to waste any money on +buying a subwoofer for a complete 5.1 sound system. If you use + to request that liba52 decode 5.1 audio in 5.0, +the subwoofer channel is simply discarded. If you want to distribute the +subwoofer channel yourself you need to downmix manually with +: + + + +Since needs to examine all six channels, specify + so liba52 decodes them all. + + + needs all the channels, so the first suboption is 6 as +well. + + +Since the subwoofer channel is the last of six, we can specify five sets of +suboptions and omit the set belonging to the subwoofer channel. Each of those +five sets needs six suboptions so the list will get pretty long. + + + The left front channel should have itself and half the subwoofer channel: + "1:0:0:0:0:0.5" + + + The right front channel should have itself and half the subwoofer channel: + "0:1:0:0:0:0.5" + + + The left rear channel stays the same: + "0:0:1:0:0:0" + + + The right rear channel stays the same: + "0:0:0:1:0:0" + + + The center front channel stays the same: + "0:0:0:0:1:0" + + + The subwoofer channel is left out and it will be silent. + + + + +Combine all those options to get: + +mplayer dvd://1 -channels 6 -af pan=6:1:0:0:0:0:0.5:0:1:0:0:0:0.5:0:0:1:0:0:0:0:0:0:1:0:0:0:0:0:0:1:0 + + + + + + + + +