Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
    
can you pastebin.com your xorg.conf file please? Did you experiment with Option "TripleBuffer" "1" in your xorg.conf file? –  fossfreedom May 16 '12 at 12:23
    
I've tried TripleBuffer; it seems to help a bit, but not much. I'll pastebin my xorg.conf. –  Chan-Ho Suh May 17 '12 at 9:34
    
Are you using dual monitors? –  Alistair Buxton May 21 '12 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? –  faB Apr 23 '13 at 12:37
add comment

15 Answers 15

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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!

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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 '12 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 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 at 17:14
add comment

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.

share|improve this answer
    
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 Suh May 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 Suh May 21 '12 at 21:27
    
Yes, that does look like tearing. Sorry to doubt :-) –  David Edwards May 22 '12 at 7:55
    
I have added further suggestions based on your feedback. –  David Edwards May 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 Suh May 30 '12 at 14:14
add comment

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.

share|improve this answer
    
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. –  Chan-Ho Suh May 22 '12 at 3:24
add comment

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.

share|improve this answer
    
VLC has options for those two outputs and I've tried them both. –  Chan-Ho Suh May 21 '12 at 2:09
add comment

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"

share|improve this answer
    
Hi Alistair. Thanks for the suggestion, but I use only a single display. –  Chan-Ho Suh May 21 '12 at 2:08
add comment

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.

share|improve this answer
    
As I explained in my post, my display refresh rate is 60 Hz. As for your issue, follow this answer. –  Chan-Ho Suh Apr 30 '12 at 23:28
add comment

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.

share|improve this answer
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. –  Chan-Ho Suh Apr 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. –  askuhn Mar 30 '13 at 14:03
add comment

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.

share|improve this answer
1  
As I mentioned in my post, switching to the default driver is not an option. –  Chan-Ho Suh Apr 26 '12 at 6:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.