Use the command line under Player

Use the command line under Player

MPlayer media player is a very good program I used Linux system, because it supports a wide range of playing audio / video file formats known. This article is to explore, except to general use, but also including some little-known tips and tricks. I believe after reading this article, you will be multimedia playback experience considerably.

Play files

The easiest way is to use MPlayer to play media files:
mplayer <somefile>

MPlayer will automatically detect the type of file, and it can be played, if it is an audio file, playback of the file is displayed status information in the command line; and if it is a video file will play a new window opens.

Fast forward and backward

When playing the file, you can come back and be on the fast-forward playback operation process through the following three sets of shortcuts:

Left arrow and right arrow keys: Run the back 10 seconds, and 10 seconds fast forward operation 
direction keys and the direction keys: Run the reverse and forward 1 minute 1 minute operation 
turning the key and the key page: Run the fast forward and backward 10 minutes 10 minutes operation 
play DVD

Although MPlayer does not support DVD menu, but the ability to play DVD. You can play this DVD:
mplayer DVD: // <titlenumber>

You need to use the actual numbers replacing <titlenumber>, 1,2,3 like.

Use subtitles

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

When playing a DVD movie, you can specify a language code by using subtitles:
mplayer DVD: // <titlenumber> -slang NL, EN

In this way, MPlayer will prefer to use Dutch subtitles, if the language is not available, then use English subtitles.

Useful shortcuts

The following are some of MPlayer useful shortcuts:

f- When playing video, and to switch between full-screen window mode. You can also use the -fs option on the command line, in order to make MPlayer start playing in full-screen mode. 
o- switching OSD (OnScreen Display) while playing a video. 
p or Space- pause / resume play. 
q or Esc- quit MPlayer. In the GUI mode, Esc does not exit, stop playback only. 
And / or 9 * and from 0 to decrease or increase the volume. 
m- mute switch. 
T (typically Shift + t) - play window switch top. 
and b j- cycle through the available subtitle. 
x and z- adjust the delay time subtitles. 
I (Shift + i) - displays the file name of the play movies. 
1 and 2 to adjust the contrast. 
3 and 4 to adjust the brightness. 
5 and 6 to adjust chromaticity. 
7 and 8 saturation adjustment. 
Generating an index

Sometimes, some video files (mainly AVI file) contains corrupted index, or no index. This usually is the download file is incorrect or incomplete due. Fortunately, MPlayer can generate an index normally required to play the file. By using -idx option, you can tell MPlayer to generate an index:
mplayer -idx <somefile>

Although sometimes file contains an index, but it has been damaged. That case, you may need to force the generation of index MPlayer:
mplayer -forceidx <somefile>

Depending on the size of the video file, generate the index takes some time. But after that, the file should be able to play correctly.

纠正错误的音频/视频同步

有些视频文件(主要是 flv 文件)由于编码的问题,会给 MPlayer 带来音频/视频同步的麻烦。这有两种可能情况:

MPlayer 会尝试修复,但同步问题却更遭。 
MPlayer 会尝试修复那些正确的,因此没有必要同步。 
对于第一种情况,你应当让 MPlayer 努力修复同步问题:
mplayer -autosync 30 -mc 2.0 <somefile>

而对于第二种情况,你不应当允许 MPlayer 去修复同步问题:
mplayer -autosync 0 -mc 0 <somefile>

将 上述命令中的 autosync 设置为正值就会让 MPlayer 逐渐调整音频/视频的同步。值越高,MPlayer 越快地修复它。mc 选项指定 MPlayer 纠正每帧要多少秒。值越高,MPlayer 越认为接近修复音频/视频同步。设置为 0 则阻止 MPlayer 修复。

在慢系统上使用 MPlayer

MPlayer 允许在旧的或慢的系统上使用低 CPU 功率来播放视频文件。你可以使用 -framedrop 选项:
mplayer -framedrop <somefile>

当播放 MP3 或 OGG Vorbis 文件时,你可能感受到一定的缓冲,这将影响你的音乐体验。那样的话,你可以尝试使用 libmad(MP3)或 Tremor(OGG Vorbis)音频解码器。你可以这样来检测它们:

对于 MP3:
mplayer -ac help | grep mad

如果上面的命令返回的结果像这样:
mad libmad working libMAD MPEG layer 1-2-3 [libmad]

那么你可以使用 libmad 播放 MP3:
mplayer -ac mad <somefile>

在 OGG 的情况中,你可以使用同样的技巧来检测 tremor 音频解码器是否可用:
mplayer -ac help | grep tremor

播放流媒体

如果 MPlayer 无法自动找到播放列表或直接的流媒体文件,你可以尝试使用 -playlist 选项:
mplayer -playlist <file or url>

同时你也可以设置较大的缓存:
mplayer -cache 8192 -playlist <file or url>

指定缓存大小的单位是 KB,上面的命令将允许 MPlayer 使用 8 MB 缓存。你可以使用 -cache-min 选项来改变 MPlayer 占用缓存的百分比:
mplayer -cache 8192 -cache-min 50 -playlist <file or url>

循环播放

如果你想让媒体文件循环播放,可以使用 -loop 选项:
mplayer -loop 3 <somefile>

上面的命令将播放 <somefile> 3 次,然后才退出。
mplayer -loop 0 <somefile>

上面的命令将永远重复播放 <somefile>。

改变播放速度

你可以使用 -speed 选项来改变 MPlayer 播放媒体文件的速度。值为 1.0,意味着正常速度;0.5 意味着慢两倍;2.0 意味着快两倍。像这样指定选项:
mplayer -speed 2.0 <somefile>

改变采样率

使用 -srate 选项你可以改变 MPlayer 输出的采样率:
mplayer -srate 48000 <somefile>

将音频输出为 wav 文件

你可以将视频文件中的音频部分输出为 wav 文件:
mplayer -ao pcm <somefile>

这将输出名为 audiodump.wav 的音频文件。你也可以为输出的 wav 文件指定名称:
mplayer -ao pcm:file=<filename>.wav <somefile>

使用 ASCII 方式观看电影

虽然无用,但却很好玩。有两个库文件支持该特性:aa 和 caca。使用 libaa,你只能在黑白 ASCII 中观看电影。而 libcaca 支持色彩。然而,libaa 支持更广泛。你可以像这样使用 libaa 观看电影:
mplayer -vo aa <somefile>

如果你想使用 libcaca:
mplayer -vo caca <somefile>

将电影输出为系列图片

MPlayer 也能将电影输出为一系列的图片:
mplayer -vo jpeg <somefile>

注意:上面的命令将产生数量巨大的 jpeg 文件。输出的 jpeg 文件名看起来像这样:00000001.jpg、00000002.jpg、00000003.jpg 等等。

你也可以输出其他的格式。只需将命令中的 jpeg 替换成 ppm、png、tga 等。

指定纵横比

当你在宽屏中播放电影时,可能想要使用 16:9 的纵横比:
mplayer -aspect 16:9 <somefile>

在非宽屏中,你可以使用 4:3 的纵横比。

将选项放置到 MPlayer 的配置文件中

对于一般用户来说,该配置文件位于 ~/.mplayer/config;全局的配置文件在 /etc/mplayer/config。不同的值使用行分隔,如:

# MPlayer config file
srate=48000
ao="pcm:file=dumpedaudio.wav"


创建播放列表:

 

$ ls $HOME/music > music.lst

添加
echo music.mp3 >> music.lst

删除
用编译器打开music.lst删除你想删除的

播放
$ mplayer -playlist music.lst #也有可能是mplayer --playlist music.lst,记不清啦,自己看一下mplayer --help

发布了25 篇原创文章 · 获赞 4 · 访问量 2万+

Guess you like

Origin blog.csdn.net/zhou8400/article/details/79108315