Usage Command line MPlayer utilizes a complex playtree. It consists of global options written as first, for example mplayer -vfm 5 and options written after filenames, that apply only to the given filename/URL/whatever, for example: mplayer -vfm 5 movie1.avi movie2.avi -vfm 4 You can group filenames/URLs together using { and }. It is useful with option : mplayer { 1.avi -loop 2 2.avi } -loop 3 The above command will play files in this order: 1, 1, 2, 1, 1, 2, 1, 1, 2. Playing a file: mplayer [options] [path/]filename Another way to play a file: mplayer [options] file:///uri-escaped-path Playing more files: mplayer [default options] [path/]filename1 [options for filename1] filename2 [options for filename2] ... Playing VCD: mplayer [options] vcd://trackno [-cdrom-device /dev/cdrom] Playing DVD: mplayer [options] dvd://titleno [-dvd-device /dev/dvd] Playing from the WWW: mplayer [options] http://site.com/file.asf (playlists can be used, too) Playing from RTSP: mplayer [options] rtsp://server.example.com/streamName Examples: mplayer -vo x11 /mnt/Films/Contact/contact2.mpg mplayer vcd://2 -cdrom-device /dev/hdc mplayer -afm 3 /mnt/DVDtrailers/alien4.vob mplayer dvd://1 -dvd-device /dev/hdc mplayer -abs 65536 -delay -0.4 -nobps ~/movies/test.avi Control MPlayer has a fully configurable, command driven, control layer which lets you control MPlayer with keyboard, mouse, joystick or remote control (using LIRC). See the man page for the complete list of keyboard controls. Controls configuration MPlayer allows you bind any key/button to any MPlayer command using a simple config file. The syntax consist of a key name followed by a command. The default config file location is $HOME/.mplayer/input.conf but it can be overridden using the option (relative path are relative to $HOME/.mplayer). You can get a full list of supported key names by running mplayer -input keylist and a full list of available commands by running mplayer -input cmdlist. A simple input control file ## ## MPlayer input control file ## RIGHT seek +10 LEFT seek -10 - audio_delay 0.100 + audio_delay -0.100 q quit > pt_step 1 < pt_step -1 ENTER pt_step 1 1 Control from LIRC Linux Infrared Remote Control - use an easy to build home-brewn IR-receiver, an (almost) arbitrary remote control and control your Linux box with it! More about it on the LIRC homepage. If you have the LIRC package installed, configure will autodetect it. If everything went fine, MPlayer will print "Setting up LIRC support..." on startup. If an error occurs it will tell you. If there is no message about LIRC there is no support compiled in. That's it :-) The application name for MPlayer is - surprise - mplayer. You can use any MPlayer commands and even pass more than one command by separating them with \n. Do not forget to enable the repeat flag in .lircrc when it makes sense (seek, volume, etc). Here is an excerpt from a sample .lircrc: begin button = VOLUME_PLUS prog = mplayer config = volume 1 repeat = 1 end begin button = VOLUME_MINUS prog = mplayer config = volume -1 repeat = 1 end begin button = CD_PLAY prog = mplayer config = pause end begin button = CD_STOP prog = mplayer config = seek 0 1\npause end If you do not like the standard location for the lirc-config file (~/.lircrc) use the switch to specify another file. Slave mode The slave mode allows you to build simple frontends to MPlayer. When run with the option MPlayer will read commands separated by a newline (\n) from stdin. The commands are documented in the slave.txt file. Streaming from network or pipes MPlayer can play files from the network, using the HTTP, FTP, MMS or RTSP/RTP protocol. Playing works simply by passing the URL on the command line. MPlayer honors the http_proxy environment variable, using a proxy if available. Proxies can also be forced: mplayer http_proxy://proxy.micorsops.com:3128/http://micorsops.com:80/stream.asf MPlayer can read from stdin (not named pipes). This can for example be used to play from FTP: wget ftp://micorsops.com/something.avi -O - | mplayer - It is also recommended to enable when playing from the network: wget ftp://micorsops.com/something.avi -O - | mplayer -cache 8192 - Saving streamed content Once you succeed in making MPlayer play your favorite internet stream, you can use the option to save the stream into a file. For example: mplayer http://217.71.208.37:8006 -dumpstream -dumpfile stream.asf will save the content streamed from http://217.71.208.37:8006 into stream.asf. This works with all protocols supported by MPlayer, like MMS, RSTP, and so forth. Remote streams Remote streams allow you to access most MPlayer stream type from a remote host. The main purpose of this feature is to make it possible to directly use the CD or DVD drive of another computer on the network (provided you have the required bandwidth). On the downside some stream type (currently TV and MF) are not usable remotely because they are implemented at the demuxer level. It is sad for MF but TV stream would anyway require an insane amount of bandwidth. Compiling the server After having compiled MPlayer go to the TOOLS/netstream directory and enter make to build the server binary. You can then copy the netstream binary to the right place on your system (usually /usr/local/bin on Linux). Using remote streams First you have to start the server on the computer you intend to remotely access. Currently the server is very basic and does not have any commands line arguments so just enter netstream. Now you can for example play the second track of a VCD on the server with : mplayer -cache 5000 mpst://servername/vcd://2 You can also access files on this server : mplayer -cache 5000 mpst://servername//usr/local/movies/lol.avi Note that paths which aren't starting with a / will be relative to the directory where the server is running. The option is not needed but highly recommended. Be aware that currently the server is not secure at all. So do not complain about the numerous exploits which are possible through this. Instead send some (good) patch to make it better or start writing your own server. Edit Decision Lists (EDL) The edit decision list (EDL) system allows you to automatically skip or mute sections of videos during playback, based on a movie specific EDL configuration file. This is useful for those who may want to watch a film in "family-friendly" mode. You can cut out any violence, profanity, Jar-Jar Binks .. from a movie according to your own personal preferences. Aside from this, there are other uses, like automatically skipping over commercials in video files you watch. The EDL file format is pretty bare-bones. There is one command per line that indicates what to do (skip/mute) and when to do it (using pts in seconds). Using an EDL file Include the flag when you run MPlayer, with the name of the EDL file you want applied to the video. Making an EDL file The current EDL file format is: [begin second] [end second] [action] Where the seconds are floating-point numbers and the action is either 0 for skip or 1 for mute. Example: 5.3 7.1 0 15 16.7 1 420 422 0 This will skip from second 5.3 to second 7.1 of the video, then mute at 15 seconds, unmute at 16.7 seconds and skip from second 420 to second 422 of the video. These actions will be performed when the playback timer reaches the times given in the file. To create an EDL file to work from, use the flag. During playback, just hit i to mark the beginning and end of a skip block. A corresponding entry will be written to the file for that time. You can then go back and fine-tune the generated EDL file as well as change the default operation which is to skip the block described by each line. 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 two channels of 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 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 neither 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. MPlayer can be configured to relay the audio data without decoding it. 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 safely enable passthrough for both formats. Otherwise, enable passthrough for only the format your equipment supports. 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 on the codecs it normally uses when playing a file that does not have AC3 or DTS audio. does not need a comma; MPlayer will fall back anyway when an audio family is specified. MPEG audio Passthrough Digital TV transmissions (such as DVB and ATSC) and some DVDs usually have MPEG audio streams (in particular MP2). Some MPEG hardware decoders such as full-featured DVB cards and DXR2 adapters can natively decode this format. MPlayer can be configured to relay the audio data without decoding it. To use this codec: mplayer -ac hwmpa Matrix-encoded audio ***TODO*** This section has yet to be written and cannot be completed until somebody provides sample files for us to test. If you have any matrix-encoded audio files, know where to find some, or have any information that could be helpful, please send a message to the MPlayer-DOCS mailing list. Put "[matrix-encoded audio]" in the subject line. If no files or further information are forthcoming this section will be dropped. 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. Although it is not possible to exactly imitate a surround system, MPlayer's HRTF filter does provide more spatially immersive 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 dependent 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 well 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 do not 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 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 with two speakers Mono sounds a lot better when played through two speakers - especially when using headphones. Audio files that truly have one channel are automatically played through 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 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, it may be easier 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 for the filter 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 is 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: In order to provide an output channel for each of the two speakers, the first suboption must be "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", "0:0" moves the left channel onto itself. 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 is 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 feed into (further decoded channels are discarded). This is the first suboption, and it also controls how many channels to employ for 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 is 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: should output two channels, so the first suboption is "2". Since we have two input channels, there will be two sets of suboptions. Since there are also two output channels, there will be two suboptions per set. The left channel from the file should go with full volume to the new left and the right channels. Thus the first set of suboptions is "1:1". The right channel should be discarded, so the second would be "0:0". Any 0 values at the end can be left out, but for ease of understanding we will keep them. Putting those options together gives: mplayer filename -af pan=2:1:1:0:0 If the right channel is desired instead of the left, the suboptions to will be "2:0:0:1: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 6-channel PCM MPlayer's decoder for 6-channel PCM is not capable of downmixing. Here is a way to downmix PCM using : The number of output channels is 2, so the first suboption is "2". With six input channels there will be six sets of options. 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 of the original volume, in order, which each output channel should receive from the front left channel: "1:0". The front right channel should go into the right output: "0:1". The same for the rear channels: "1:0" and "0:1". The center channel goes into both output channels with half volume: "0.5:0.5", and the subwoofer goes into both with full volume: "1:1". Put all that together, for: mplayer 6-channel.wav -af pan=2:1:0:0:1:1:0:0:1:0.5:0.5:1:1 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. outputs to only five channels, the first suboption is 5. Six input channels and five output channels means six sets of five suboptions. The left front channel only replicates onto itself: "1:0:0:0:0" Same for the right front channel: "0:1:0:0:0" Same for the left rear channel: "0:0:1:0:0" And also the same for the right rear channel: "0:0:0:1:0" Center front, too: "0:0:0:0:1" And now we have to decide what to do with the subwoofer, e.g. half into front right and front left: "0.5:0.5:0:0:0" Combine all those options to get: mplayer dvd://1 -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 Software Volume adjustment Some audio tracks are too quiet to be heard comfortably without amplification. This becomes a problem when your audio equipment cannot amplify the signal for you. The option directs MPlayer to use an internal mixer. You can then use the volume adjustment keys (by default 9 and 0) to reach much higher volume levels. Note that this does not bypass your sound card's mixer; MPlayer only amplifies the signal before sending it to your sound card. The following example is a good start: mplayer quiet-file -softvol -softvol-max 300 The option specifies the maximum allowable output volume as a percentage of the original volume. For example, would allow the volume to be adjusted up to twice its original level. It is safe to specify a large value with ; the higher volume will not be used until you use the volume adjustment keys. The only disadvantage of a large value is that, since MPlayer adjusts volume by a percentage of the maximum, you will not have as precise control when using the volume adjustment keys. Use a lower value with and/or specify if you need higher precision. The option works by controlling the audio filter. If you want to play a file at a certain volume from the beginning you can specify manually: mplayer quiet-file -af volume=10 This will play the file with a ten decibel gain. Be careful when using the filter - you could easily hurt your ears if you use too high a value. Start low and work your way up gradually until you get a feel for how much adjustment is required. Also, if you specify excessively high values, may need to clip the signal to avoid sending your sound card data that is outside the allowable range; this will result in distorted audio.