Tear-Free Video Playback with mpv

This post is about how to play tear-free video using GNU/Linux, weston and mpv, a pretty fork of mplayer. Weston is a reference compositor for the wayland protocol. One of its intended features is that windows should be rendered tear-free, meaning that you won't get partial frames drawn over previous ones. Unlike mplayer, mpv has been ported directly to the wayland protocol. With the right option and a supported graphics card, it will play you tear-free video under weston.

I'm writing this because I was inspired by a post by Bradley Kuhn, who shares technical solutions to problems that take him a while to figure out. I hope you find this useful.

I'm using debian jessie with mpv installed from sid, but this should be possible on other recent systems as well. I use the recent version of mpv because it supports control key combinations within weston, whereas the version in jessie currently doesn't.

Do this first to make the pinning process easier:

$ sudo apt-get update
$ sudo apt-get upgrade

Put this in /etc/apt/preferences.d/00-pinning

Package: *
Pin: release n=sid
Pin-Priority: 350

And add this to /etc/apt/sources.list

deb http://debian.csail.mit.edu/debian/ sid main

(Use whatever mirror suits you, for example the mirror you use for jessie.)

$ sudo apt-get update

Attempt the following, to make sure that your system doesn't want to upgrade every package under the sun (or any package) to sid. If that is what is being asked of you, then say no and fix your pinning settings.

$ sudo apt-get upgrade

Install mpv and weston:

$ sudo apt-get install weston
$ sudo apt-get install mpv/sid

If that doesn't work for you, you can try pulling in other dependencies from sid:

$ sudo apt-get install -t sid mpv

Then open a tty by pressing ctrl-alt-F2. Log in with your user information. Launch weston:

$ weston -i0
$ weston-launch -- -i0  # (alternative command for newer versions of weston)

The -i0 option is to disable the screen saver.

$ mpv --vo=opengl-old $VIDEO_NAME

The above command does the trick on my X60 laptop. Search the mpv man page for "video output drivers" to see more options. I recommend creating a bash alias for the that command, so you can just type mpv.

To quit weston, type ctrl-alt-backspace. Exit with ctrl-D and then return to your X11 session with ctrl-alt-F7. Enjoy!

Posted: 31 Jan 2015

Author: Andrew Engelbrecht