35

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:

  1. 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.

  2. Enabling sync to VBlank. To enable this, I set the option in nvidia-settings and then autostart it as nvidia-settings -l with my other autostart programs. This seems to work, because when I run glxgears, 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:: video tearing

4
  • can you pastebin.com your xorg.conf file please? Did you experiment with Option "TripleBuffer" "1" in your xorg.conf file?
    – fossfreedom
    May 16, 2012 at 12:23
  • I've tried TripleBuffer; it seems to help a bit, but not much. I'll pastebin my xorg.conf. May 17, 2012 at 9:34
  • Are you using dual monitors? May 21, 2012 at 1:19
  • Same issue in 12.10 with Flash in the browser, although no tearing in VLC that I can see, nor when dragging windows around. Did you find a solution since then? Apr 23, 2013 at 12:37

17 Answers 17

18

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.

3
  • Thank you! This worked for me using the proprietary nvidia driver (310.19) on Arch Linux. I've been trying to solve this for quite a while now. Such a strange issue.
    – Reid
    Dec 28, 2012 at 19:50
  • Is it possible to control this setting from the command line? So that I can enable it when I start a video player (and disable it after the player is closed)?
    – panzi
    Mar 21, 2014 at 17:08
  • 1
    Ah. nvidia-settings -a GPUPowerMizerMode=1 sets it to performance and nvidia-settings -a GPUPowerMizerMode=2 to auto.
    – panzi
    Mar 21, 2014 at 17:14
11

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"

1
  • Hi Alistair. Thanks for the suggestion, but I use only a single display. May 21, 2012 at 2:08
7

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.

2
  • 2
    Thanks for the suggestion, but these are Gnome3 environment variables (such as used by Gnome Shell). I use a very minimal window manager, so this does not apply to me. Additionally, I do not have a Sandy Bridge processor. Apr 30, 2012 at 23:33
  • This solution fixed the tearing problem I was having on the Cinnamon desktop (Mutter window manager) and nvidia 313 drivers on 13.04. Sorry for bumping an old post, but thank you.
    – askuhn
    Mar 30, 2013 at 14:03
4

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.

  1. 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
  2. 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.
  3. 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
  4. 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.

1

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.

1
  • 1
    As I mentioned in my post, switching to the default driver is not an option. Apr 26, 2012 at 6:12
1

Not sure if this will hepl you, but it worked for me. Open nvidia-settings and change the Frecuency from Auto to 60. And press apply. This solved my problems with the video tearing and the general desktop flickering. Sadly I have to do this each time I restart.

1
  • 1
    As I explained in my post, my display refresh rate is 60 Hz. As for your issue, follow this answer. Apr 30, 2012 at 23:28
1

I was experiencing the very same video tear problems. In my case I observed that tear down happens in fullscreen mode only. The problem seems to be at scaling the video to fullscreen. Whenever the original size of the video played and screen resolution ratios do not match there is tear down in the video. Setting the aspect ratio in smplayer to the displays aspect ratio fixed the problem for me.

e.g. I was playing a 1280x714 sized video in fullscreen there was tear in the video. As I forced the aspect ratio of the video to 16:9 the playback was smooth.

I have to note that the root cause of the problem stays there and is annoying. Since the aspect ratio is not kept original, there will be some deformation in the video. However it is better to watch without tears ;)

1

I use Ubuntu 12.04LTS 64bit and I have an nvidia gtx 660ti.

I was suffering from video tearing for over a month until I found a solution.

Open nvidia x server settings-->PowerMizer-->PowerMizer Settings (near the bottom), and where it says, "Prefered Mode," change the setting from Adaptive to Prefer Maximum Performance.

1

Upgrading to version 319 from PPA solved the problem:

If after boot, it runs in failsafe mode go into recovery and run sudo nvidia-xconfig. Happy video playing!

0

If you're not using dual monitor there's another possibility. There are two different kinds of sync to vblank: One for XVideo and one for OpenGL. In nvidia-settings, one is under "X Server XVideo Settings" and the other is under "OpenGL/Settings". Which one actually affects your video playback software may depend on which output plugin it is using.

1
  • VLC has options for those two outputs and I've tried them both. May 21, 2012 at 2:09
0

I am unsure from your description whether you are actually seeing tearing; normally, tearing looks like the picture is split horizontally into two or three sections, with the parts not matching up. This happens because the top part of the picture and the bottom part are not coming from the same frame in the video. Wikipedia has a good simulated example of screen tearing. Fine horizontal lines sounds different, more like combing artifacts from poor de-interlacing, although maybe it is just hard to describe.

You don't mention any details of the video you are trying to watch, such as its resolution, encoding, and if it is interlaced or progressive, and whether you have de-interlacing turned on in VLC. It might also be worth checking if the video processing is being offloaded to the GPU, or whether the CPU is doing all the work. Have you confirmed that you can successfully view the same video on different hardware, or on the MacBook using OS X?

You say you've tried with compositing disabled on XFCE, but it probably wouldn't hurt to try adding:

Section "Extensions"
    Option "Composite" "Disable"
EndSection

to your /etc/X11/xorg.conf just to be sure. Also, one other suggestion not mentioned so far is to add:

Option "UseEvents" "True"

to the Device or Screen sections of your xorg.conf.

UPDATE:

The attached screenshot definitely shows tearing! If the player is otherwise keeping up with decoding the video (ie, no stuttering slow downs, just the tearing), then it probably doesn't matter if it's the CPU or GPU doing the decoding. VLC has an option on the Video settings page in Preferences to turn on and off "Accelerated video output"; if it's on, it ought to be using the GPU to decode. If you toggle that setting in VLC and run top in a terminal whilst playing the video, you should see a difference in CPU usage between the two settings. You could also try turning off any de-interlacing in VLC to see if that makes a difference.

I have two other suggestions:

I don't see anything obviously wrong with your xorg.conf, but you could double-check that both sync to vblank settings (on X Server XVideo Settings and OpenGL Settings) are stored correctly in .nvidia-settings-rc. Some people run nvidia-settings as root or using gksudo (so it can update /etc/X11/xorg.conf), but this can result in the settings being stored in /root/.nvidia-settings-rc rather than ~/.nvidia-settings-rc. It ought to be picking up your own copy, but to avoid any doubt, you should check both vblank settings when running nvidia-settings as you; don't forget to hit "Save Current Configuration" on the bottom page of settings. If you run:

nvidia-settings -q=XVideoTextureSyncToVBlank -q=SyncToVBlank

then you should see both settings are set to 1. You should probably also check that however you auto-loading the settings is working by rebooting and running the above command again.

The other thing you could try would be to upgrade/downgrade your nvidia drivers. I have experienced tearing with some minor driver version updates before; there are definitely "good" and "bad" versions of the nvidia drivers and the latest are not always the best. You can try upgrading using the X-swat PPA:

https://launchpad.net/~ubuntu-x-swat/+archive/x-updates

And you can try downgrading to an earlier version available for 12.04:

https://launchpad.net/ubuntu/precise/amd64/nvidia-current or https://launchpad.net/ubuntu/precise/i386/nvidia-current

depending on whether you have amd64 or i386 installed. Click on the version number to the right that you want to try, download the .deb file and then install with:

sudo dpkg --install <name of file>.deb

For example, due to an unrelated nvidia bug, I had to download this:

http://launchpadlibrarian.net/90395807/nvidia-current_290.10-0ubuntu2_amd64.deb

from

https://launchpad.net/ubuntu/precise/amd64/nvidia-current/290.10-0ubuntu2

and installed it using:

sudo dpkg --install nvidia-current_290.10-0ubuntu2_amd64.deb

One other tiny point: one other answer mentions changing the refresh rate from Auto to 60Hz, and you say that it is already set to 60Hz. However, your attached xorg.conf has nvidia-auto-select in metamodes (in the Screen section), which suggests it is not fixed. However, your Monitor definition only offers 60.0, so maybe this is inconsequential. It might be interesting to back up and move your xorg.conf, and re-run nvidia-xconfig and nvidia-settings to see if you get a different config.

5
  • Hi David. I've uploaded an image of my alleged tearing :-) Please tell me if it matches "tearing". It happens pretty much on any video I watch, so I didn't think it was worth getting into specifics. Do you have any suggestions of what to test on specifically? I've tried those options (and subsequently removed them), but perhaps there's some combination I should try? If you can look at my pasted xorg.conf, let me know if there is anything seemingly amiss. How do I check if the GPU is not doing the work? Finally, yes the same videos never have an issue in OS X on the same machine. May 21, 2012 at 21:25
  • The nouveau driver doesn't seem to have the same problem. The only thing I was able to diagnose that seems different is that with nouveau the FPS is about 600 without any additional configuration needed by me. May 21, 2012 at 21:27
  • Yes, that does look like tearing. Sorry to doubt :-) May 22, 2012 at 7:55
  • I have added further suggestions based on your feedback. May 22, 2012 at 8:52
  • Unfortunately, no luck. I think maybe the only thing to do is wait for Nvidia to improve support for the GeForce 320M, although I wonder why Nouveau has no issues. May 30, 2012 at 14:14
0

In addition to David previous post: if you want to install latest NVidia proprietary drivers using X-swat PPA, you can also add it to your apt sources:

sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current

This will install latest version and keep you up to date regarding their deliveries.

0

Sorry this answer is somewhat for openSuSE, not Ubuntu, but I did finally get it working with these changes,

  • Disable compositing / window effects temporarily (alt+shift+f12 in openSuSE)
  • Use VLC with the "Video" setting set to "OpenGL video output (experimental)". "Accelerated video output (Overlay)" is also checked for me. I'm using VLC 2.1.1 if it matters.
  • Set the PowerMizer settings to performance, as in mjnichol's answer
  • Set the OpenGL settings to high, as in Amir Dizdarević's answer

Hope it helps! I imagine there's some setting to make it work with compositing, but I recommend at least disabling compositing for testing. My setup is a 4K monitor and GTX 650 graphics card.

0

You can fix this for VLC by changing video output to "OpenGL GLX".

0

I am running 64-bit Elementary OS Luna (based on Ubuntu 12.04 LTS) and I had the same problem. Searching around, I finally found a method that WORKS and obviously it does include the "Powermizer settings to Performance" solution, as a lot of other peaople have already said.

The problem is that after restart these settings get restored to the default "Auto" setting and apparently the Nvidia-Settings application does not save properly the new settings of Powermizer. NOT TO WORRY!!!

JUST FOLLOW THE INSTRUCTIONS BELOW, IT'S SOOOOO SIMPLE:

http://ubuntu.aspcode.net/view/635400140124705175636416/nvidia-settings-powermizer-performance-mode-on-12044-64-bit

As the article says, make a Startup Application and you're good to go!!!! TRUST ME IT WORKS!!! Many thanks to Aquablue for posting this and of course, to Mike from Nvidia Customer Care who provided the solution!!!

FYI, I have a Phenom II X4, 8GB DDR3 RAM, Corsair SSD, GTX 650, Elementary Luna 64-bit.

0

I could pick the window with my cursor, move the window, and it fixed the tearing. So is seems like some callback issues in X.

For me the vlc fix was:

vlc -> tools -> preferences -> video -> in the 'output' dropdown choose x11 video output(XCB)

-2

It seems that you are running some lightweight window manager (presumably openbox). If that is the case, it is possible that you are using xcompmgr as a composite manager to get desktop effects such as shadows, transparencies, etc. In my case, turning xcompmgr off solved this same issue: tearing while watching videos, specially those in HD (which are CPU intensive). Apparently, tearing occured because of a bug in xcompmgr, which is a longly abandoned project. To turn off xcompmgr you can execute "killall xcompmgr". That should work. Hope it helps! Saludos! Pablo.

1
  • It doesn't seem like you read my post very carefully. Incidentally, you shouldn't have to kill xcompmgr. Just don't start it in the first place. May 22, 2012 at 3:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .