当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 4 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : Mplayer的使用技巧,好好享受Mplayer———摘,自藏
帖子发表于 : 2008-12-31 14:38 

注册: 2008-08-21 12:25
帖子: 64
地址: 上海
送出感谢: 0 次
接收感谢: 0 次
本文所要探讨的,除却一般的使用方法之外,更包括一些鲜为人知的提示和诀窍。相信在阅读此文后,你的多媒体播放体验将会增色不少。

播放文件

使用 MPlayer 播放媒体文件最简单的方式是:

mplayer <somefile>

MPlayer 会自动检测文件的类型并加以播放,如果是音频文件,则会在命令行中显示该播放文件的状态信息;而假如是视频文件的话,则会打开一个新的播放窗口。

倒退与快进

在播放文件的时候,你可以通过以下三组快捷键来对播放进程进行倒退与快进操作:

* 左方向键和右方向键:分别执行倒退 10 秒和快进 10 秒操作
* 下方向键和上方向键:分别执行倒退 1 分钟和快进 1 分钟操作
* 下翻页键和上翻页键:分别执行倒退 10 分钟和快进 10 分钟操作

播放 DVD

虽然 MPlayer 不支持 DVD 菜单,但是却能够播放 DVD。你可以这样播放 DVD:

mplayer dvd://<titlenumber>

你需要使用实际的数字来替换 <titlenumber>,如 1、2、3 等。

使用字幕

当播放电影文件时,你可以指定字幕文件:

mplayer -sub <somesubtitlefile> <somefile>

在播放 DVD 电影时,你也可以通过指定语言代码来使用字幕:

mplayer dvd://<titlenumber> -slang nl,en

这样,MPlayer 就会优先使用荷兰语字幕,如果该语言不可用,则再使用英语字幕。

有用的快捷键

以下是 MPlayer 中一些有用的快捷键:

* f-当播放视频时,在全屏和窗口模式之间切换。你也可以在命令行中使用 -fs 选项,以便让 MPlayer 开始在全屏模式中播放。
* o-在播放视频时切换 OSD(OnScreen Display)模式。
* p 或 Space-暂停/继续播放。
* q 或 Esc-退出 MPlayer。在 GUI 模式时,Esc 不会退出,仅停止播放。
* / 和 * 或 9 和 0-减小或增大音量。
* m-静音切换。
* T(通常是 Shift + t)-播放窗口置顶切换。
* b 和 j-在可用的字幕间循环。
* x 和 z-调整字幕的延迟时间。
* I(Shift + i)-显示播放电影的文件名称。
* 1 和 2-调整对比度。
* 3 和 4-调整亮度。
* 5 和 6-调整色度。
* 7 和 8-调整饱和度。

生成索引

有时候,有些视频文件(主要是 AVI 文件)包含损坏的索引,或者根本就没有索引。这种情况通常是由下载文件不正确或未完成造成的。幸运的是,MPlayer 能够生成正常播放文件所需的索引。通过使用 -idx 选项,你可以告诉 MPlayer 来生成索引:

mplayer -idx <somefile>

有时候文件虽然包含索引,但却已损坏。那样的情况,你可能需要 MPlayer 强制生成索引:

mplayer -forceidx <somefile>

根据视频文件的大小,生成索引需花费一定的时间。但在此后,文件应该能够正常播放。

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

有些视频文件(主要是 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"


原文:just for reference

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>

Also, when trying to play MP3 or OGG Vorbis files, you might (on really slow systems) experience buffer underruns, spoiling your music experience. In that case, try using the libmad (in the case of an MP3) or the Tremor (in case of an OGG Vorbis) audio codec. You can detect whether you have a one or not like this:

(In case of MP3)

[rechosen@localhost ~]$ mplayer -ac help | grep mad

If the above command returns a line like this:

mad libmad working libMAD MPEG layer 1-2-3 [libmad]

Then you can play an MP3 file with libmad, which uses a lot less CPU power. To do so, invoke MPlayer like this:

[rechosen@localhost ~]$ mplayer -ac mad <somefile>

In OGG's case, you can use the same trick to look if you have a tremor audio codec available:

[rechosen@localhost ~]$ mplayer -ac help | grep tremor

Sadly, I don't have an example of what it should look like. If you seem to have a working tremor decoder, please leave a comment here so I can add it.

Playing streams from the internet

Many web radio stations make you download a playlist with different ip's and ports if you want to listen to them. MPlayer is perfectly able to play a web station stream, but the playlist is not a stream, nor a media file. If MPlayer doesn't autodetect that it's looking at a playlist and not at a direct stream or media file, you can try using the -playlist option:

[rechosen@localhost ~]$ mplayer -playlist <file or url>

And if the server has hiccups and causes a lot of buffer underruns (or if you have a bad connection), you can set a bigger cache size:

[rechosen@localhost ~]$ mplayer -cache 8192 -playlist <file or url>

The cache size is specified in kilobytes; the above will make MPlayer use a cache of 8 mb. Note that MPlayer doesn't fill the whole cache before it starts playing, it only fills about 4 percent (after that it'll try to keep filling the cache during playback). You can alter that percentage with the -cache-min option:

[rechosen@localhost ~]$ mplayer -cache 8192 -cache-min 50 -playlist <file or url>

You can seek in a cache, but do not expect too much of it =).

Looping playback

If you want the media file you're playing to loop a certain amount of times (or infinitely), you can specify the -loop option, like this:

[rechosen@localhost ~]$ mplayer -loop 3 <somefile>

The above command will play <somefile> three times and then exit.

[rechosen@localhost ~]$ mplayer -loop 0 <somefile>

The above command will repeat playing <somefile> forever, unless it is interrupted (for example by quitting MPlayer with the "q" keyboard shortcut). Infinite playback can be useful if you, for example, want a (promotion) movie to play all day on an exhibition.

Altering the playback speed

This may not be that useful, but it can be good for a laugh =). You can make MPlayer play a media file at a different speed with the -speed option. The value 1.0 means normal speed, 0.5 means twice as slow, 2.0 means twice as fast and so on. Specify the option like this:

[rechosen@localhost ~]$ mplayer -speed 2.0 <somefile>

Altering the sample rate

You might want to alter the output sample rate sometimes (certain audio cards, for example, do not support other samplerates than, say, 48000 Hz). This is done with the -srate option, like this:

[rechosen@localhost ~]$ mplayer -srate 48000 <somefile>

This can also be useful when exporting audio to a file (see next chapter).

Exporting the audio to a wav file

You can export the audio of a video file to a wav file this way (note that you can also use this to convert an audio file to a wav file):

[rechosen@localhost ~]$ mplayer -ao pcm <somefile>

This will export the audio to the file audiodump.wav. You can also specify a filename for the exported wav:

[rechosen@localhost ~]$ mplayer -ao pcm:file=<filename>.wav <somefile>

Watching a movie in ASCII

Another pretty useless but funny feature. There are two libraries that provide support for this: aa and caca. With libaa, you can only watch a movie in black & white ASCII, while libcaca supports colors. However, libaa is more widely supported. You can watch a movie with libaa this way:

[rechosen@localhost ~]$ mplayer -vo aa <somefile>

And, if you want to (and can) use libcaca:

[rechosen@localhost ~]$ mplayer -vo caca <somefile>

Exporting a movie to a lot of pictures

MPlayer can also export a movie to a load of images. For example:

[rechosen@localhost ~]$ mplayer -vo jpeg <somefile>

Warning: the above command will output a huge amount of jpeg files. I strongly recommend to do this in a freshly made, empty directory created for this purpose.

The filenames of the jpeg file it will export will look like this:

* 00000001.jpg
* 00000002.jpg
* 00000003.jpg
* And so on...

You can export to some other formats. Just replace jpeg in the command above with ppm, png or tga. Note that all these image format have their own options, too. Look for them in MPlayer's man page.

Specifying an aspect ratio

When playing video files on, for example, a wide laptop screen, you'll probably want to benefit from that wideness by watching a movie in a 16:9 aspect ratio. You can do that this way:

[rechosen@localhost ~]$ mplayer -aspect 16:9 <somefile>

Of course, you can also specify 4:3 as the ratio to force MPlayer to show the movie in non widescreen format.

Putting options in your MPlayer config file

MPlayer has a nice way of storing options so they will be automatically set every time you invoke the MPlayer command. This can be useful if your system, for example, always needs the audio outputted with a different samplerate. However, the syntax of the config file is a little different. If you'd type -srate 48000 on the command-line, this should be specified in the config file as srate=48000. More complex options, like the -ao pcm:file=<filename>.wav, should be put between quotes in a way like this: ao="pcm:file=<filename>.wav". The config file is located at ~/.mplayer/config for a user, and a global configuration file is located at /etc/mplayer/config. The different values are separated by newlines, like this:

# MPlayer config file

srate=48000
ao="pcm:file=dumpedaudio.wav"


Final words

Although this tutorial lists and explains quite a bunch of MPlayer features, this wonderful program features a lot more! Have a look at its man page or at the documentation on the MPlayer website. Anyway, I hope this tutorial helped you. Please help promoting this website a little, to let other people benefit from its growing knowledge. Thank you for reading, and happy MPlaying!


页首
 用户资料  
 
2 楼 
 文章标题 : Re: Mplayer的使用技巧,好好享受Mplayer———摘,自藏
帖子发表于 : 2009-01-18 9:11 
头像

注册: 2007-11-29 9:41
帖子: 8455
送出感谢: 0 次
接收感谢: 0 次
不错,保留 :em11


页首
 用户资料  
 
3 楼 
 文章标题 : Re: Mplayer的使用技巧,好好享受Mplayer———摘,自藏
帖子发表于 : 2009-02-02 10:36 

注册: 2008-01-09 12:56
帖子: 135
送出感谢: 0 次
接收感谢: 0 次
请问 −rootwin 参数怎么用?我想实现在桌面根窗口放电影


页首
 用户资料  
 
4 楼 
 文章标题 : Re: Mplayer的使用技巧,好好享受Mplayer———摘,自藏
帖子发表于 : 2009-02-03 16:27 

注册: 2008-02-03 10:27
帖子: 69
送出感谢: 0 次
接收感谢: 0 次
学习了一下,受益很多。多谢!


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 4 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:Exabot [Bot] 和 4 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译