1 <?xml version="1.0" encoding="utf-8"?>
6 <sect1 id="commandline">
7 <title>Command line</title>
10 <application>MPlayer</application> utilizes a complex playtree. Options passed
11 on the command line can apply to all files/URLs or just to specific ones
12 depending on their position. For example
13 <screen>mplayer -vfm ffmpeg movie1.avi movie2.avi</screen>
14 will use FFmpeg decoders for both files, but
16 mplayer -vfm ffmpeg <replaceable>movie1.avi</replaceable> <replaceable>movie2.avi</replaceable> -vfm dmo
18 will play the second file with a DMO decoder.
22 You can group filenames/URLs together using <literal>{</literal> and
23 <literal>}</literal>. It is useful with option <option>-loop</option>:
24 <screen>mplayer { 1.avi -loop 2 2.avi } -loop 3</screen>
25 The above command will play files in this order: 1, 1, 2, 1, 1, 2, 1, 1, 2.
31 <command>mplayer</command><!--
32 --> [<replaceable>options</replaceable>]<!--
33 --> [<replaceable>path</replaceable>/]<replaceable>filename</replaceable>
38 Another way to play a file:
40 <command>mplayer</command><!--
41 --> [<replaceable>options</replaceable>]<!--
42 --> <replaceable>file:///uri-escaped-path</replaceable>
49 <command>mplayer</command><!--
50 --> [<replaceable>default options</replaceable>]<!--
51 --> [<replaceable>path</replaceable>/]<replaceable>filename1</replaceable><!--
52 --> [<replaceable>options for filename1</replaceable>]<!--
53 --> <replaceable>filename2</replaceable><!--
54 --> [<replaceable>options for filename2</replaceable>] ...
61 <command>mplayer</command> [<replaceable>options</replaceable>]<!--
62 --> vcd://<replaceable>trackno</replaceable><!--
63 --> [-cdrom-device <replaceable>/dev/cdrom</replaceable>]
70 <command>mplayer</command> [<replaceable>options</replaceable>]<!--
71 --> dvd://<replaceable>titleno</replaceable><!--
72 --> [-dvd-device <replaceable>/dev/dvd</replaceable>]
79 <command>mplayer</command> [<replaceable>options</replaceable>]<!--
80 --> http://<replaceable>site.com/file.asf</replaceable>
82 (playlists can be used, too)
88 <command>mplayer</command> [<replaceable>options</replaceable>]<!--
89 --> rtsp://<replaceable>server.example.com/streamName</replaceable>
96 mplayer -vo x11 <replaceable>/mnt/Films/Contact/contact2.mpg</replaceable>
97 mplayer vcd://<replaceable>2</replaceable> -cdrom-device <replaceable>/dev/hdc</replaceable>
98 mplayer -afm 3 <replaceable>/mnt/DVDtrailers/alien4.vob</replaceable>
99 mplayer dvd://<replaceable>1</replaceable> -dvd-device <replaceable>/dev/hdc</replaceable>
100 mplayer -abs 65536 -delay -0.4 -nobps <replaceable>~/movies/test.avi</replaceable><!--
106 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
110 <title>Subtitles and OSD</title>
113 <application>MPlayer</application> can display subtitles along with movie files.
114 Currently the following formats are supported:
116 <listitem><para>VOBsub</para></listitem>
117 <listitem><para>OGM</para></listitem>
118 <listitem><para>CC (closed caption)</para></listitem>
119 <listitem><para>MicroDVD</para></listitem>
120 <listitem><para>SubRip</para></listitem>
121 <listitem><para>SubViewer</para></listitem>
122 <listitem><para>Sami</para></listitem>
123 <listitem><para>VPlayer</para></listitem>
124 <listitem><para>RT</para></listitem>
125 <listitem><para>SSA</para></listitem>
126 <listitem><para>PJS (Phoenix Japanimation Society)</para></listitem>
127 <listitem><para>MPsub</para></listitem>
128 <listitem><para>AQTitle</para></listitem>
130 <ulink url="http://unicorn.us.com/jacosub/">JACOsub</ulink>
136 <application>MPlayer</application> can dump the previously listed subtitle
137 formats (<emphasis role="bold">except the three first</emphasis>) into the
138 following destination formats, with the given options:
140 <listitem><para>MPsub: <option>-dumpmpsub</option></para></listitem>
141 <listitem><para>SubRip: <option>-dumpsrtsub</option></para></listitem>
142 <listitem><para>MicroDVD: <option>-dumpmicrodvdsub</option></para></listitem>
143 <listitem><para>JACOsub: <option>-dumpjacosub</option></para></listitem>
144 <listitem><para>Sami: <option>-dumpsami</option></para></listitem>
149 <application>MEncoder</application> can dump DVD subtitles into
150 <link linkend="menc-feat-extractsub">VOBsub</link> format.
154 The command line options differ slightly for the different formats:
158 <title>VOBsub subtitles</title>
160 VOBsub subtitles consist of a big (some megabytes) <filename>.SUB</filename>
161 file, and optional <filename>.IDX</filename> and/or <filename>.IFO</filename>
162 files. If you have files like
163 <filename><replaceable>sample.sub</replaceable></filename>,
164 <filename><replaceable>sample.ifo</replaceable></filename> (optional),
165 <filename><replaceable>sample.idx</replaceable></filename> - you have to pass
166 <application>MPlayer</application> the <option>-vobsub sample
167 [-vobsubid <replaceable>id</replaceable>]</option> options
168 (full path optional). The <option>-vobsubid</option> option is like
169 <option>-sid</option> for DVDs, you can choose between subtitle tracks
170 (languages) with it. In case that <option>-vobsubid</option> is omitted,
171 <application>MPlayer</application> will try to use the languages given by the
172 <option>-slang</option> option and fall back to the
173 <systemitem>langidx</systemitem> in the <filename>.IDX</filename> file to set
174 the subtitle language. If it fails, there will be no subtitles.
179 <title>Other subtitles</title>
181 The other formats consist of a single text file containing timing,
182 placement and text information. Usage: If you have a file like
183 <filename><replaceable>sample.txt</replaceable></filename>,
184 you have to pass the option <option>-sub
185 <replaceable>sample.txt</replaceable></option> (full path optional).
190 <title>Adjusting subtitle timing and placement:</title>
192 <term><option>-subdelay <replaceable>sec</replaceable></option></term>
194 Delays subtitles by <option><replaceable>sec</replaceable></option> seconds.
195 Can be negative. The value is added to movie's time position counter.
199 <term><option>-subfps <replaceable>RATE</replaceable></option></term>
201 Specify frame/sec rate of subtitle file (float number).
205 <term><option>-subpos <replaceable>0-100</replaceable></option></term>
207 Specify the position of subtitles.
213 If you experience a growing delay between the movie and the subtitles when
214 using a MicroDVD subtitle file, most likely the framerate of the movie and
215 the subtitle file are different. Please note that the MicroDVD subtitle
216 format uses absolute frame numbers for its timing, but there is no fps
217 information in it, and therefore the <option>-subfps</option> option should
218 be used with this format. If you like to solve this problem permanently,
219 you have to manually convert the subtitle file framerate.
220 <application>MPlayer</application> can do this
224 mplayer -dumpmicrodvdsub -fps <replaceable>subtitles_fps</replaceable> -subfps <replaceable>avi_fps</replaceable> \
225 -sub <replaceable>subtitle_filename</replaceable> <replaceable>dummy.avi</replaceable>
230 About DVD subtitles, read the <link linkend="dvd">DVD</link> section.
235 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
239 <title>Control</title>
242 <application>MPlayer</application> has a fully configurable, command
243 driven, control layer which lets you control
244 <application>MPlayer</application> with keyboard, mouse, joystick or remote
245 control (using LIRC). See the man page for the complete list of keyboard controls.
250 <sect2 id="ctrl-cfg">
251 <title>Controls configuration</title>
254 <application>MPlayer</application> allows you bind any key/button to any
255 <application>MPlayer</application> command using a simple config file.
256 The syntax consist of a key name followed by a command. The default config file location is
257 <filename>$HOME/.mplayer/input.conf</filename> but it can be overridden
258 using the <option>-input <replaceable>conf</replaceable></option> option
259 (relative path are relative to <filename>$HOME/.mplayer</filename>).
263 You can get a full list of supported key names by running
264 <command>mplayer -input keylist</command>
265 and a full list of available commands by running
266 <command>mplayer -input cmdlist</command>.
269 <example id="input_control_file">
270 <title>A simple input control file</title>
273 ## MPlayer input control file
283 ENTER pt_step 1 1<!--
291 <title>Control from LIRC</title>
294 Linux Infrared Remote Control - use an easy to build home-brewed IR-receiver,
295 an (almost) arbitrary remote control and control your Linux box with it!
296 More about it on the <ulink url="http://www.lirc.org">LIRC homepage</ulink>.
300 If you have the LIRC package installed, <filename>configure</filename> will
301 autodetect it. If everything went fine, <application>MPlayer</application>
302 will print "<systemitem>Setting up LIRC support...</systemitem>"
303 on startup. If an error occurs it will tell you. If there is no message about
304 LIRC there is no support compiled in. That's it :-)
308 The application name for <application>MPlayer</application> is - surprise -
309 <filename>mplayer</filename>. You can use any <application>MPlayer</application>
310 commands and even pass more than one command by separating them with
311 <literal>\n</literal>.
312 Do not forget to enable the repeat flag in <filename>.lircrc</filename> when
313 it makes sense (seek, volume, etc). Here is an excerpt from a sample
314 <filename>.lircrc</filename>:
326 button = VOLUME_MINUS
341 config = seek 0 1\npause
346 If you do not like the standard location for the lirc-config file
347 (<filename>~/.lircrc</filename>) use the <option>-lircconf
348 <replaceable>filename</replaceable></option> switch to specify another
355 <sect2 id="slave-mode">
356 <title>Slave mode</title>
359 The slave mode allows you to build simple frontends to
360 <application>MPlayer</application>. When run with the
361 <option>-slave</option> option <application>MPlayer</application> will
362 read commands separated by a newline (\n) from stdin.
363 The commands are documented in the
364 <ulink url="../../tech/slave.txt">slave.txt</ulink> file.
370 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
373 <sect1 id="streaming">
374 <title>Streaming from network or pipes</title>
377 <application>MPlayer</application> can play files from the network, using the
378 HTTP, FTP, MMS or RTSP/RTP protocol.
382 Playing works simply by passing the URL on the command line.
383 <application>MPlayer</application> honors the <envar>http_proxy</envar>
384 environment variable, using a proxy if available. Proxies can also be forced:
386 mplayer <replaceable>http_proxy://proxy.micorsops.com:3128/http://micorsops.com:80/stream.asf</replaceable>
391 <application>MPlayer</application> can read from stdin
392 (<emphasis>not</emphasis> named pipes). This can for example be used to
395 wget <replaceable>ftp://micorsops.com/something.avi</replaceable> -O - | mplayer -
400 It is also recommended to enable <option>-cache</option> when playing
403 wget <replaceable>ftp://micorsops.com/something.avi</replaceable> -O - | mplayer -cache 8192 -
409 <sect2 id="streaming-save">
410 <title>Saving streamed content</title>
413 Once you succeed in making <application>MPlayer</application> play
414 your favorite internet stream, you can use the option
415 <option>-dumpstream</option> to save the stream into a file.
418 mplayer <replaceable>http://217.71.208.37:8006</replaceable> -dumpstream -dumpfile <replaceable>stream.asf</replaceable>
420 will save the content streamed from
421 <replaceable>http://217.71.208.37:8006</replaceable> into
422 <replaceable>stream.asf</replaceable>.
423 This works with all protocols supported by
424 <application>MPlayer</application>, like MMS, RTSP, and so forth.
430 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
434 <title>DVD playback</title>
437 For the complete list of available options, please read the man page.
438 The syntax to play a standard DVD is as follows:
440 mplayer dvd://<replaceable><track></replaceable> [-dvd-device <replaceable><device></replaceable>]
446 <screen>mplayer dvd://1 -dvd-device /dev/hdc</screen>
450 If you have compiled <application>MPlayer</application> with dvdnav support, the
451 syntax is the same, except that you need to use dvdnav:// instead of dvd://.
455 The default DVD device is <filename>/dev/dvd</filename>. If your setup
456 differs, make a symlink or specify the correct device on the command
457 line with the <option>-dvd-device</option> option.
461 <application>MPlayer</application> uses <systemitem>libdvdread</systemitem> and
462 <systemitem>libdvdcss</systemitem> for DVD playback and decryption. These two
463 libraries are contained in the
464 <application>MPlayer</application> source tree, you do not have
465 to install them separately. You can also use system-wide versions of the two
466 libraries, but this solution is not recommended, as it can result in bugs,
467 library incompatibilities and slower speed.
471 In case of DVD decoding problems, try disabling supermount, or any other such
472 facilities. Some RPC-2 drives may also require setting the region code.
476 <title>DVD decryption</title>
478 DVD decryption is done by <systemitem>libdvdcss</systemitem>. The method
479 can be specified through the <envar>DVDCSS_METHOD</envar> environment
480 variable, see the manual page for details.
486 <sect2 id="region_code">
487 <title>region code</title>
489 DVD drives nowadays come with a nonsensical restriction labeled
490 <ulink url="http://en.wikipedia.org/wiki/DVD_region_code">region code</ulink>.
491 This is a scheme to force DVD drives to only accept DVDs produced for one of
492 the six different regions into which the world was partitioned. How a group
493 of people can sit around a table, come up with such an idea and expect the
494 world of the 21st century to bow to their will is beyond anyone's guess.
498 Drives that enforce region settings through software only are also known as
499 RPC-1 drives, those that do it in hardware as RPC-2. RPC-2 drives allow
500 changing the region code five times before it remains fixed.
501 Under Linux you can use the
502 <ulink url="http://linvdr.org/projects/regionset/">regionset</ulink> tool
503 to set the region code of your DVD drive.
507 Thankfully, it is possible to convert RPC-2 drives into RPC-1 drives through
508 a firmware upgrade. Feed the model number of your DVD drive into your favorite
509 search engine or have a look at the forum and download sections of
510 <ulink url="http://www.rpc1.org/">"The firmware page"</ulink>.
511 While the usual caveats for firmware upgrades apply, experience with
512 getting rid of region code enforcement is generally positive.
518 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
522 <title>VCD playback</title>
525 For the complete list of available options, please read the man page. The
526 Syntax for a standard Video CD (VCD) is as follows:
527 <screen>mplayer vcd://<replaceable><track></replaceable> [-cdrom-device <replaceable><device></replaceable>]</screen>
529 <screen>mplayer vcd://2 -cdrom-device /dev/hdc</screen>
530 The default VCD device is <filename>/dev/cdrom</filename>. If your setup
531 differs, make a symlink or specify the correct device on the command line
532 with the <option>-cdrom-device</option> option.
536 At least Plextor and some Toshiba SCSI CD-ROM drives have horrible performance
537 reading VCDs. This is because the CDROMREADRAW <systemitem>ioctl</systemitem>
538 is not fully implemented for these drives. If you have some knowledge of SCSI
539 programming, please <ulink url="../../tech/patches.txt">help us</ulink>
540 implement generic SCSI support for VCDs.
544 In the meantime you can extract data from VCDs with
545 <ulink url="http://ftp.ntut.edu.tw/ftp/OS/Linux/packages/X/viewers/readvcd/">readvcd</ulink>
546 and play the resulting file with <application>MPlayer</application>.
550 <title>VCD structure</title>
552 A Video CD (VCD) is made up of CD-ROM XA sectors, i.e. CD-ROM mode 2
556 The first track is in mode 2 form 2 format which means it uses L2
557 error correction. The track contains an ISO-9660 file system with 2048
558 bytes/sector. This file system contains VCD metadata information, as
559 well as still frames often used in menus. MPEG segments for menus can
560 also be stored in this first track, but the MPEGs have to be broken up
561 into a series of 150-sector chunks. The ISO-9660 file system may
562 contain other files or programs that are not essential for VCD
567 The second and remaining tracks are generally raw 2324 bytes/sector
568 MPEG (movie) tracks, containing one MPEG PS data packet per
569 sector. These are in mode 2 form 1 format, so they store more data per
570 sector at the loss of some error correction. It is also legal to have
571 CD-DA tracks in a VCD after the first track as well.
572 On some operating systems there is some trickery that goes on to make
573 these non-ISO-9660 tracks appear in a file system. On other operating
574 systems like GNU/Linux this is not the case (yet). Here the MPEG data
575 <emphasis role="bold">cannot be mounted</emphasis>. As most movies are
576 inside this kind of track, you should try <option>vcd://2</option>
581 There exist VCD disks without the first track (single track and no file system
582 at all). They are still playable, but cannot be mounted.
586 The definition of the Video CD standard is called the
587 Philips "White Book" and it is not generally available online as it
588 must be purchased from Philips. More detailed information about Video
589 CDs can be found in the
590 <ulink url="http://www.vcdimager.org/pub/vcdimager/manuals/0.7/vcdimager.html#SEC4">vcdimager documentation</ulink>.
597 <title>About .DAT files</title>
599 The ~600 MB file visible on the first track of the mounted VCD is not a real
600 file! It is a so called ISO gateway, created to allow Windows to handle such
601 tracks (Windows does not allow raw device access to applications at all).
602 Under Linux you cannot copy or play such files (they contain garbage). Under
603 Windows it is possible as its iso9660 driver emulates the raw reading of
604 tracks in this file. To play a .DAT file you need the kernel driver which can
605 be found in the Linux version of PowerDVD. It has a modified iso9660 file system
606 (<filename>vcdfs/isofs-2.4.X.o</filename>) driver, which is able to emulate the
607 raw tracks through this shadow .DAT file. If you mount the disc using their
608 driver, you can copy and even play .DAT files with
609 <application>MPlayer</application>. But it will not
610 work with the standard iso9660 driver of the Linux kernel! Use
611 <option>vcd://</option> instead. Alternatives for VCD copying are the
612 new <ulink url="http://www.elis.rug.ac.be/~ronsse/cdfs/">cdfs</ulink> kernel
613 driver (not part of the official kernel) that shows CD sessions as image files
614 and <ulink url="http://cdrdao.sf.net/">cdrdao</ulink>, a bit-by-bit
615 CD grabbing/copying application.
621 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
624 <sect1 id="edl" xreflabel="Edit Decision Lists (EDL)">
625 <title>Edit Decision Lists (EDL)</title>
628 The edit decision list (EDL) system allows you to automatically skip
629 or mute sections of videos during playback, based on a movie specific
630 EDL configuration file.
634 This is useful for those who may want to watch a film in "family-friendly"
635 mode. You can cut out any violence, profanity, Jar-Jar Binks .. from a movie
636 according to your own personal preferences. Aside from this, there are other
637 uses, like automatically skipping over commercials in video files you watch.
641 The EDL file format is pretty bare-bones. There is one command per line that
642 indicates what to do (skip/mute) and when to do it (using pts in seconds).
647 <sect2 id="edl_using">
648 <title>Using an EDL file</title>
651 Include the <option>-edl <filename></option> flag when you run
652 <application>MPlayer</application>, with the name of the EDL file you
653 want applied to the video.
659 <sect2 id="edl_making">
660 <title>Making an EDL file</title>
663 The current EDL file format is:
664 <programlisting>[begin second] [end second] [action]</programlisting>
665 Where the seconds are floating-point numbers and the action is either
666 <literal>0</literal> for skip or <literal>1</literal> for mute. Example:
672 This will skip from second 5.3 to second 7.1 of the video, then mute at
673 15 seconds, unmute at 16.7 seconds and skip from second 420 to second 422
674 of the video. These actions will be performed when the playback timer
675 reaches the times given in the file.
679 To create an EDL file to work from, use the <option>-edlout
680 <filename></option> flag. During playback, just hit <keycap>i</keycap> to
681 mark the beginning and end of a skip block.
682 A corresponding entry will be written to the file for that time.
683 You can then go back and fine-tune the generated EDL file as well as
684 change the default operation which is to skip the block described by each line.
690 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
693 <sect1 id="advaudio-surround">
694 <title>Surround/Multichannel playback</title>
696 <sect2 id="advaudio-surround-DVD">
700 Most DVDs and many other files include surround sound.
701 <application>MPlayer</application> supports surround playback but does not
702 enable it by default because stereo equipment is by far more common. To play a
703 file that has more than two channels of audio use <option>-channels</option>.
704 For example, to play a DVD with 5.1 audio:
705 <screen>mplayer dvd://1 -channels 6</screen>
706 Note that despite the name "5.1" there are actually six discrete channels.
707 If you have surround sound equipment it is safe to put the
708 <option>channels</option> option in your <application>MPlayer</application>
709 configuration file <filename>~/.mplayer/config</filename>. For example, to make
710 quadraphonic playback the default, add this line:
711 <programlisting>channels=4</programlisting>
712 <application>MPlayer</application> will then output audio in four channels when
713 all four channels are available.
718 <sect2 id="advaudio-surround-stereoinfour">
719 <title>Playing stereo files to four speakers</title>
722 <application>MPlayer</application> does not duplicate any channels by default,
723 and neither do most audio drivers. If you want to do that manually:
724 <screen>mplayer <replaceable>filename</replaceable> -af channels=2:2:0:1:0:0</screen>
726 <link linkend="advaudio-channels-copying">channel copying</link> for an
732 <sect2 id="advaudio-surround-passthrough">
733 <title>AC-3/DTS Passthrough</title>
736 DVDs usually have surround audio encoded in AC-3 (Dolby Digital) or DTS
737 (Digital Theater System) format. Some modern audio equipment is capable of
738 decoding these formats internally. <application>MPlayer</application> can be
739 configured to relay the audio data without decoding it. This will only work if
740 you have a S/PDIF (Sony/Philips Digital Interface) jack in your sound card, or
741 if you are passing audio over HDMI.
745 If your audio equipment can decode both AC-3 and DTS, you can safely enable
746 passthrough for both formats. Otherwise, enable passthrough for only the format
747 your equipment supports.
751 <title>To enable passthrough on the command line:</title>
753 For AC-3 only, use <option>-ac hwac3</option>
756 For DTS only, use <option>-ac hwdts</option>
759 For both AC-3 and DTS, use <option>-afm hwac3</option>
764 <title>To enable passthrough in the <application>MPlayer</application>
765 configuration file: </title>
767 For AC-3 only, use <option>ac=hwac3,</option>
770 For DTS only, use <option>ac=hwdts,</option>
773 For both AC-3 and DTS, use <option>afm=hwac3</option>
778 Note that there is a comma (",") at the end of
779 <option>ac=hwac3,</option> and <option>ac=hwdts,</option>. This will make
780 <application>MPlayer</application> fall back on the codecs it normally uses when
781 playing a file that does not have AC-3 or DTS audio.
782 <option>afm=hwac3</option> does not need a comma;
783 <application>MPlayer</application> will fall back anyway when an audio family
789 <sect2 id="hwmpa-surround-passthrough">
790 <title>MPEG audio Passthrough</title>
793 Digital TV transmissions (such as DVB and ATSC) and some DVDs usually have
794 MPEG audio streams (in particular MP2).
795 Some MPEG hardware decoders such as full-featured DVB cards and DXR2
796 adapters can natively decode this format.
797 <application>MPlayer</application> can be configured to relay the audio data
803 <screen> mplayer -ac hwmpa </screen>
808 <sect2 id="advaudio-surround-matrix">
809 <title>Matrix-encoded audio</title>
812 <emphasis>***TODO***</emphasis>
816 This section has yet to be written and cannot be completed until somebody
817 provides sample files for us to test. If you have any matrix-encoded audio
818 files, know where to find some, or have any information that could be helpful,
819 please send a message to the
820 <ulink url="http://lists.mplayerhq.hu/mailman/listinfo/mplayer-docs">MPlayer-DOCS</ulink>
821 mailing list. Put "[matrix-encoded audio]" in the subject line.
825 If no files or further information are forthcoming this section will be dropped.
832 <ulink url="http://electronics.howstuffworks.com/surround-sound5.htm">http://electronics.howstuffworks.com/surround-sound5.htm</ulink>
835 <ulink url="http://www.extremetech.com/article2/0,1697,1016875,00.asp">http://www.extremetech.com/article2/0,1697,1016875,00.asp</ulink>
842 <sect2 id="advaudio-surround-hrtf">
843 <title>Surround emulation in headphones</title>
846 <application>MPlayer</application> includes an HRTF (Head Related Transfer
847 Function) filter based on an
848 <ulink url="http://sound.media.mit.edu/KEMAR.html">MIT project</ulink>
849 wherein measurements were taken from microphones mounted on a dummy human head.
853 Although it is not possible to exactly imitate a surround system,
854 <application>MPlayer</application>'s HRTF filter does provide more spatially
855 immersive audio in 2-channel headphones. Regular downmixing simply combines all
856 the channels into two; besides combining the channels, <option>hrtf</option>
857 generates subtle echoes, increases the stereo separation slightly, and alters
858 the volume of some frequencies. Whether HRTF sounds better may be dependent on
859 the source audio and a matter of personal taste, but it is definitely worth
864 To play a DVD with HRTF:
865 <screen>mplayer dvd://1 -channels 6 -af hrtf</screen>
869 <option>hrtf</option> only works well with 5 or 6 channels. Also,
870 <option>hrtf</option> requires 48 kHz audio. DVD audio is already 48 kHz, but if
871 you have a file with a different sampling rate that you want to play using
872 <option>hrtf</option> you must resample it:
874 mplayer <replaceable>filename</replaceable> -channels 6 -af resample=48000,hrtf
880 <sect2 id="advaudio-surround-troubleshooting">
881 <title>Troubleshooting</title>
884 If you do not hear any sound out of your surround channels, check your mixer
885 settings with a mixer program such as <application>alsamixer</application>;
886 audio outputs are often muted and set to zero volume by default.
893 <sect1 id="advaudio-channels">
894 <title>Channel manipulation</title>
896 <sect2 id="advaudio-channels-general">
897 <title>General information</title>
900 Unfortunately, there is no standard for how channels are ordered. The orders
901 listed below are those of AC-3 and are fairly typical; try them and see if your
902 source matches. Channels are numbered starting with 0.
904 <orderedlist spacing="compact">
906 <listitem override="0"><para>center</para></listitem>
909 <orderedlist spacing="compact">
910 <title>stereo</title>
911 <listitem override="0"><para>left</para></listitem>
912 <listitem><para>right</para></listitem>
915 <orderedlist spacing="compact">
916 <title>quadraphonic</title>
917 <listitem override="0"><para>left front</para></listitem>
918 <listitem><para>right front</para></listitem>
919 <listitem><para>left rear</para></listitem>
920 <listitem><para>right rear</para></listitem>
923 <orderedlist spacing="compact">
924 <title>surround 4.0</title>
925 <listitem override="0"><para>left front</para></listitem>
926 <listitem><para>right front</para></listitem>
927 <listitem><para>center rear</para></listitem>
928 <listitem><para>center front</para></listitem>
931 <orderedlist spacing="compact">
932 <title>surround 5.0</title>
933 <listitem override="0"><para>left front</para></listitem>
934 <listitem><para>right front</para></listitem>
935 <listitem><para>left rear</para></listitem>
936 <listitem><para>right rear</para></listitem>
937 <listitem><para>center front</para></listitem>
940 <orderedlist spacing="compact">
941 <title>surround 5.1</title>
942 <listitem override="0"><para>left front</para></listitem>
943 <listitem><para>right front</para></listitem>
944 <listitem><para>left rear</para></listitem>
945 <listitem><para>right rear</para></listitem>
946 <listitem><para>center front</para></listitem>
947 <listitem><para>subwoofer</para></listitem>
952 The <option>-channels</option> option is used to request the number of
953 channels from the audio decoder. Some audio codecs use the number of specified
954 channels to decide if downmixing the source is necessary. Note that this does
955 not always affect the number of output channels. For example, using
956 <option>-channels 4</option> to play a stereo MP3 file will still result in
957 2-channel output since the MP3 codec will not produce the extra channels.
961 The <option>channels</option> audio filter can be used to create or remove
962 channels and is useful for controlling the number of channels sent to the sound
963 card. See the following sections for more information on channel manipulation.
968 <sect2 id="advaudio-channels-mono">
969 <title>Playing mono with two speakers</title>
972 Mono sounds a lot better when played through two speakers - especially when
973 using headphones. Audio files that truly have one channel are automatically
974 played through two speakers; unfortunately, most files with mono sound are
975 actually encoded as stereo with one channel silent. The easiest and most
976 foolproof way to make both speakers output the same audio is the
977 <option>extrastereo</option> filter:
978 <screen>mplayer <replaceable>filename</replaceable> -af extrastereo=0</screen>
982 This averages both channels, resulting in both channels being half as loud as
983 the original. The next sections have examples of other ways to do this without a
984 volume decrease, but they are more complex and require different options
985 depending on which channel to keep. If you really need to maintain the volume,
986 it may be easier to experiment with the <option>volume</option> filter and find
987 the right value. For example:
989 mplayer <replaceable>filename</replaceable> -af extrastereo=0,volume=5
995 <sect2 id="advaudio-channels-copying">
996 <title>Channel copying/moving</title>
999 The <option>channels</option> filter can move any or all channels.
1000 Setting up all the suboptions for the <option>channels</option>
1001 filter can be complicated and takes a little care.
1003 <orderedlist spacing="compact">
1005 Decide how many output channels you need. This is the first suboption.
1008 Count how many channel moves you will do. This is the second suboption. Each
1009 channel can be moved to several different channels at the same time, but keep
1010 in mind that when a channel is moved (even if to only one destination) the
1011 source channel will be empty unless another channel is moved into it. To copy
1012 a channel, keeping the source the same, simply move the channel into both the
1013 destination and the source. For example:
1015 channel 2 --> channel 3
1016 channel 2 --> channel 2<!--
1017 --></programlisting>
1020 Write out the channel copies as pairs of suboptions. Note that the first
1021 channel is 0, the second is 1, etc. The order of these suboptions does not
1022 matter as long as they are properly grouped into
1023 <replaceable>source:destination</replaceable> pairs.
1028 <bridgehead>Example: one channel in two speakers</bridgehead>
1030 Here is an example of another way to play one channel in both speakers. Suppose
1031 for this example that the left channel should be played and the right channel
1032 discarded. Following the steps above:
1035 In order to provide an output channel for each of the two speakers, the first
1036 suboption must be "2".
1039 The left channel needs to be moved to the right channel, and also must be
1040 moved to itself so it won't be empty. This is a total of two moves, making
1041 the second suboption "2" as well.
1044 To move the left channel (channel 0) into the right channel (channel 1), the
1045 suboption pair is "0:1", "0:0" moves the left channel onto itself.
1048 Putting that all together gives:
1050 mplayer <replaceable>filename</replaceable> -af channels=2:2:0:1:0:0
1055 The advantage this example has over <option>extrastereo</option> is that the
1056 volume of each output channel is the same as the input channel. The disadvantage
1057 is that the suboptions must be changed to "2:2:1:0:1:1" when the desired audio
1058 is in the right channel. Also, it is more difficult to remember and type.
1061 <bridgehead>Example: left channel in two speakers shortcut</bridgehead>
1063 There is actually a much easier way to use the <option>channels</option> filter
1064 for playing the left channel in both speakers:
1065 <screen>mplayer <replaceable>filename</replaceable> -af channels=1</screen>
1066 The second channel is discarded and, with no further suboptions, the single
1067 remaining channel is left alone. Sound card drivers automatically play
1068 single-channel audio in both speakers. This only works when the desired channel
1072 <bridgehead>Example: duplicate front channels to the rear</bridgehead>
1074 Another common operation is to duplicate the front channels and play them back
1075 on the rear speakers of a quadraphonic setup.
1078 There should be four output channels. The first suboption is "4".
1081 Each of the two front channels needs to be moved to the corresponding rear
1082 channel and also to itself. This is four moves, so the second suboption is "4".
1085 The left front (channel 0) needs to moved to the left rear (channel 2):
1086 "0:2". The left front also needs to be moved to itself: "0:0". The right
1087 front (channel 1) is moved to the right rear (channel 3): "1:3", and also to
1091 Combine all the suboptions to get:
1093 mplayer <replaceable>filename</replaceable> -af channels=4:4:0:2:0:0:1:3:1:1
1099 <sect2 id="advaudio-channels-mixing">
1100 <title>Channel mixing</title>
1103 The <option>pan</option> filter can mix channels in user-specified proportions.
1104 This allows for everything the <option>channels</option> filter can do and
1105 more. Unfortunately, the suboptions are much more complicated.
1108 Decide how many channels to work with. You may need to specify this with
1109 <option>-channels</option> and/or <option>-af channels</option>.
1110 Later examples will show when to use which.
1113 Decide how many channels to feed into <option>pan</option> (further decoded
1114 channels are discarded). This is the first suboption, and it also controls how
1115 many channels to employ for output.
1119 The remaining suboptions specify how much of each channel gets mixed into each
1120 other channel. This is the complicated part. To break the task down, split the
1121 suboptions into several sets, one set for each input channel. Each suboption
1122 within a set corresponds to an output channel. The number you specify will be
1123 the percentage of the input channel that gets mixed into the output channel.
1126 <option>pan</option> accepts values from 0 to 512, yielding 0% to 51200% of
1127 the original volume. Be careful when using values greater than 1. Not only
1128 can this give you very high volume, but if you exceed the sample range of
1129 your sound card you may hear painful pops and clicks. If you want you can
1130 follow <option>pan</option> with <option>,volume</option> to enable clipping,
1131 but it is best to keep the values of <option>pan</option> low enough that
1132 clipping is not necessary.
1138 <bridgehead>Example: one channel in two speakers</bridgehead>
1140 Here is yet another example for playing the left channel in two speakers. Follow
1144 <option>pan</option> should output two channels, so the first
1148 Since we have two input channels, there will be two sets of suboptions.
1149 Since there are also two output channels,
1150 there will be two suboptions per set.
1151 The left channel from the file should go with full volume to
1152 the new left and the right channels.
1153 Thus the first set of suboptions is "1:1".
1154 The right channel should be discarded, so the second would be "0:0".
1155 Any 0 values at the end can be left out, but for ease of
1156 understanding we will keep them.
1159 Putting those options together gives:
1160 <screen>mplayer <replaceable>filename</replaceable> -af pan=2:1:1:0:0</screen>
1161 If the right channel is desired instead of the left, the suboptions to
1162 <option>pan</option> will be "2:0:0:1:1".
1166 <bridgehead>Example: left channel in two speakers shortcut</bridgehead>
1168 As with <option>channels</option>, there is a shortcut that only works with the
1170 <screen>mplayer <replaceable>filename</replaceable> -af pan=1:1</screen>
1171 Since <option>pan</option> has only one channel of input (the other channel is
1172 discarded), there is only one set with one suboption, which specifies that the
1173 only channel gets 100% of itself.
1176 <bridgehead>Example: downmixing 6-channel PCM</bridgehead>
1178 <application>MPlayer</application>'s decoder for 6-channel PCM is not capable of
1179 downmixing. Here is a way to downmix PCM using <option>pan</option>:
1182 The number of output channels is 2, so the first suboption is "2".
1185 With six input channels there will be six sets of options. Fortunately,
1186 since we only care about the output of the first two channels, we only need to
1187 make two sets; the remaining four sets can be omitted. Beware that not all
1188 multichannel audio files have the same channel order! This example
1189 demonstrates downmixing a file with the same channels as AC-3 5.1:
1197 --></programlisting>
1198 The first set of suboptions lists the percentages of the original volume, in
1199 order, which each output channel should receive from the
1200 front left channel: "1:0".
1201 The front right channel should go into the right output: "0:1".
1202 The same for the rear channels: "1:0" and "0:1".
1203 The center channel goes into both output channels with half volume:
1204 "0.5:0.5", and the subwoofer goes into both with full volume: "1:1".
1207 Put all that together, for:
1209 mplayer <replaceable>6-channel.wav</replaceable> -af pan=2:1:0:0:1:1:0:0:1:0.5:0.5:1:1
1211 The percentages listed above are only a rough example. Feel free to tweak them.
1214 <bridgehead>Example: Playing 5.1 audio on big speakers without a subwoofer</bridgehead>
1216 If you have a huge pair of front speakers you may not want to waste any money on
1217 buying a subwoofer for a complete 5.1 sound system. If you use
1218 <option>-channels 5</option> to request that liba52 decode 5.1 audio in 5.0,
1219 the subwoofer channel is simply discarded. If you want to distribute the
1220 subwoofer channel yourself you need to downmix manually with
1221 <option>pan</option>:
1224 Since <option>pan</option> needs to examine all six channels, specify
1225 <option>-channels 6</option> so liba52 decodes them all.
1228 <option>pan</option> outputs to only five channels, the first suboption is 5.
1231 Six input channels and five output channels means six sets of five suboptions.
1232 <itemizedlist spacing="compact">
1234 The left front channel only replicates onto itself:
1238 Same for the right front channel:
1242 Same for the left rear channel:
1246 And also the same for the right rear channel:
1254 And now we have to decide what to do with the subwoofer,
1255 e.g. half into front right and front left:
1261 Combine all those options to get:
1263 mplayer <replaceable>dvd://1</replaceable> -channels 6 -af pan=5:1:0:0:0:0:0:1:0:0:0:0:0:1:0:0:0:0:0:1:0:0:0:0:0:1:0.5:0.5:0:0:0
1271 <sect1 id="advaudio-volume">
1272 <title>Software Volume adjustment</title>
1275 Some audio tracks are too quiet to be heard comfortably without amplification.
1276 This becomes a problem when your audio equipment cannot amplify the signal for
1277 you. The <option>-softvol</option> option directs
1278 <application>MPlayer</application> to use an internal mixer. You can then use
1279 the volume adjustment keys (by default <keycap>9</keycap> and
1280 <keycap>0</keycap>) to reach much higher volume levels. Note that this does not
1281 bypass your sound card's mixer; <application>MPlayer</application> only
1282 amplifies the signal before sending it to your sound card.
1283 The following example is a good start:
1285 mplayer <replaceable>quiet-file</replaceable> -softvol -softvol-max 300
1287 The <option>-softvol-max</option> option specifies the maximum allowable output
1288 volume as a percentage of the
1289 original volume. For example, <option>-softvol-max 200</option> would allow the
1290 volume to be adjusted up to twice its original level.
1291 It is safe to specify a large value with
1292 <option>-softvol-max</option>; the higher volume will not be used until you
1293 use the volume adjustment keys. The only disadvantage of a large value is that,
1294 since <application>MPlayer</application> adjusts volume by a percentage of the
1295 maximum, you will not have as precise control when using the volume adjustment
1296 keys. Use a lower value with <option>-softvol-max</option> and/or specify
1297 <option>-volstep 1</option> if you need higher precision.
1301 The <option>-softvol</option> option works by controlling the
1302 <option>volume</option> audio filter. If you want to play a file at a certain
1303 volume from the beginning you can specify <option>volume</option> manually:
1304 <screen>mplayer <replaceable>quiet-file</replaceable> -af volume=10</screen>
1305 This will play the file with a ten decibel gain. Be careful when using the
1306 <option>volume</option> filter - you could easily hurt your ears if you use
1307 too high a value. Start low and work your way up gradually until you get a feel
1308 for how much adjustment is required. Also, if you specify excessively high
1309 values, <option>volume</option> may need to clip the signal to avoid sending
1310 your sound card data that is outside the allowable range; this will result in