Stopping screen tearing

It’s a blight of Linux generally, the dreaded screen tearing, certainly for users who use Nvidia cards/drivers. On some Distro’s i’ve had tearing, others not. On some Nvidia cards i’ve had tearing, on others not. It almost seems like it’s the luck of the draw. I’ve trawled Google for answers, i’ve tried almost everything until, almost by chance, I stumbled on an answer, for me at least, hopefully it will help others or point them in the right direction to solving their tearing issues.

I must admit I like my desktop to look clean, simple but very ‘fancy’. Rather duplicital i’ll admit. I like flat icons and window borders but I like the fancy opacity that compositing brings. I’ll get it out of the way now, I like Gnome 3, I’m running Gnome 3.12 right now. My current system has a nice big fancy Nvidia card coupled to two HD monitors and it’s great, no tearing. The issue I have with tearing is my bog standard Ubuntu/Unity Core2 media machine. All it does is stream video and music so it’s just got a GT218 Nvidia card with HDMI-out, it’s quite capable of supplying full 1080p to my 1080p TV, but here’s the rub, I get tearing in films! That sucks!

So what is ‘screen tearing’ or ‘tearing’ anyway? Basically it’s two (or more) frames being shown at the same time on your screen, this results in imperfections in the playback, or lines horizontally across the entire screen, or the areas of the screen that are changing quickly. It’s caused by the refresh rate (number of times in a given period that the image is updated) of your video card not matching the refresh rate of your screen. To solve this problem there are settings available to us to synchronize the refresh rates, only they don’t always work! EG: Compiz and Nvidia have Vsync settings, it doesn’t matter which one of these is enabled, or not, we can still get tearing.

Lots of threads talk about adding things like “userevents” “true” to our Xorg config (etc/X11/xorg.config), switching from Compiz to Mutter and so on, having tried all of these plus some, none of them work…..

For my system the following did work and it’s rather simple, which I like:

sudo apt-get install mplayer2 && smplayer    — this install Mplayer 2 and smplayer

sudo apt-get install vdpau-va-driver && libvdpau1    — This installs vdpau drivers designed by Nvidia, these help to offset some of the decoding and post-processing (making the image you see nicer than the raw decoded image) to the GPU (Graphical-Processing-Unit) instead of the CPU. Basically we’re telling our hardware that all things to do with graphics is to be done by the GPU, the CPU can get on with keeping the rest of the system working!

sudo gedit /home/user/.mplayer/config    — (user is of course whatever your home folder is called, EG: Fred)

Into that file add:




Save the file and exit (ao=pulse says to use pulseaudio, vo=vdpau says to use the vdpau-drivers during playback in Mplayer.)

Along with these I also have the following settings:

Nvidia-settings: Vsync=enabled, Allow-flipping=enabled, Compiz-compositor=enabled, Compiz-openGL=disabled.

Now I can play full 1080 films without any tearing at all. Hopefully this will help someone, or point them down the right road to tear-free film enjoyment, feel free to comment.