5 Comments

MPlayer with DVDs

Update: 2012-08-21 – Because of MPlayer still having trouble playing DVDs, I’ve since moved to using cVLC.

There are plenty of movie players for Linux but my all time favorite is MPlayer. Not only is MPlayer quick and responsive but it can play almost anything. I’ve used MPlayer before but I realized that my movies weren’t playing just as I wanted them too – no menu support, picture quality wasn’t as I expected. If you’d like to play DVD’s with player, here’s a guide that can show you how to get good functional DVD player.

Calibrating Display

Presentation is a large part of a good movie experience. Movie companies and movie theaters put a good deal of consideration over how a movie looks and sounds. THX for example became a standard in the movie industry defining such. Therefore, how your display looks also will represent the quality of the movie you play with MPlayer. There are a couple things you can do to create good picture quality on your monitor but first a quick bit on colorschemes.

Windows and Mac OS both have built in colorschemes (also known as ICC profiling). Colorschemes define such things for the display as color balance and gamma. Linux by default does not have any colorschemes defined. Often new users will report that their display when first installed looks “too bright”. There is no way to define a colorscheme in Linux but most of this “too bright” reporting is because of gamma and there is something you can do about that.

The best option so far for Linux is if you got an nvidia card and use the standard nvidia drivers. If you do, it includes a tool called ‘nvidia-settings’. This program will allow, contrast, brightness, color and gamma change for the GUI. If not, you’ll have to look a program to discover the proper gamma for Linux like Monica. Use monica to calibrate your gamma. Calibrating Monica you’ll notice the whole display will change. Ignore this and just be sure your red, green, and blue gammas are set ok. When this is done, Monica will display an option to have Monica load at desktop startup. This can be done but it’s better to have the X server know the settings directly because if you play games (for instance) your gamma will be reset. The X server can be made aware of the gamma in the “/etc/X11/xorg” file. For example:

Section "Monitor"
    Identifier     "Monitor0"
    Gamma           0.86 0.85 0.87
EndSection

Gamma values are in RGB order. Restart the X server to have the gamma values permanently applied.

MPlayer Config

Note: Nowdays, I use the MPlayer configuration file to control MPlayer behavior, plus I use vdpau graphic acceleration (for nvidia cards) and dvdnav:// for dvd menu navigation. Using the config I’m able to set different options for different media I play and don’t need a seperate script to run my dvds. Here is my ‘~/.MPlayer/config’ for any that would like to use it. However, the information following could be useful if you want to learn about other configurations.
[default]

# driver and codecs
vo=vdpau:deint=2,gl:yuv=2:force-pbo,xv,
vc=ffh264vdpau,ffmpeg12vdpau,ffwmv3vdpau,ffvc1vdpau,coreavc,dummy,
ao=oss,alsa
srate=48000
#mixer-channel="Master"

# options
mc=1             # keeps video and sound in sync
heartbeat-cmd="qdbus org.freedesktop.ScreenSaver  /ScreenSaver SimulateUserActivity" # disable screensaver
#fs=1                   # full-screen
#dr=1                   # direct rendering

# Picture settings
contrast=24
brightness=12
saturation=-14
hue=-8

[protocol.dvd]
profile-desc="profile for dvd:// streams"
alang=en
af=volnorm=1   # increase amplitude for movies because of wide dynamic range
#vf=yadif=3,hqdn3d=3:2.8:1:3 # for deinterlacint (tv shows)

[protocol.dvdnav]
profile-desc="profile for dvdnav:// streams"
profile=protocol.dvd
mouse-movements=yes
nocache=yes
fs=1

Selecting Video and Audio Output Devices

MPlayer defaults will work on just about any media. If you want to test MPlayer, try:

mplayer dvd://1

Track 1 almost always has something on it and you should get a good idea how MPlayers plays with the default settings. First thing you should do is decide what video output driver to use. Most people tend to use xv, this is the XVideo extension and has hardware accelerated playback. I however use the OpenGL driver because it give me slight better performance. For example:

mplayer -vo gl:yuv=2:force-pbo -dr -framedrop -fs dvd://1
mplayer -vo xv -dr -framedrop -fs -cache 8192 dvd://1

For OpenGL you’ll have to use a proper yuv setting, look into “man MPlayer” for all the options. Adding the ‘-dr’ option to make sure direct rendering gets used and add ‘-framedrop’ because if a CPU intensive task starts in the background audio and video will get out of sync. Using -fs will start MPlayer in full screen-mode.

For xv make sure to use the ‘-cache’ option as xv video doesn’t play well without it.

For audio, I just allow use MPlayers default. I’ve tried setting ‘-ao alsa’ but occasionally I get skips with that and find the default (usually aoss) works better.

Filters

One of the things you’ll notice at this time is that their is a little noise to the picture quality. This is common because TV’s have built-in noise-reduction filters. You’ll also notice if you are playing a DVD recorded tv show that the picture appears “lined”(interlacing). TV’s produce pictures by displaying alternate lines. So a property called deinterlacing is used to produce a combined image. To add deinterlacing and a noise filter try this:

mplayer -vo gl:yuv=2:force-pbo -dr -framedrop -fs \
-vf yadif=3,hqdn3d dvd://1

Yadif is a good deinterlacer and hqdn3d will help to smooth the picture. I find that hqdn3d produces a bit too blurred image so I’ve reduced it to:

mplayer -vo gl:yuv=2:force-pbo -dr -framedrop -fs \
-vf yadif=3,hqdn3d=3:2.8:1:3 dvd://1

For movies that aren’t interlaced MPlayer won’t use the yadif filter.

Aspect-Ratio

MPlayer may choose to alter the aspect-ratio which will result in a distorted picture. I think there is some legacy code in MPlayer that tries to scale based on screen size. Add ‘-noaspect’ to prevent this from happening:

mplayer -vo gl:yuv=2:force-pbo -dr -framedrop -fs \
-vf yadif=3,hqdn3d=3:2.8:1:3 -noaspect dvd://1

Contrast, Brightness, and Saturation

Even for a properly monitor the picture isn’t going to look quite right because movies use a different colorspace that is designed for proper display on a television. While not perfect this too can be corrected to a good degree with brightness, contrast, and saturation values.

If you’re using the gl driver, you’ll be able to adjust contrast, brightness, hue, and saturation with 1 and 2, 3 and 4, 5 and 6, 7 and 8, respectively. To add the values to the command line:

mplayer -vo gl:yuv=2:force-pbo -dr -framedrop -fs \
-vf yadif=3,hqdn3d=3:2.8:1:3 -noaspect \
-contrast 14 -brightness 8 -saturation -9 dvd://1

If you’re using the xv driver, you can use the software equalizer to enable the ability to adjust these values:

mplayer -vo xv -dr -framedrop -fs -cache 8192 \
-vf yadif=3,hqdn3d=3:2.8:1:3,eq2 -noaspect -contrast 14 \
-brightness 8 -saturation -9 dvd://1
mplayer -vo xv -dr -framedrop -fs -cache 8192 \
-vf yadif=3,hqdn3d=3:2.8:1:3,eq2=1:1.14:0.08:0.91 -noaspect \
-contrast 14 -brightness 8 -saturation -9 dvd://1

DVD Menus

New versions of MPlayer (as of this writing MPlayer-28347-4) now include support for DVD menus. MPlayer will have to be compiled with “–enable-dvdnav” for DVD menus to work. From the command line, tell MPlayer to use DVD menus:

mplayer -vo gl:yuv=2;force-pbo -dr -framedrop -fs \
-vf yadif=3,hqdn3d=3:2.8:1:3 -noaspect \
-contrast 14 -brightness 8 -saturation -9 dvdnav://

You can also add support for being able to choose DVD menu items with the mouse:

mplayer -vo gl:yuv=2;force-pbo -dr -framedrop -fs \
-vf yadif=3,hqdn3d=3:2.8:1:3 -noaspect \
-contrast 14 -brightness 8 -saturation -9 \
-mouse-movements dvdnav://

If using MPlayer with DVD menu support make sure you do not to have caching on or MPlayer won’t work properly.

That’s it! You should now have a great DVD player for you Linux.

Extranei

Sometimes selections in DVD menus don’t get recognized. I found that pressing 5 will bring them up again.

MPlayer uses keyboard presses for input. A basic reference of commonly used keys:

  • F – Fullscreen toggle
  • Q – Quit
  • P – Pause
  • ← – Backward 10 seconds
  • → – Forward 10 seconds
  • ↑ – Forward 1 minute
  • ↓ – Backward 1 minute
  • Pgup – Forward 10 minutes
  • Pgdown – Backward 10 minutes
  • !/@ – Backward/Forward Chapters
  • Arrow Keys or Numpad Arrow Keys – DVD navigation

Because DVD navigation binds to the arrow keys, they cannot be used to skip while using DVD navigation.

Users of newer Nvidia cards might want to look at MPlayer support for VDPAU (Purevideo technology).

Lastly, thanks to electro for his hqdn3d values.

About these ads

About Gen2ly

<3's linux

5 comments on “MPlayer with DVDs

  1. A few ppl have pointed out to me that using opengl requires a good bit of more CPU and that is true

    http://www.hexus.net/content/item.php?item=18017&page=5

    (with the basic defaults) but because the xv video driver requires me to use a software video equalizer i find that using xv and gl to be pretty comparable.

  2. I don’t know how you can play a typical DVD at all without dvdnav. As ripping protection, all the movie DVDs I’ve seen have invalid sectors in them that have to be navigated around using instructions on the DVD. dvdnav:// knows how to follow those instructions; dvd:// apparently isn’t smart enough.

    I just checked a current Debian Lenny Mplayer (based on Mplayer 1.0rc2) and dvd://1 just went into some kind of infinite loop reading the DVD, reporting “invalid navi packet”, and not even beginning to display.

    Maybe other versions of Mplayer have a more capable dvd:// .

  3. Yeah Bryan, I agree. This page needs to be updated. Currently, I’m not even using this script anymore and am using a vdpau mplayer with ‘mplayer dvdnav://’. Here’s the config I use:

    [default]
    # Write your default config options here!
    ao=alsa,oss
    mixer-channel=”Master”
    srate=48000
    vo=vdpau,gl:yuv=2:force-pbo,xv,
    vc=ffh264vdpau,ffmpeg12vdpau,ffwmv3vdpau,ffvc1vdpau,

    #dr=1
    framedrop=1
    #fs=1

    # Good for movies
    contrast=7 #6
    brightness=5 #6
    saturation=-6
    hue=-1

  4. [...] fast and bare-bones video player (to learn a little more about setting up MPlayer settings, look at this page). To be able have MPlayer as your default video player in KDE 4 you’ll have to do change mime [...]

  5. Magnificent beat ! I would like to apprentice while you amend your website, how could i subscribe
    for a blog site? The account aided me a acceptable deal.
    I had been a little bit acquainted of this your broadcast provided bright
    clear idea

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 51 other followers

%d bloggers like this: