How do I stop video tearing? (Nvidia prop driver, non-compositing window manager)
I have that problem which seemingly afflicts many using the proprietary Nvidia driver:
Video tearing: fine horizontal lines (usually near the top of my display) when there is a lot of panning or action in the video.
(Note: switching back to the default nouveau driver is not an option, as its seemingly nonexistent power-management drains my battery several times faster)
I've tried Totem, Parole, and VLC, and tearing occurs with all of them. The best result has been to use X11 output
in VLC, but there is still tearing with relatively moderate action.
Hardware: MacBook Air 3,2 -- which has an Nvidia GeForce 320M.
There are two common fixes for tearing with Nvidia prop drivers:
Turn off compositing, since Nvidia proprietary drivers don't usually play nice with compositing window managers on Linux (Compiz is an exception I'm aware of). But I use an extremely lightweight window manager (Awesome window manager) which is not even capable of compositing (or any cool effects). I also have this problem in Xfce, where I have compositing disabled.
-
Enabling sync to VBlank. To enable this, I set the option in
nvidia-settings
and then autostart it asnvidia-settings -l
with my other autostart programs. This seems to work, because when I runglxgears
, I get:$ glxgears Running synchronized to the vertical refresh. The framerate should be approximately the same as the monitor refresh rate. 303 frames in 5.0 seconds = 60.500 FPS 300 frames in 5.0 seconds = 59.992 FPS
And when I check the refresh rate using
nvidia-settings
:$ nvidia-settings -q RefreshRate Attribute 'RefreshRate' (wampum:0.0; display device: DFP-2): 60.00 Hz.
All this suggests sync to VBlank is enabled. As I understand it, this is precisely designed to stop tearing, and a lot of people's problem is even getting something like
glxgears
to output the correct info. I don't understand why it's not working for me.
xorg.conf: http://paste.ubuntu.com/992056/
Example of observed tearing::
One thing to try that may work. Open nvidia-settings and go to the powermizer section. Choose "Maximum Performance" in the drop-down, and you should see your powermizer level jump to the fastest speed.
Once you've done that, try the video.
In the past, I've found that vsync doesn't work when the nvidia card is on the slowest powermizer setting.
If you are using dual monitors, the nvidia driver can only sync to the vblank of one of the displays unless they use exactly the same refresh rate. And I do mean exactly. This is effectively impossible unless both monitors are the exact same type. In case the nvidia driver is syncing to the wrong display (for example, syncing to the built in display when you want to watch a movie on the external TV) you can override it's choice. From the nvidia driver documentation:
When using __GL_SYNC_TO_VBLANK with TwinView, OpenGL can only sync to one of the display devices; this may cause tearing corruption on the display device to which OpenGL is not syncing. You can use the environment variable __GL_SYNC_DISPLAY_DEVICE to specify to which display device OpenGL should sync. You should set this environment variable to the name of a display device; for example "CRT-1". Look for the line "Connected display device(s):" in your X log file for a list of the display devices present and their names.
I have set this permanently in /etc/environment - just add something like this on a new line:
__GL_SYNC_DISPLAY_DEVICE="DFP-0"
I too was suffering from video tearing in my Intel sandy bridge processor. This worked for me. I put the following lines in "/etc/environment" -
CLUTTER_PAINT=disable-clipped-redraws:disable-culling
CLUTTER_VBLANK=True
and it worked. Press enter at the end and copy paste these lines. It may require restart. Try it.
Here is how I solved vsync issues for video on my ASUS K50IN notebook with the NVIDIA GeForce G102M. I am aware that your mileage may vary since the cards are different, but you can try it out... The trick for me was to use barebones MPlayer (but not MPlayer2!). It doesn't work with any of the other players.
-
Do the usual compiz magic in ccsm
- Under Composite turn off Detect Refresh Rate and enter your monitor's current one manually.
- I turned 'Copy to Texture' on, not sure if that helped or not.
- Under OpenGL: Tex. Filter - Best
- Sync to VBlank is on
- Unity Plugin: (not sure if this helped any, but it allegedly improves speed) Panel Opacity - 1.0000, same for Launcher Opacity. Dash Blur - Static
-
Do the usual nvidia-settings magic:
- Enable Sync to VBlank under both XVideo and OpenGL settings
- Set Image Settings to High Quality under OpenGL settings
- Under Display Configuration set your resolution manually, then set your refresh rate from Auto to your current refresh rate.
-
Install mplayer and vdpau (NOT mplayer2!!! This is new and experimental and, for me at least, was laggy with VDPAU)
- Packages: mplayer libvdpau1 vdpau-va-driver
-
Set up MPlayer (I have tried gnome-mplayer, too, but it doesn't have the same result as hard as I tried)
- Open the file ~/.mplayer/config or create it if you don't have it. You might also have to create the folder .mplayer. It should contain this:
[default] ao=pulse vo=vdpau
Change ao to alsa if you removed pulse audio.
Restart X by logging out/in again.
Try it out, YMMV as always. I have found that, especially in non-LTS releases or with beta drivers, this may not work anymore depending on the codec of the video.
This worked for me on an ATI radeon driver, so it might work for you:
Add a configuration file (e.g case /etc/X11/xorg.conf.d/20-nouveau.conf)
consisting of this:
Section "Device"
Option "EXAVsync" "True"
Option "GLXVBlank" "True"
Identifier "Nvidia card"
Driver "nouveau"
EndSection
EXA is the framework for compositing video; it doesn't seem to vsnc by default.
It might also be worth trying different software (e.g. vlc) to playback video.