How to Use mplayer in Command Line Mode

Source: Internet
Author: User

Mplayer is a good media player that I use in Linux. It is well known for its support for playing a wide range of audio/video file formats. In addition to the general usage, this article includes some little-known tips and tips. I believe that after reading this article, your multimedia playback experience will increase significantly.

Playback File

The simplest way to use mplayer to play a media file is:
Mplayer <somefile>

Mplayer automatically detects the file type and plays it back. If it is an audio file, the status information of the video file is displayed on the command line. If it is a video file, A new playing window is opened.

Backward and fast forward

When playing a file, you can use the following three sets of shortcut keys to perform backward and fast forward operations on the playback process:

Left arrow keys and right arrow keys: Perform the 10 s backward and 10 s Forward Operations respectively.
Downstream and upstream keys: Perform 1-minute backward operation and 1-minute forward operation respectively.
Go down and go up: Perform the 10-minute backward operation and the 10-minute forward operation respectively.
Play a DVD

Although mplayer does not support the DVD menu, it can play a DVD. You can play a DVD like this:
Mplayer DVD: // <titlenumber>

You need to replace <titlenumber> with actual numbers, such as 1, 2, and 3.

Use subtitles

When playing a movie file, you can specify the subtitle file:
Mplayer-sub <somesubtitlefile> <somefile>

When playing a DVD movie, you can also use Subtitles by specifying the language code:
Mplayer DVD: // <titlenumber>-slang NL, en

In this way, mplayer will give priority to Dutch subtitles. if the language is unavailable, English subtitles will be used again.

Useful shortcut keys

The following are some useful shortcut keys for mplayer:

F-when playing a video, switch between full screen and window mode. You can also use the-Fs option in the command line to enable mplayer to start playing in full screen mode.
O-switch the OSD (onscreen display) mode when playing a video.
P or space-Pause/resume playing.
Q or ESC-exit mplayer. In GUI mode, ESC does not exit and only stops playing.
/And * or 9 and 0-decrease or increase the volume.
M-Mute switch.
T (usually SHIFT + T)-top switch of the playback window.
B and J-cycle between available subtitles.
X and Z-adjust the subtitle delay time.
I (SHIFT + I)-display the name of the file that plays the movie.
1 and 2-adjust the contrast.
3 and 4-adjust the brightness.
5 and 6-adjust the color.
7 and 8-adjust the saturation.
Index generation

Sometimes, some video files (mainly AVI Files) contain corrupted indexes or no indexes at all. This is usually caused by incorrect or incomplete file downloads. Fortunately, mplayer can generate indexes required for normal playback files. By using the-idx option, you can tell mplayer to generate an index:
Mplayer-idx <somefile>

Sometimes the file contains an index, but it is damaged. In that case, you may need mplayer to forcibly generate an index:
Mplayer-forceidx <somefile>

It takes some time to generate an index based on the video file size. But after that, the file should be played normally.

Corrected audio/video synchronization errors

Some video files (mainly FLV files) may cause Audio/Video Synchronization troubles for mplayer due to Encoding Problems. There are two possible cases:

Mplayer tries to fix the problem, but the synchronization problem is even worse.
Mplayer will try to fix the correct ones, so there is no need to synchronize them.
In the first case, you should make mplayer try to fix the synchronization problem:
Mplayer-autosync 30-MC 2.0 <somefile>

In the second case, you should not allow mplayer to fix the synchronization problem:
Mplayer-autosync 0-MC 0 <somefile>

Setting autosync in the preceding command to a positive value will make mplayer adjust Audio/Video Synchronization gradually. The higher the value, the faster mplayer can fix it. MC
Specifies the number of seconds that mplayer takes to correct each frame. The higher the value, the closer mplayer thinks it is to fix audio/video synchronization. If it is set to 0, mplayer cannot be repaired.

Use mplayer on a slow System

Mplayer allows low CPU power to play video files on old or slow systems. You can use the-frameddrop option:
Mplayer-frameddrop <somefile>

When playing MP3 or Ogg Vorbis files, you may feel a certain amount of buffer, which will affect your music experience. In this case, you can try to use the libmad (mp3) or tremor (Ogg Vorbis) audio decoder. You can detect them like this:

For MP3:
Mplayer-AC help | grep mad

If the result returned by the preceding command is as follows:
Mad libmad working libmad MPEG Layer 1-2-3 [libmad]

Then you can use libmad to play MP3:
Mplayer-AC mad <somefile>

In the case of Ogg, you can use the same technique to check whether the tremor audio decoder is available:
Mplayer-AC help | grep tremor

Playing Streaming Media

If mplayer cannot automatically find the playlist or direct streaming media file, you can try the-playlist option:
Mplayer-playlist <file or URL>

You can also set a large cache:
Mplayer-Cache 8192-playlist <file or URL>

The unit of cache size is KB. The preceding command allows mplayer to use 8 Mb cache. You can use the-Cache-min option to change the percentage of memory occupied by mplayer:
Mplayer-Cache 8192-Cache-min 50-playlist <file or URL>

Loop playback

If you want to play media files cyclically, you can use the-loop option:
Mplayer-loop 3 <somefile>

The preceding command plays <somefile> three times before exiting.
Mplayer-loop 0 <somefile>

The above command will always play back <somefile>.

Change playback speed

You can use the-speed option to change the speed at which mplayer plays media files. The value is 1.0, which means normal speed; 0.5 means two times slower; 2.0 means two times faster. Specify options as follows:
Mplayer-speed2.0 <somefile>

Change Sampling Rate

You can use the-srate option to change the mplayer output sampling rate:
Mplayer-srate 48000 <somefile>

Output Audio as a WAV file

You can output the audio part of a video file as a WAV file:
Mplayer-ao PCM <somefile>

This will output the audio file named audiodump.wav. You can also specify the name for the output WAV file:
Mplayer-ao PCM: file = <FILENAME>. wav <somefile>

Use ASCII to watch movies

Although useless, it is fun. Two library files support this feature: AA and caca. With libaa, you can only watch movies in black and white ASCII. Libcaca supports color. However, libaa supports more widely. You can use libaa to watch a movie like this:
Mplayer-vo AA <somefile>

If you want to use libcaca:
Mplayer-vo caca <somefile>

Output movies as series images

Mplayer can also output movies as a series of images:
Mplayer-vo JPEG <somefile>

Note: The above command will generate a large number of JPEG files. The output JPEG file name looks like this: 00000001.jpg000000000002.jpg000000000003.jpg and so on.

You can also output other formats. You only need to replace the JPEG in the command with ppm, PNG, and TGA.

Specify Aspect Ratio

When you play a movie on a wide screen, you may want to use the aspect ratio:
Mplayer-aspect 16: 9 <somefile>

In a non-wide screen, you can use the aspect ratio of 4-3.

Place options in the mplayer configuration file

For general users, the configuration file is located in ~ /. Mplayer/config; the global configuration file is in/etc/mplayer/config. Different values are separated by rows, for example:

# Mplayer Config File
Srate = 1, 48000
Ao = "PCM: filedeskdumpedaudio.wav"

Create a playlist:

$ Ls $ home/music> music. lst

Add
Echo musicloud> music. lst

Delete
Use the compiler to open music. lst and delete

Play
$ Mplayer-playlist music. lst # may also be mplayer -- playlist music. lst. you can't remember it. Let's take a look at mplayer -- help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.