MPlayer (简体中文)
MPlayer 是 GNU/Linux 下非常流行的影音播放器,支持绝大多数视频/音频文件格式,非常通用。
安装
安装 软件包 mplayer 或它的开发版本 mplayer-svnAUR 。
定制版:
- MPlayer-VAAPI — 支持 VAAPI 的版本
- http://gitorious.org/vaapi/mplayer[失效链接 2020-08-04 ⓘ] || mplayer-vaapiAUR
- MPlayer2 — MPlayer 的分支
图形前端
参考 List of applications/Multimedia#MPlayer-based.
配置
系统全局配置文件位于/etc/mplayer/
,用户配置文件位于~/.mplayer/
。
/etc/mplayer/
下默认包含:
codecs.conf
- 解码器配置文件。example.conf
- mplayer.conf 不会在安装时自动创建,这是其示例文件。input.conf
- 快捷键配置文件。
~/.mplayer/
下默认包含一个 config 文件。
参考 MPlayer 配置示例 和 mplayer(1)。
按键绑定
系统按键绑定通过 /etc/mplayer/input.conf
配置,个人按键绑定通过 ~/.mplayer/input.conf
配。完整的键盘快捷键列表请阅读 mplayer(1)。
参阅:XF86 键盘符号
提示与技巧
继续之前的播放
为了获得这个功能, 你可以到 AUR 下载mplayer-resumerAUR[断开的链接:package not found] 软件包。这个软件包包含一个Perl脚本,使你可以从上一次的播放记录继续播放。
To use it, simply call the wrapper script in place of MPlayer:
$ mplayer-resumer options path/to/file
If this script is restarted within a short amount of time after closing MPayer (default 5 seconds) then it will delete the file used to keep track of the videos resume position, effectively starting the video from the beginning.
If the video file to be played is on a read-only filesystem, or otherwise lives in a location that cannot be written to, resume will fail. This is because the current implementation uses a file parallel to the video file to store the timecode.
硬件加速
参考 Hardware video acceleration.
启用 VDPAU
将下列内容加入前面提到过的配置文件(全局或用户配置文件均可):
vo=vdpau, vc=ffmpeg12vdpau,ffwmv3vdpau,ffvc1vdpau,ffh264vdpau,ffodivxvdpau,
- The trailing commas are important! They tell MPlayer to fall back on other drivers and codecs should the specified ones not be found.
-vo
option selects VDPAU video output driver,-vc
option selects VDPAU video codecs.
启用 VA-API
This requires mplayer-vaapiAUR from the AUR.
$ mplayer -vo vaapi -va vaapi foobar.mpeg
- -vo - Select vaapi video output driver
- -va - Select vaapi video decoder driver
MPlayer based players:
- gnome-mplayer: To enable hardware acceleration: Edit > Preferences > Player, then set Video Output to
vaapi
. - smplayer: To enable hardware acceleration: Options > Preferences > General > Video, then set Output driver to
vaapi
.
Radeon 显卡启用半透明视频混合显示
为了在 X 中获得半透明视频效果,你需要在MPlayer中启用视频纹理:
$ mplayer -vo xv:adaptor=1 file
或者在 ~/.mplayer/config
中添加一行:
vo=xv:adaptor=1
你可以使用 xvinfo
命令检查你的显卡支持那种视频模式。
播放流媒体文件
要播放流媒体(如*.asx文件),使用以下命令:
$ mplayer -playlist link-to-stream.asx
必须使用-playlist参数,因为这些文件是流媒体列表,而非影音文件。
播放DVD
To play a DVD with MPlayer:
$ mplayer dvd://N
where N is the desired title number. Start at 1 and work up if unsure. To start at a specific chapter use the '-chapter' flag. For example, adding '-chapter 5' to the command starts the dvd playing at chapter five of the title.
Mplayer checks /dev/dvd
by default. Tell it to use /dev/sr0
with the dvd-device
option at the command line, or the dvd-device
variable in ~/.mplayer/config
.
To play a DVD image file:
$ mplayer -dvd-device movie.iso dvd://N
To enable the DVD menu use:
$ mplayer dvdnav://
Enter
key to choose.To enable mouse support in DVD menus use:
$ mplayer -mouse-movements dvdnav://
To find the audio language, start MPlayer with the -v
switch to output audio IDs. An audio track is selected with -aid audio_id
. Set a default audio language by editing ~/.mplayer/config
and adding the line alang=en
for English.
With MPlayer, the DVD could be set to a low volume. To increase the maximum volume to 400%, use softvol=yes
and softvol-max=400
. The startup volume defaults to 100% of software volume and the global mixer levels will remain untouched. Using the 9
and 0
keys, volume can be adjusted between 0 and 400 percent.
alang=en softvol=yes softvol-max=400
DVB-T Streaming
See DVB-T for more info.
JACK support
To have MPlayer audio output directed to JACK as its default behavior, edit ~/.mplayer/config
and add:
ao=jack
If you do not have JACK running all the time, you can have MPlayer output to JACK on an as-needed basis by invoking MPlayer from the command line as such:
$ mplayer -ao jack path/to/file
Advanced Subtitles
In order to get Advanced SubStation Alpha (ass) or SubStation Alpha (ssa) formatted subtitles to display properly you need to either edit ~/.mplayer/config
and add:
ass=true
or add -ass to the command line:
$ mplayer -ass path/to/subtitledVideo.mkv
One possible indication of needing to enable this flag is if you get numbers appearing with your subtitles. This is caused by the positioning information being interpreted as something to be displayed. Mplayer will also complain about subtitles being either too long or having too many lines.
Enabling ass
also enables any embedded fonts. As per the note in the mplayer's man adding embeddedfonts=true
is unneeded if fontconfig is version 2.4.2 or newer. Fontconfig will also be used to select which font to use when there are no embedded fonts. This may result in a different font being used than the OSD subtitle renderer.
Internet radio
Here is an example of a script for an easy start/stop of playing a predefined radio station. [1][失效链接 2020-08-04 ⓘ]
#!/bin/bash XX="X"$1; PLAYIT='mplayer -loop 0 -playlist http://*.*.*.*:8000/listen.pls'; if [ "$XX" == "Xstop" ]; then killall mplayer; else if [ 'EX' == 'EX'"$(pidof mplayer)" ]; then if [ "$UID" -ne 0 ]; then nohup $PLAYIT &> /dev/null & disown; else echo The "root" user is not allowed to run this script. fi else echo mplayer is already running by user: $(ps -eo user,comm | grep -i "mplayer"$ | sed 's/ mplayer/,/m') | sed "s/ ,$/./m"; fi fi
For more details on a running mplayer instance:
$ ps -eo pcpu,pid,user,comm | grep -i "mplayer"$ | sed "s/ mplayer$//m"
问题处理
无法打开名称含空格的文件
打开名称含空格的文件时,如果报类似于“无法打开file:///The%20Movie”的错误(空格被替换成“%20”了),可以通过下面的方法解决:
打开/usr/share/applications/mplayer.desktop
,修改下面的内容:
Exec=mplayer %U
为:
Exec=mplayer "%F"
如果要使用图形前端,修改为Exec=gui_name "%F"
即可。
MPlayer has black or strange colored font for OSD and Subtitles
There appears to be an issue with OSD and Subtitle colors when using vdpau output, which mplayer may be using by default. You can get around this issue by using xv instead of vdpau:
As a command line option:
mplayer -vo xv
Adding the following line to your ~/.mplayer/config
file:
vo=xv
See the original forums thread for details.
Smplayer无图像
打开mp4和flv文件时,Smplayer可能出现无图像问题。解决方法如下:
打开~/.mplayer/config
添加:
[extension.mp4] demuxer=mov
如果还有问题,可能是由Smplayer原有设置导致的。删除设置文件即可:
$ rm -rf ~/.config/smplayer/file_settings
Transparent SMPlayer in Gnome with Composite enabled
Have you noticed the transparent screen of smplayer when you are using compiz and maybe cairo-dock? Well it’s ridiculous that when you open your videos using SMplayer you can just hear audio and no video! Here’s how you fix this: [copy paste into terminal]
sudo bash -c "cat > /usr/bin/smplayer.helper" <<EOF export XLIB_SKIP_ARGB_VISUALS=1 exec smplayer.real "$@" EOF sudo chmod 755 /usr/bin/smplayer.helper sudo mv /usr/bin/smplayer{,.real} sudo ln -sf smplayer.helper /usr/bin/smplayer
If you don’t use sudo then just use “su” to login as root and do the above!
SMPlayer: OSD font too big / subtitle text too small
Since SMPlayer 0.8.2.1 (with MPlayer2 20121128-1), the ratio of the subtitle font to the OSD font is very strange. This can result in the OSD text filling the whole screen while the subtitles are very small and unreadable. This problem can be solved by adding:
-subfont-osd-scale 2
or to the extra options passed to MPlayer from SMPlayer. These options are found in Options > Preferences > Advanced > Options for MPlayer. This can also be achieved by adding the following line to ~/.mplayer/config
:
subfont-osd-scale=2
Mplayer shows question marks for some characters on subtitle
If the codepage of the subtitles is utf8, try using:
-subcp utf8
You can find the codepage of the subtitles with:
file subtitles.srt
See mplayer-shows-question-marks-for-some-characters-on-subtitle.
Choppy audio CD playback
CDDA playback may be interrupted every few seconds as the CDROM spins down the CD. To get around this you need to cache or buffer in advance using the -cache
option:
mplayer cdda://:1 -cache 1024
The :1
is to lower the CDROM speed for a constant spin and less noise.
参阅
- MPlayer FAQ
- MPlayer tips
- How to configure MPlayer
- playerctl: A command-line utility and library for controlling media players