Last Edit (23.05.2009)
MPlayer is a high quality media player with feature rich options that can play almost every known media files. It can play media such as DVD, VCD, CD, DVB, web-stream, and in any containers such as SMplayer, KMplayer, MythTV, Kaffeine, etc. MPlayer by itself is a command-line tool (CLI), however there is a graphical frontend called gmplayer that come by default with at least one skin theme (mplayer-skin-blue). If you are either not comfortable with CLI or need features like DVD navigational menus I would suggest you use SMplayer which is available in the Debian repository.
Please consulate the MPlayer documentations at mplayerhq website for features, supported input formats, supported video & audio codecs, and supported video & audio output devices.
This HOW-TO explains how to setup MPlayer on your Debian system. Feel free to add your own tips and tricks and examples are also welcome.
Note:
1.In all instance, the console/terminal prompt # refer to 'root' usage and $ refer to normal usage.
2.I use apt-get in all instances of package management but feel free to use your own such as aptitude or synaptic.
MPlayer is in the main Debian repository. To get the Debian MPlayer,
Code: Select all
# apt-get update
# apt-get install mplayer
I would recommend that you install MPlayer using either of the two methods below:
Method 1
Install from the Debian-Multimedia repository maintained by Christian Marillat as it's more up to date though it requires some non-free packages. Open the /etc/apt/sources.list file with an editor of your choice, in this case nano:
Code: Select all
# nano -w /etc/apt/sources.list
Code: Select all
deb http://www.debian-multimedia.org branch main
deb-src http://www.debian-multimedia.org branch main
Code: Select all
deb http://www.debian-multimedia.org squeeze main
deb-src http://www.debian-multimedia.org squeeze main
Get the apt-key:
Code: Select all
# apt-get install debian-multimedia-keyring
Code: Select all
# apt-get update
# apt-get install mplayer w32codecs
Code: Select all
# apt-get install mozilla-mplayer
Install MPlayer from source files, i.e., the daily Subversion (SVN) snapshots which is the recommended method and it's generally stable or download via SVN. There is a quick compilation and installation instructions in the mplayerhq's README page.
To get SVN snapshots:
Debian-multimedia source and binaries page.
To download via SVN, make sure that you have the package subversion installed before doing SVN checkout:
Code: Select all
$ svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
1. Update and install the necessary developmental libraries and build tools:
Code: Select all
# apt-get update
# apt-get build-dep mplayer
# exit
Code: Select all
$ ./configure --help
3. Compile with your specific configurations, e.g., dvb, lirc, and other optimisations enabled or disabled then build the *.deb package all with one command:
Code: Select all
$ DEB_BUILD_OPTIONS="--enable-gui --enable-menu" fakeroot debian/rules binary
Code: Select all
# dpkg -i mplayer*.deb
Code: Select all
$ man mplayer
MPLAYER PLAYBACK
In the terminal run without options:
Code: Select all
$ mplayer
Code: Select all
$ mplayer /path/to/your/video
Code: Select all
$ mplayer -v /path/to/your/video
Code: Select all
$ mplayer -fs /path/to/your/video
Code: Select all
$ mplayer -monitoraspect 16:9 -fs /path/to/your/video
Code: Select all
$ mplayer -loop 2 /path/to/your/video
Code: Select all
$ mplayer -loop 0 /path/to/your/video
Code: Select all
$ mplayer /path/to/your/video -loop 2
Code: Select all
$ mplayer /path/to/your/video -ss 45
Code: Select all
$ mplayer ~/path/to/your/video -ss 01:30:00
It's possible to run MPlayer from the console in framebuffer mode. Assuming that you have already setup the framebuffer and ALSA:
Code: Select all
$ mplayer -vo fbdev /path/to/your/video
Code: Select all
$ mplayer -vo fbdev -fs -vf scale=1440:900 /path/to/your/video
Some useful default keyboard control (check man page for full list):
Code: Select all
right arrow/left arrow: Seek forward/back 10 seconds
up arrow/down arrow: Seek forward/back 1 minute
page up/page down: Seek forward/back 10 minutes
< and > : Move backward and forward in playlist
p, space: Toggle pause
f : Toggle full-screen
t : Toggle stay-on-top
q, Esc: Stop playing and quit
+ and - : Adjust audio delay by +/-0.1 seconds (100ms)
j : Rotate through subtitles
/, 9 and *,0 : Decrease/increase volume
m : mute sound
scroll wheel: Seek forward/back
Mplayer configuration files are usually located in ~/.mplayer/ for user setting and /etc/mplayer/ for system-wide setting. You can set up most of the frequently used configuration in ~/.mplayer/config. If you do not have a config file in ~/.mplayer, just copy the system wide one:
Code: Select all
$ cp /etc/mplayer/mplayer.conf ~/.mplayer/config
Code: Select all
$ mplayer /path/to/your/video -vo xv -ao alsa -channels 2 -alang=de,en -slang=en
Code: Select all
vo=xv
ao=alsa
channels=2
alang=en,de
slang=en
Code: Select all
$ mplayer /path/to/your/video
MPlayer has good support for DVD playback but not for DVD menus and navigation (for these I would suggest you try the latest package SMPlayer or xine). The graphical gmplayer has a limited menu features including playback, titles, chapters, audio language & subtitle language. MPlayer simply skips the menu system and goes straight to the first video in the title. Some DVDs have several titles each containing stuffs like main feature, deleted scenes, etc. To start playback of the first title in the DVD:
Code: Select all
$ mplayer dvd://1
Code: Select all
$ mplayer -v dvd://
Code: Select all
Reading disc structure, please wait...
There are 4 titles on this DVD.
There are 1 angles in this DVD title.
DVD successfully opened.
audio stream: 0 format: ac3 (5.1) language: en aid: 128.
audio stream: 1 format: dts (5.1) language: en aid: 137.
audio stream: 2 format: ac3 (stereo) language: en aid: 130.
number of audio channels on disk: 3.
subtitle ( sid ): 0 language: en
subtitle ( sid ): 1 language: en
number of subtitles on disk: 2
Code: Select all
$ mplayer dvd://1 -dvd-device /dev/hdc
Code: Select all
$ mplayer dvd://1 -dvd-device /path/to/dvd.iso
Code: Select all
$ mplayer dvd://1 -dvd-device /path/to/VOB/directory
Code: Select all
$ mplayer dvd://1 -chapter 3-6
Code: Select all
$ mplayer dvd://1 -alang de,en
Code: Select all
$ mplayer dvd://1 -alang de,en -slang en
Code: Select all
# apt-cache search libdvdread
# apt-cache search libdvdcss
Code: Select all
# apt-get install libdvdread3 libdvdcss2
(S)VCD playback in mplayer is similar to DVD playback, just use the vcd:// argument. It can play .bin files from (S)VCD:
Code: Select all
$ mplayer vcd://1
MPlayer supports playback from many different audio and video streams, e.g., to play a mms stream, pass the URL on the command line:
Code: Select all
$ mplayer mms://url/path/to/video.wmv
You can use the playlist for stream from web radio for example. To create a playlist open a text editor, copy & past the stream URL and save it as whatever name you choose and playback it with the -playlist option:
Code: Select all
$ mplayer -playlist /path/to/your/stream/playlist/file
Code: Select all
$ mplayer -dumpstream mms://url/path/to/video.wmv -dumpfile your_dumped_stream.wmv
ANALOGUE & DIGITAL TV CARD PLAYBACK
If you have a TV tuner card whether it's a PCI or USB it should be a simple matter of using mplayer to play and also record your favourite TV show. Setting up your TV tuner is beyond the scope of this HOWTO, nevertheless I'll point you to the excellent linuxtv.org website for V4L-DVB cards and the IVTV driver website for cards like Conexant's and Hauppauge's PVR 1xx/2xx/3xx, etc. Also, you can check my HOWTO for Hauppauge WinTV-HVR-1110 DVB-T card in this forum.
Taking DVB-T card as an example, once you have it setup you can test your DVB card, scan channels and use mplayer to play & record your show. Install some dvb utilities such as dvb-apps, dvbsnoop, dvbstream and dvbtune. Follow this guide for scanning channels and creating a channels.conf file. Put the channels.conf file in ~/.mplayer directory. To play a DVB-T channel:
Code: Select all
$ mplayer dvb://"stream name"
Code: Select all
$ mplayer dvb://"BBC ONE"
Code: Select all
$ mplayer -dumpstream dvb://"BBC ONE" -dumpfile bbc_one.ts
Code: Select all
mencoder -ovc copy -oac copy -o bbc_one.ts dvb://"BBC ONE"
Code: Select all
$ mplayer /path/to/bbc_one.ts
linuxtv.org Mplayer
linuxtv.org Mencoder.
SUBTITLE & OSD MENU
MPlayer can handle most subtitles, see subtitles and On-Screen-Display (OSD) for detail.
There are many text subtitle like *.srt (SubRip) or *.ssa (Sub Station Alpha) file that you could download and play in MPlayer with -sub option:
Code: Select all
$ mplayer -sub /path/to/your_subtitle /path/to/your/video
Code: Select all
$ mv matrix-de.srt matrix.srt
$ mplayer matrix.avi
Code: Select all
$ mplayer -subfont-text-scale 3 /path/to/your/video
Code: Select all
<txt name="man" file="manpage.txt"/>
<filesel name="open_file"/>
<filesel name="open_list" file-action="loadlist '%p'" auto-close="yes"
title="Open a playlist: %p" />
<dvbsel title="Channel List" name="dvbsel" />
<pt name="jump_to"/>
<console name="console0" height="80" vspace="0">Welcome to MPlayer</console>
<txt name="man" file="manpage.txt"/>
<pref name="general_pref" title="General">
<e name="autoq"/>
<e name="autosync" />
<e name="framedrop"/>
<e name="quiet"/>
<e name="softsleep" />
</pref>
<pref name="demuxer_pref" title="Demuxer">
<e name="aid"/>
<e name="alang" />
<e name="cache"/>
<e name="channels"/>
<e name="dvdangle" />
<e name="forceidx"/>
<e name="fps"/>
<e name="hr-mp3-seek"/>
<e name="idx"/>
<e name="mc"/>
<e name="ni"/>
<e name="nobps"/>
<e name="srate"/>
<e name="vid"/>
</pref>
<pref name="osd_sub_pref" title="OSD & Subs">
<e name="ffactor"/>
<e name="noautosub"/>
<e name="osdlevel"/>
<e name="sid"/>
<e name="slang"/>
<e name="subdelay"/>
<e name="subfps"/>
<e name="subpos"/>
<e name="unicode"/>
<e name="utf8"/>
<e name="vobsubid"/>
</pref>
<pref name="audio_pref" title="Audio">
<e name="abs"/>
<e name="af"/>
<e name="ao"/>
<e name="delay"/>
<e name="mixer"/>
</pref>
<pref name="video_pref" title="Video">
<e name="bpp"/>
<e name="brightness"/>
<e name="contrast"/>
<e name="display"/>
<e name="double"/>
<e name="dr"/>
<e name="fs"/>
<e name="geometry"/>
<e name="hue"/>
<e name="icelayer"/>
<e name="noslices"/>
<e name="panscan"/>
<e name="rootwin"/>
<e name="saturation"/>
<e name="vm"/>
<e name="vo"/>
<e name="vf"/>
<e name="xineramascreen"/>
</pref>
<cmdlist name="pref_main" title="Preferences" ptr="<>" >
<e name="General ..." ok="set_menu general_pref"/>
<e name="Demuxer ..." ok="set_menu demuxer_pref"/>
<e name="Osd/Subtitles ..." ok="set_menu osd_sub_pref"/>
<e name="Audio ..." ok="set_menu audio_pref"/>
<e name="Video ..." ok="set_menu video_pref"/>
</cmdlist>
<cmdlist name="main" title="MPlayer OSD menu" ptr="<>" >
<e name="Pause" ok="pause"/>
<e name="Prev/Next" ok="pt_step 1" cancel="pt_step -1"/>
<e name="Jump to ..." ok="set_menu jump_to"/>
<e name="Open ..." ok="set_menu open_file"/>
<e name="Open playlist ..." ok="set_menu open_list"/>
<e name="DVB" ok="set_menu dvbsel"/>
<e name="Help" ok="set_menu man"/>
<e name="Pref" ok="set_menu pref_main"/>
<e name="Console" ok="set_menu console0"/>
<e name="Quit" ok="quit"/>
</cmdlist>
Code: Select all
font=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
ffactor = 0.75
subfont-text-scale=3
subfont-osd-scale=3
menu=yes
To make a screen capture:
Code: Select all
$ mplayer /path/to/your/video -vf screenshot
Other method: first play it with x11 output driver (no hardware acceleration) and pause the video (spacebar or p):
Code: Select all
$ mplayer -vo x11 /path/to/your/video
Code: Select all
$ import screenshot.jpg && display screenshot.jpg
Code: Select all
# apt-get install imagemagick
Convert (from imagemagick) a video file of arbitrary format to a sequence of images:
Code: Select all
$ mplayer -nosound -vo jpeg /path/to/your/video
Code: Select all
$ mplayer -nosound -vo png:z=n /path/to/your/video
Code: Select all
$ mplayer /path/to/your/video ss 10:00 -vo jpeg
Code: Select all
$ display 00001.jpg
CREATING AN EDITED VIDEO FOR PLAYBACK
One of the nicest features of mplayer is the ability to edit out contents in a video for example you might want to edit video with questionable contents for your kids or you might want to edit out an annoying character from a movie or to skip commercials. You can use a feature called EDL (Edit Decision List) to do all of these.
To use EDL, simply play the video you want to edit by running mplayer with -edlout option:
Code: Select all
$ mplayer -edlout sample.edl /path/to/your/video
Code: Select all
4.504500 11.594916 0
416.290863 423.256165 0
Code: Select all
$ mplayer -edl sample.edl /path/to/your/video
If your playback is slow or jerky, try this example:
Code: Select all
$ mplayer -cache 8192 -cache-min 4 mms://url/path/to/video.wmv
The xv video output option is the default that most media players are set to. It use the XVideo extension in X for hardware acceleration. To test whether your card has support for it:
Code: Select all
$ xvinfo
Code: Select all
$ mplayer -vo x11 /path/to/your/video
To get a quick listing of -vo drivers:
Code: Select all
$ mplayer -vo help
To change video resolution:
Code: Select all
$ mplayer -vm -screenw 640 -screenh 480 /path/to/your/video
To normalise the volume, this will maximise the volume of the audio track without distortion:
Code: Select all
$ mplayer -af volnorm 4 /path/to/your/video
Code: Select all
$ mplayer -framedrop /path/to/your/video
See:
http://www.mplayerhq.hu/design7/news.html
MENCODERNews
2009-02-20, Friday :: Video Acceleration and You
posted by Compn
There are several ways to speed up the playback of 1080 H.264 files in MPlayer.
First is to use the newly added VDPAU output. It allows the newer Nvidia video cards to decode the video without using much CPU. It is in SVN MPlayer (Nvidia binary driver 180.37 or newer required), you can find known bugs and report bugs HERE. (Linux, Solaris and FreeBSD only)
How to get the SVN version is described on the download page and snapshot tarballs are available as well.
Second is to use MPlayer with the experimental multithreaded FFmpeg-mt branch, which allows you to use multiple cores/CPU. (all OS and CPU supported)
To install, copy and paste this line:
git clone git://repo.or.cz/mplayer && cd mplayer && git checkout origin/mt && git submodule init && git submodule update && ./configure && make && make install
To enable threading run mplayer -lavdopts threads=N file.mkv where N is the number of threads you want to use.
NOTE: FFmpeg-mt has problems with packed b-frames.
A Windows build of MPlayer using FFmpeg-mt can be found at http://kovensky.project357.com.
Third is to use the multithreaded CoreAVC codec with the CoreAVC-for-linux project. The CoreAVC decoder costs $15 USD. (Linux ONLY)(Windows users only need this PATCH)
Fourth, FFmpeg has added some optimizations from the x264 project. To fully utilize these you will need to make sure a recent version of YASM is installed and detected by the latest SVN MPlayer when compiling. (32bit x86 CPU only!)
Fifth, using -lavdopts skiploopfilter=all:fast=1 may cause artifacts, but will allow you to play larger files in realtime. (all OS and CPU supported) (use -lavdopts skipframe=nonref:skiploopfilter=all:fast=1 for even more speedup, skipframe also works with VDPAU.)
There is also a rejected PATCH which adds support for the new multithreaded binary VC-1/WMV3 codec.
Some useful links for encoding video using MEncoder, maintaining audio/video synchronization, VCD/(S)VCD, and some example scripts:
1. Mplayerhq: Using MEncoder to create VCD/SVCD/DVD-compliant files
2. Gentoo wiki's MEncoder HOWTO, and How to create a DVD with MEncoder.
CREATING PAL compliant DVD
For format constraints, please read the link for mplayerhq in no. 1 above. Generally, I use for widescreen PAL DVD (720x576):
* aspect ratio: 16/9
* framerate: 25
* ofps: 25
* vcodec: mpeg2video
* sample rate: 48000
* vrc_buf_size: 1835
* abitrate: 192 kbps for stereo (can be up to 1536; 384 kbps for 5.1 channel sound)
* vbitrate: 4900 (can be up to 9800, but longer encoding, better quality and limited to up to 1 hr of video on a single layer DVD)
* keyint: 15
The video will be encoded to *.ac3 audio, but you could also use *.mp2 audio (for PAL DVD only). I use the script below to encode my DVB-T MPEG-TS video to DVD. Open a text editor like nano, copy & paste the script below:
Code: Select all
#!/bin/sh
read -p "Name of video1: " VIDEO1;
mencoder -of mpeg -mpegopts format=dvd:vaspect=16/9:vframerate=25 -vf scale=720:576,harddup \
-srate 48000 -af lavcresample=48000 -ofps 25 \
-ovc lavc -oac lavc -lavcopts vcodec=mpeg2video:\
vrc_buf_size=1835:\
keyint=15:\
vrc_maxrate=9800:\
vbitrate=4900:\
aspect=16/9:\
acodec=ac3:abitrate=192 \
${VIDEO1}.mpg -o ${VIDEO1}-output.mpg
Code: Select all
$ chmod +x your_mencode_script
Code: Select all
$ ./your_mencode_script
LINKS
1. Offical MPlayer Documentation.
2. Multimedia Dynamite, Linux Journal, October 1st, 2007.
3. julian67's HOWTO: Multiple / Sequential Video Thumbnails