This is an old revision of the document!
Mplayer
Mplayer with no dependencies (4.3MB) is a powerful, flexible and relatively compact media player capable of handling both video and music files.
The information on mplayer is taken from the following web site:
http://www.linuxtutorialblog.com/post/tutorial-playing-around-with-mplayer
Tutorial: Playing around with MPlayer
rechosen | 07 February, 2007 19:15 |
This tutorial handles about the usage of the wonderful media player MPlayer. It explains several options, lists some useful keyboard shortcuts and handles about tips and tricks that can be used to enhance your multimedia experience.
Difficulty: Basic
Note: this tutorial assumes that you have MPlayer installed & working and that you have some basic shell knowledge.
Playing a file
The most simple way of invoking MPlayer to play a media file is this:
[[rechosen@localhost ~]]$ mplayer <somefile>
MPlayer will try to auto-detect what kind of file you're trying to play (it usually succeeds) and play it. If it's an audio file, it'll just start playing and show its status and possible warnings on the command-line. If it's a video file, it'll open a window to play it in and then start playing.
Seeking through a file
You can seek through a file with a set of 3 keyboard shortcut pairs. Each pair makes MPlayer seek a different amount of time, and the pair consists of a key for seeking backward and a one for seeking forward. Listed below are those key pairs, for seeking backward and forward respectively: Left arrow and Right arrow (10 seconds) Down arrow and Up arrow (1 minute) Page down and Page up (10 minutes)
Knowing these will come in handy a lot of times.
Playing a DVD
MPlayer does not have DVD menu support (sadly), but it does support playing DVD's. You can play a DVD this way:
mplayer dvd://<titlenumber>
Replace <titlenumber> with a number, like 1, 2 or 3. I personally prefer xine for DVD playback, as xine does support DVD menus.
Playing with subtitles
You can play a movie with subtitles in multiple ways. When playing a movie file, you can specify a subtitle file this way:
[[rechosen@localhost ~]]$ mplayer -sub <somesubtitlefile> <somefile>
When playing a DVD movie, you can also use the DVD's subtitle by specifying a language code like this:
[[rechosen@localhost ~]]$ mplayer dvd://<titlenumber> -slang nl,en
The above command would try to use dutch subtitles first, and fall back on english ones if dutch subtitles weren't available.
Useful keyboard shortcuts
A list of useful keyboard shortcuts (sometimes called hotkeys) in MPlayer:
(note that the full list can be found in MPlayer's man page) “f” ⇒ Toggle between full-screen and windowed mode during video playback (you can set the option -fs on the command line to make MPlayer start playing in full-screen mode immediately) “o” ⇒ Switch OSD (OnScreen Display) mode during video playback (for viewing how much time the movie has been playing and what its total lenght is) “p” or Space ⇒ Pause / resume playback “q” or Esc ⇒ Quit MPlayer (Esc does not quit but only stops playback when in GUI mode) “/” and “*” (or “9” and “0”) ⇒ Decrease / increase playback volume respectively “m” ⇒ Mute sound (toggle) “T” (usually Shift + “t”) ⇒ Toggle stay-on-top (very useful if you don't want your video window to be overlapped by an other application) “b” and “j” ⇒ Cycle through available subtitles “x” and “z” ⇒ Adjust subtitle delay (useful if you have a subtitle that isn't 100% synced; you can then correct the time difference on the fly) “I” (usually Shift + “i”) ⇒ Show the filename of the movie being played (useful if you want to know that without interrupting the movie) “1” and “2” ⇒ Adjust contrast* “3” and “4” ⇒ Adjust brightness* “5” and “6” ⇒ Adjust hue* “7” and “8” ⇒ Adjust saturation*
- : These do not always work; see the MPlayer man page.
Generating an index
Sometimes, video files (mainly AVI files) have a corrupted index, or no index at all. This frequently is the case with incorrectly or incompletely downloaded files. Fortunately, MPlayer can generate the index it needs to play the file correctly. By using the -idx option, you can tell MPlayer to generate an index when necessary:
[[rechosen@localhost ~]]$ mplayer -idx <somefile>
Sometimes the file does contain an index, but a corrupted one. In those cases, you might need to force MPlayer to generate an index:
[[rechosen@localhost ~]]$ mplayer -forceidx <somefile>
Generating an index can take some time, depending on the size of the video file, but after that, the file should play correctly.
Correcting bad audio/video sync Some videos (mainly flv files) are encoded in a horrible way, and MPlayer will have enormous trouble with the A/V (Audio/Video) sync. There are pretty much two possibilities in this case: MPlayer is trying to fix it but the sync is worsening too fast MPlayer is trying to fix something that's already right and therefore pushes the sync away unnecessarily
In the first case, you should allow MPlayer to try harder to fix the sync:
[[rechosen@localhost ~]]$ mplayer -autosync 30 -mc 2.0 <somefile>
In the second case, you shouldn't allow MPlayer to fix anything when it comes to the sync:
[[rechosen@localhost ~]]$ mplayer -autosync 0 -mc 0 <somefile>
You might wonder what those options mean. Well, setting autosync to a positive value allows MPlayer to gradually adapt its A/V correction algorithm. The higher the value, the faster MPlayer will try to correct it. The mc option specifies how many seconds MPlayer may correct every frame. Setting it to a high value (like 2.0) practically allows MPlayer to do whatever it thinks it should to correct the A/V sync. Setting it to 0 stops MPlayer from trying anything when it comes to syncing.
Using MPlayer on slow systems
As video playback is a CPU-intensive task, older and slower systems may have a hard time to play certain video files. MPlayer has a feature that will help them to keep up the playback with less CPU power: -framedrop. This will allow MPlayer not to render a frame here and there if the CPU can't handle it. On systems that are far too slow, it won't be a pleasure to “watch” the movie (the majority of the frames will just not be rendered at all), but on systems that are a bit faster, this will stop the playback from having hiccups here and there. You can use the -framedrop option like this:
[[rechosen@localhost ~]]$ mplayer -framedrop <somefile>
Playing Youtube or Other Flash Videos Using Mplayer-nodeps.tcz
Most of us use our computers occasionally to play youtube videos or other flash content, but if the internet connection is not fast enough those videos can pause and stutter annoyingly. Here is one way to get around that problem. Mplayer (without dependencies) allows this in the most efficient way possible.
1. Start the Youtube video in Opera and then push the pause button on the flashplayer so that the video loads in the background while you are doing something else. You can find the file wherever you have set up Opera to store its cache. Flash videos are often cached even if cache is configured to OFF. (I have mine in /tmp so that is in wholly in RAM memory and avoids writing to my SSD drive.) Use your file manager (mc or emelfm) to rename the file, giving it a *.flv suffix. Now you can use mplayer to play it with no stutters or pauses. Typical command: mplayer -zoom test.flv. Note that the -zoom allows you to resize the video by clicking-and-dragging a corner. The arrow keys allow you to “jump” forward and back in the video–plus or minus 25% for up or down arrow; plus or minus one minute for left and right arrows.