How to watch videos smoothly with no stutter and no tearing

Post tutorials, HOWTO's and other useful resources here.

How to watch videos smoothly with no stutter and no tearing

Postby fulalas » 09 Nov 2016, 05:07

This tutorial probably works only for Nvidia cards on XFCE, but you may try on a different setup and check if it works for you.

I'm coming from Windows where I was using Media Player Classic + EVR render + Reclock, a combination that works flawlessly. I had to spend some time on Linux until I had everything working so I want to share with you. I hope you can get everything working too. :)

---Mpv + SMPlayer---
We need to pick a good player that syncs the FPS of the video file with the refresh rate of the display, so Mpv (a fork of MPlayer) is the answer -- up to this moment MPlayer can't handle this. You can download Mpv xzm package here. Although it's an excellent player, it lacks a good GUI, but we can use SMPlayer as a front-end. Here's a link to SMPlayer xzm package.

After installing both, open SMPlayer and go to Options -> Preferences -> General -> Multimedia engine and select 'mpv'. In Advanced -> MPlayer/mpv -> Options you should put this: --video-sync=display-resample (a really good explanation here: https://github.com/mpv-player/mpv/wiki/ ... ronization). In my experience (i7 860 + GTX 650 Ti) I noticed that audio is a little bit out of sync with this configuration, so I also put this: --audio-delay=0.08

Also, we need to disable XFCE display compositor on 'Window Manager Tweaks' settings.

---Nvidia driver---
You can skip this section if everything works for you. But if you still can't get rid of tearing, try to put this command on Section "Screen" inside the file /etc/X11/xorg.conf (or usb stick/porteus/rootcopy/etc/X11/xorg.conf if you want to persist after boot):
Code: Select all
   Option  "metamodes" "nvidia-auto-select +0+0 { ForceCompositionPipeline = On }"


---Linux Mesa driver (i.e. non-Nvidia official)---
In my experience the native XFCE compositor doesn't run on fullscreen even using Mpv parameter --x11-bypass-compositor=never, which is a pity once outside fullscreen everything works flawlessly. So I had to pick another compositor called Compton.

After installing Compton you need to create an empty file /home/guest/.config/compton.conf (if you're not using 'guest' as your current user, change the path accordingly), and put this inside:
Code: Select all
backend = "glx";
paint-on-overlay = true;
glx-no-stencil = true;
glx-no-rebind-pixmap = true;
vsync = "opengl-swc";


Open a terminal and execute: compton. You'll notice that windows now move smoothly. If not, you have to try another vsync method, like 'opengl' (see Compton's documentation about vsync here: https://github.com/chjj/compton/wiki/vsync-guide). After choosing the right vsync method don't forget to put Compton to auto execute on boot.

If you still notice some tearing, try this on SMPlayer -> Options -> Preferences -> Advanced -> MPlayer/mpv -> Options: --x11-bypass-compositor=never

---Notes---
Of course, before opening a video you should set your display refresh rate to a value that is a multiple (or at least as close as possible) of the video file. Ex.: your video file has 23.976 FPS so you should set your display to 24 Hz, or you have a video file with 25 FPS so you should set your display to 50 Hz.

If you have an old machine you can try a different Mpv render. To change it you have to open SMPlayer and go to Options -> Preferences -> General -> Output driver and finally select the render you want ('opengl' is Mpv's default). I did some quick testing on and old machine with a Intel Pentium dual-core + IntelHD graphics and 'vaapi' seems to be the best render.

---Future upgrades---
If someone finds a way to keep XFCE compositor on during fullscreen, it would be great to add this information here. :good:
Last edited by fulalas on 13 Feb 2017, 14:59, edited 2 times in total.
fulalas
Contributor
Contributor
 
Posts: 418
Joined: 26 Oct 2016, 16:34
Location: Brazil
Distribution: Porteus

Re: How to watch videos smoothly with no stutter and no tear

Postby fulalas » 13 Feb 2017, 14:38

If you have an Intel graphic card, you can enable vsync by doing this:

Create a text file called 20-intel.conf inside the path usb stick/porteus/rootcopy/etc/X11/xorg.conf.d. Open the file and just put this:

Code: Select all
Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"
   Option      "AccelMethod" "SNA"
   Option      "TearFree"    "true"
EndSection


Now you just need to reboot. :good:

Although it solves tearing with both Mpv videos and Linux GUI (LXQt tested), it seems that Youtube videos like this drops a lot of frames even at full screen, introducing an annoying stutter.
fulalas
Contributor
Contributor
 
Posts: 418
Joined: 26 Oct 2016, 16:34
Location: Brazil
Distribution: Porteus

Re: How to watch videos smoothly with no stutter and no tear

Postby Bogomips » 13 Feb 2017, 17:24

^ Watched above video more than half-way through in kde5 with the nvidia 304 driver, and did not notice any aberrations. :roll:
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
Bogomips
Full of knowledge
Full of knowledge
 
Posts: 2378
Joined: 25 Jun 2014, 16:21
Location: London
Distribution: 3.2.2 Cinnamon & KDE5

Re: How to watch videos smoothly with no stutter and no tear

Postby fulalas » 14 Feb 2017, 04:48

Bogomips wrote:^ Watched above video more than half-way through in kde5 with the nvidia 304 driver, and did not notice any aberrations. :roll:

Great! I'm not that lucky. :( You know that saying 'short blanket'? It's a Brazilian expression referring to something that you fix here and it creates a problem there. With Nvidia cards I managed to get rid of tearing only inside full screen. With Intel HD cards there's no tearing at all not matter where, but the blanket is short and so I have too much stutter inside Youtube (inside and outside full screen). :unknown:
fulalas
Contributor
Contributor
 
Posts: 418
Joined: 26 Oct 2016, 16:34
Location: Brazil
Distribution: Porteus

Re: How to watch videos smoothly with no stutter and no tear

Postby Bogomips » 14 Feb 2017, 16:03

Ever considered possibility that scripts could be tearing up your picture? Try closing your browser and pasting the URL into a player like VLC or SMPlayer, and maybe could be a difference. :)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
Bogomips
Full of knowledge
Full of knowledge
 
Posts: 2378
Joined: 25 Jun 2014, 16:21
Location: London
Distribution: 3.2.2 Cinnamon & KDE5

Re: How to watch videos smoothly with no stutter and no tear

Postby fulalas » 15 Feb 2017, 05:00

Bogomips wrote:Ever considered possibility that scripts could be tearing up your picture?

Hmmm... What kind of scripts?

Bogomips wrote:Try closing your browser and pasting the URL into a player like VLC or SMPlayer, and maybe could be a difference. :)

Yeah, downloading the video and watching it through SMPlayer + Mpv is flawlessly. That's what I've doing. :)
fulalas
Contributor
Contributor
 
Posts: 418
Joined: 26 Oct 2016, 16:34
Location: Brazil
Distribution: Porteus

Re: How to watch videos smoothly with no stutter and no tear

Postby Bogomips » 15 Feb 2017, 13:10

fulalas wrote:Hmmm... What kind of scripts?
Javascripts that the browser is running on your behalf, which are no use to you whatsoever! Scripts written by people who don't give a damn about your cpu, scripts written by mediocre programmers, buggy scripts, scripts of an invasive nature which watch your every mouse move and report back, NSA scripts, and those of other governments' governmental agencies, etc. etc. If you have 8 or 9 tabs open you could be running around 100 scripts or more. :twisted:
Starting out in Porteus 3.2.2 (A Guide)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
Bogomips
Full of knowledge
Full of knowledge
 
Posts: 2378
Joined: 25 Jun 2014, 16:21
Location: London
Distribution: 3.2.2 Cinnamon & KDE5

Re: How to watch videos smoothly with no stutter and no tear

Postby fulalas » 16 Feb 2017, 03:49

Bogomips wrote:
fulalas wrote:Hmmm... What kind of scripts?
Javascripts that the browser is running on your behalf, which are no use to you whatsoever! Scripts written by people who don't give a damn about your cpu, scripts written by mediocre programmers, buggy scripts, scripts of an invasive nature which watch your every mouse move and report back, NSA scripts, and those of other governments' governmental agencies, etc. etc. If you have 8 or 9 tabs open you could be running around 100 scripts or more. :twisted:
https://forum.porteus.org/viewtopic.php ... 954#p52940

I see, but I don't think this is the problem since when I pause the video the CPU usage drops to almost 0%.
fulalas
Contributor
Contributor
 
Posts: 418
Joined: 26 Oct 2016, 16:34
Location: Brazil
Distribution: Porteus


Return to Tutorials



Who is online

Users browsing this forum: No registered users and 1 guest