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

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.

16 Answers
16

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:

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.
–
Chan-Ho SuhApr 30 '12 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.
–
askuhnMar 30 '13 at 14:03

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.

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.

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 ;)

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.

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:

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.

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.
–
Chan-Ho SuhMay 21 '12 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.
–
Chan-Ho SuhMay 21 '12 at 21:27

Yes, that does look like tearing. Sorry to doubt :-)
–
David EdwardsMay 22 '12 at 7:55

I have added further suggestions based on your feedback.
–
David EdwardsMay 22 '12 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.
–
Chan-Ho SuhMay 30 '12 at 14:14

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!!!

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!!!

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.