Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Hardware & Software > Software players

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th June 2016, 22:45   #1  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
[GUIDE] Smooth playback with madVR and no Smooth Motion/Reclock

How to limit the number of drops/repeats with madVR and custom resolutions.

At a basic level, to reach a low enough number of drops/repeats, you need to:

* Increase your refresh rate in case of madVR reporting frames dropped
* Decrease your refresh rate in case of madVR reporting frames repeated.


You will discover that you don't need "perfect" 23.976 refresh rate for smooth playback, as the target refresh varies according to the different clocks in your system.

I simply explain how to do this the right way.


What follows is a guide that hopefully will allow you to maximise playback smoothness using a DirectShow based player with madVR.
Before we begin, I would like to express a heartfelt thank you to hannes69, the Kodi forums user that inspired me to learn this stuff and without whose help this guide would never have happened.

The problem: with PC based playback it's pretty hard to get perfectly smooth playback without the odd frame being repeated or dropped.

The reason this happens is that, unlike regular DVD/BD players, our machines use different clocks inside them. Tipically we are looking at three clocks being used in a PC: video, audio and system clock, with the first two being crucial for video playback.
Unfortunately, it's just a matter of luck for audio and video clock being in sync. When this doesn't happen, we have frames dropped or repeated during playback. More or less frequently according to how much audio and video clock are out of sync.

I think it's better to let madshi speak about this, quoting him from a 2013 post:
Quote:
Originally Posted by madshi
There are 3 clocks during video playback:

(1) System clock ("time").
(2) Video refresh rate.
(3) Audio hardware clock.

The system clock really doesn't have anything to do with video playback, but madVR uses it to measure and compare the other two clocks. Now it is possible (even probable) that the system clock is not perfect. But that's not a big problem because if it's e.g. slightly too fast, both video and audio clocks will be measured wrong in the exact same way, so everything's fine.

If the video and audio hardware clocks are "perfect", there should be no dropped or repeated frames (if your PC is fast enough). However, video and audio clocks are usually both imperfect. If both are imperfect in the same way (e.g. being 0.1% too fast), again there's no problem. But if the amount of "deviation from perfectness" of audio and video clocks is not identical then madVR has to either drop frames (video clock slower than audio clock) or repeat frames (video clock faster than audio clock) to make sure video and audio stay in sync.

The refresh rate as shown in the first line in the madVR OSD is madVR's measurement of the video clock, measured by using the system clock. The audio "deviation" in the madVR OSD shows how much the audio clock deviates from "perfectness", measured by the system clock. If e.g. the measured refresh rate is 24.24000Hz (1% too fast for 24.000 content) and the audio deviation is exactly 1%, too, then there should be no frame drops/repeats. If the video/audio deviation differs, there have to be drops or repeats.
In this post madshi gives us all the info we need to try and solve the problem, while acting on the video side. Acting on the audio side means resampling sound so as to "adapt" it to the video clock difference. It's what Reclock does, it's what Kodi does with "Sync to display" activated, it's what Sanear is scheduled to do in the future.

For people who want to bitstream, or who would prefer to leave their audio untouched even when decoding via software, Reclock is not an option, though.
This method acts on the refresh rate you send to your screen, taking into account the interaction between audio clock and video clock discrepancies, compared to the "ideal" refresh rate.

If you follow this procedure, results are not 100% guaranteed as I've discovered some inconsistencies on specific 59.940fps files (while hannes69 has everything working almost perfectly). Nonetheless, even for most problematic cases, we've managed to get the drops/repeats down to less than 1 every two hours. Which, in my book, qualifies as good enough (and for the grand majority of files we are instead down to 1 every 9 hours or more).

The first step is deciding which refresh rate you intend to operate on. I suggest working first on the resolution/refresh that accomodates the majority of content you watch. In the example provided we will use 2560x1440@50.000.

1) Download and install Custom Resolution Utility (CRU).

2) Visit Pixel Clock Calculator (PCC).

3) For CRU use the instructions provided by ToastyX in its release thread, linked above.

If you are using audio through HDMI or DisplayPort be sure to add the relevant extension block files in CRU, as explained in the above link. I quote from there below.
Quote:
For audio support, import one of these extension block files:
What I do is use CRU's Automatic LCD standard timings as a starting point, as those keep the right values for front porch/back porch/sync, setting resolution and refresh and then switching to Manual timings.
Then, using Pixel Clock Calculator I aim for the correct refresh, down to the 5th or 6th decimal (talking about the @ portion in data entry). Under "Maximum decimal places" insert 2, as that, unfortunately, it's the maximum precision offered in controlling the pixel clock in our GPUs.

Comparing the standard LCD timings offered by CRU, fill in the minimum blanking and maximum blanking. As a minimum I tend to use the value offered by standard timings, with 2-300 more pixels as a maximum. Being more precise requires knowing the exact specifications of the screen you are using and it's clearly beyond the scope of this guide. What I suggest is what I've been doing, nothing more.

Keep in mind this:

Active = visible pixels
Front porch + sync width + back porch = blanking
Active + blanking = total

These numbers are *important* if you want to preserve all bitstreaming formats, as they are carried in the "invisible" portion of the HDMI signal (if you're using HDMI, that is). As an example, CEA standard timings require front porch at 638 for 1080p24Hz and 528 for 1080p50Hz.
For the "Multiple" entry, I've found 2 for horizontal and 1 for vertical to be working for me on my plasma TV, while hannes69, on a PC monitor, can use 1 for both horizontal and vertica. Your situation might be different, you can only test here. Suggestion is to start with PCC defaults at 8 horizontal / 1 vertical and slowly decrease the horizontal value if you don't get precise enough results (ie. you don't get refresh rates close enough to what you'll need).

Once you have filled in all the numbers in PCC, hit submit query and find a set of values to use for a new custom resolution in CRU. The three values PCC offers are in line with CRU, so you can use horizontal total, vertical total and refresh (up to the third decimal position) in CRU's window.



Front porch and sync width will stay at the values coming from standard timings, back porch and blanking will vary according to the total values you'll input. Save, restart the driver, check that there are no wrong colors, shimmering pixels, distortion (if there are, choose different timings) and move to the following point.



In the example we aim for 2560x1440, with a refresh rate of 50.000Hz. PCC suggests 2720x1475 lines with a pixel clock of 200.60 MHz. Leading to a calculated refresh rate of 50.000Hz.

4) Find a video lasting at least 45 minutes and start playing it. Leave it playing for at least 30 minutes, more if you can (measurements will be more precise). Note: ReClock is known to produce inaccurate clock deviation figures, even when bitstreaming. For an accurate clock deviation, try Sanear or the default audio renderer.

5) After the prescribed amount of time, bring up madVR OSD (CTRL+J). Take note of the following values, if you want to be rigorous, you might want to start a spreadsheet (or txt, whatever suits you) with these info, name of the file, moment of the day you tested the file (ideally here you should note for how long the PC had been running before the test).

a) movie 50.000 fps (says source filter) - I've had one case where madVR erroneusly reported 23.970 for a 23.976fps file. If something like that happens, change the file, otherwise all calculations would be skewed.
b) 1 frame repeat every x.xx minutes/hours/days (this is the value we wil try to optimize, take note of drop or repeat here, as that's crucial). In the example we get 1 frame dropped every 56.21 minutes. That is 1 frame dropped every (56.21 x 60) = 3372.6 seconds. It appears the audio clock is extremely precise, while the video clock deviates somewhat.



To calculate the error we need to compensate for, the formula is:

1 / (number of seconds before a drop/repeat * movie framerate)

In the above example the formula becomes 1 / (3372.6 * 25.000) = 0.00001186028, that is 11.86028ppm.

To apply the compensation, we add to the refresh rate in case of frames dropped, we subtract from the refresh rate in case of frames repeated.
Given this, our compensated refresh rate in the example becomes:

50.000 * (1+11.86028ppm) ---> 50.000 * (1+0.00001186028) ---> 50.000 * 1.00001186028 = 50.00059301 (we approximate to the eight decimal here).

6) With the compensated refresh rate at hand, we go back to PCC and input it.

7) Now it's again to CRU where we input the new values (use the closer ones you manage to use with no distortion, wrong colors, etc.). For our example, we choose 2750 x 1541 with a pixel clock of 211.89MHz (it's not the closest one, but it's useful for showing you the possible iteration of the process), leading to a calculated refresh rate of 50.00058994Hz.

8) You go back to point 4 and check your new results. 45 minutes of playback and check. Ideally, you'll now find frame drops/repeats in the days range, if not "no frame drops/repeats expected".

9) In our case, instead, we get 1 frame drop every 11 hours.



We then decide to go back to 5 and try to compensate some more. With the calculations shown, we get that our error diminished and is now 1.01ppm. That is 1 / ((3600 * 11) * 25)) = 0.00000101. Since we have frame drops, we add to the previous refresh rate like this: 50.00058994 * (1+1.01ppm) = 50.00064044.

Going back to PCC we get a 2860 horizontal total, 1639 vertical total and 234.38 pixel clock custom resolution leading to a calculated refresh rate of 50.00063999. Not perfect but closer. By going back to 4, we get 1 frame drop every 18.15 hours. This is definitely in the "good enough" region, as it offers some serious margin for clock variations due to temperature, etc.



We could iterate some more or we could be luckier than in this example and have a more precise video clock/GPU/timings relation. The process remains the same. With this configuration the closer I managed to get was 1 frame drop every 1.02 days, with a calculated refresh rate of 50.00067942Hz.



Bear in mind that, during our experiments, we discovered that there are some "regions" where the GPU refuses to behave according to the input provided (lowering refresh when timings should make it rise, for instance). If you meet one of those regions, try working around it. Unfortunately, in cases like that, it becomes more a matter of trial and error than it would be ideal.

9) You can now calculate the factor by which the audio and video clock differ. 50.00067942, in our example, is the refresh rate that gives optimal results. The factor then is 50.00067942 / (2 * 25.00), using double the frame rate of the video being played back, as that's what's being displayed by madVR. The calculations gives 1.0000135884. The video clock, in this case, deviates by -13.588ppm, that is 1 - 1.0000135884.

10) You can now apply the factor calculated in the previous point to other refreshes needed. For 23.976, as an example, we would need to aim for 23.976 * 1.0000135884 = 23.97635580. As we discover our PC monitor doesn't accept such a low refresh rate, we double it. 47.952 * 1.0000135884 = 47.95265159. We go back to 3 and discover that with these values we have 1 frame drop every 17.43 hours.



Most definitely already in "good enough" territory, although we might want to iterate some more as shown above. Doing that, I managed to get to this:



Bear in mind that clock deviation can vary with temperature, so try and get the absolute best result possible as far as drops/repeats are concerned, as that will give you some headroom to handle clock variations due to long sessions playback, room temperature changes, etc. Feel free to take periodic measurements in order to better compensate for the most likely use case.

Again a big thank you to hannes69 for all the knowledge he shared with me.

Last edited by ashlar42; 18th July 2017 at 11:49.
ashlar42 is offline   Reply With Quote
Old 9th June 2016, 10:21   #2  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
312 views and not a single comment? Is the guide useful? Everybody knew this already (I've been looking for a "clean" solution to the problem for the past 10 years and never found a good write up)? Is this not the right place to post it? Is it a giant steaming pile of crap?
ashlar42 is offline   Reply With Quote
Old 9th June 2016, 11:50   #3  |  Link
QBhd
QB the Slayer
 
QBhd's Avatar
 
Join Date: Feb 2011
Location: Toronto
Posts: 408
Fear not, Some good info here... I sure most of us are just trying to find the time to actually fine tune their Custom Resolutions. I use the built in Custom Resolutions of Crimson and use ReClock, and I think this info here can help me fine tune to even better results than I got by fiddling around with trial and error :P

I will post again when I have the time to get to it.

QB
__________________
QBhd is offline   Reply With Quote
Old 9th June 2016, 18:59   #4  |  Link
pirlouy
_
 
Join Date: May 2008
Location: France
Posts: 592
Quote:
Originally Posted by ashlar42 View Post
312 views and not a single comment?
I was in those 312 views. Something bugged me. In the title, you mention bitstreaming. Isn't this past ? Bitstreaming seems pointless today. We can decode it with LAV filters libraries plus Windows can output 24 bits 96 kHz untouched (without exclusive mode).

For the display frequency, with 24Hz movie, I use 60Hz with smooth motion and I don't notice dropped/double frame.
For 25Hz movie, I use 50Hz, and I don't notice frames issues.

Plus your guide is to go from 1 frame lost every 45 minutes to 1 every 45 hours. So it's complicated for something you won't really notice (1 frame every 45 minutes).

Don't get me wrong. Your guide is very interesting, but it is essentially aimed at those who want perfect numbers. In real life, you can use madVR LAV filters and Windows DirectSound output and still get a smooth/perfect playback.

For those who want to tweak, it's really helpful.
__________________
Windows 10 x64; 1080p 60" TV, GTX 750; madVR, LAV Filters, MPC-HC
pirlouy is offline   Reply With Quote
Old 9th June 2016, 19:49   #5  |  Link
hannes69
Registered User
 
Join Date: Nov 2012
Posts: 54
Quote:
I use 60Hz with smooth motion and I don't notice dropped/double frame.
Of course smoothmotion is a valid solution for the given problem. Same as Reclock is a solution. But I consider both of these methods as a kind of "workaround" from a purist´s point of view. Both these methods work, but one alters video material, one alters audio material.
Why workaround when it can be done as it is supposed to be
It is supposed that a movie with a given framerate is being played back with the corresponding accurate refresh rate (multiple of the framerate). And if the underlying technology isn´t accurate enough but we can compensate that, it should be compensated
But of course I can understand that many people like to use practical solutions without fiddling around. Not everybody is built for perfection.
I am.

Quote:
Your guide is very interesting, but it is essentially aimed at those who want perfect numbers.
YES. The guide makes use of madvr which itself is made for perfection We all want results as good as possible. This guide is part of that philosophy...
hannes69 is offline   Reply With Quote
Old 9th June 2016, 23:51   #6  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
Maybe it's the fact that if I am actually *watching* something, I notice dropped/repeated frames always.

In any case, in the guide I specify it's not just for bitstreaming, do I not?

Quote:
For people who want to bitstream, or who would prefer to leave their audio untouched even when decoding via software, Reclock is not an option, though.
Of course, using Smoothmotion solves everything... But that modifies video, by design.
ashlar42 is offline   Reply With Quote
Old 10th June 2016, 14:21   #7  |  Link
huhn
Registered User
 
Join Date: Oct 2012
Posts: 4,108
think about a new thread name.

people usually understand something else under a guide for smooth playback.
or with other words the name sound like "yet another madVR guide"


maybe think about some information like "A LOT of TV's can't do proper 23/24P no matter what they are doing a 3/2 pullup".
huhn is offline   Reply With Quote
Old 10th June 2016, 18:31   #8  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
I don't think I can change the thread title. If a moderator has a better idea... be my guest.

Probably the title of the guide itself "How to limit the number of drops/repeats with madVR and custom resolutions." would be better. What do you think?
ashlar42 is offline   Reply With Quote
Old 10th June 2016, 18:41   #9  |  Link
huhn
Registered User
 
Join Date: Oct 2012
Posts: 4,108
i'm not good at this naming stuff but that would be a lot better.

but think about a shorter name. i guess.
huhn is offline   Reply With Quote
Old 10th June 2016, 23:28   #10  |  Link
Warner306
Registered User
 
Join Date: Dec 2014
Posts: 495
This is pretty complicated for a noob. You should spend some time defining all of the different timing parameters and explaining what they do (e.g. Front porch: definition, Blanking: definition, etc.).
Warner306 is offline   Reply With Quote
Old 11th June 2016, 14:14   #11  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
Quote:
Originally Posted by Warner306 View Post
This is pretty complicated for a noob. You should spend some time defining all of the different timing parameters and explaining what they do (e.g. Front porch: definition, Blanking: definition, etc.).
They would just complicate the guide, don't you think? As you don't interact and don't need to interact with all those other values to reach the objective.

Horizontal total, Vertical total, Pixel clock. That's it.

I could, I suppose, add a glossary at the end. But, again, incorporating it in the guide would lead people to believe they *need* to understand all that, while that's definitely not the case.
ashlar42 is offline   Reply With Quote
Old 12th June 2016, 00:56   #12  |  Link
CarlosCaco
Registered User
 
Join Date: Oct 2015
Location: Brasil, SP, São Paulo
Posts: 153
man this is great! but there´s a chance to make some solution for intel users... on intel custom resolutions theres no blanking control, the blanking is not showing at all turning things much much harder... we can calculate blanking by the total showed on the end in intels cp but its really hard to fine tune things...
worst is how custom resolution works, you can only make a 24 mode and intel automatic deliverys a 23.976 mode, same to 60 and 59.94 and 30 and 29.970...
__________________
Desktop, i5 2500, 8GB, N570 GTX TF III PE/OC
Asus X555LF, i7-5500U, 6GB Ram, Nvidia 930m/HD 5500
Windows 8.1 Pro x64
CarlosCaco is offline   Reply With Quote
Old 12th June 2016, 15:07   #13  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
For Intel you might want to have a look at this, that's been created with Intel GPUs in mind, if I recall correctly: http://www.clevertec.co.uk/productsfree.htm#dtdcalc with instructions here http://www.avsforum.com/forum/26-hom...orrection.html
ashlar42 is offline   Reply With Quote
Old 12th June 2016, 16:21   #14  |  Link
CarlosCaco
Registered User
 
Join Date: Oct 2015
Location: Brasil, SP, São Paulo
Posts: 153
This method don t work on intel modern gpus, a least on my two laptops don t work, but i can use intel custom resolutions on intel control panel with my tv on, but is much harder to fine tune than nvidia custom resolutions and cru
__________________
Desktop, i5 2500, 8GB, N570 GTX TF III PE/OC
Asus X555LF, i7-5500U, 6GB Ram, Nvidia 930m/HD 5500
Windows 8.1 Pro x64
CarlosCaco is offline   Reply With Quote
Old 12th June 2016, 18:38   #15  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
I'm sorry, I'm no expert at Intel's GPUs... Always had a dedicated GPU in my eleven years of HTPCing.
ashlar42 is offline   Reply With Quote
Old 15th June 2016, 01:22   #16  |  Link
river1
Registered User
 
Join Date: May 2010
Posts: 9
This is really helpful, now madvr says no frame repeat/drop expected
river1 is offline   Reply With Quote
Old 15th June 2016, 12:06   #17  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
Quote:
Originally Posted by river1 View Post
This is really helpful, now madvr says no frame repeat/drop expected
Cool! Thanks a lot for letting us know. While writing this I had this nagging doubt about nobody getting any real value out of it. Seeing people happy makes me happy as well.
ashlar42 is offline   Reply With Quote
Old 15th June 2016, 12:12   #18  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
I think it would be nice if this guide could be linked here: http://www.avsforum.com/forum/26-hom...rt-thread.html

I do not have a working account on AVS and the approval process is taking ages.

Another piece of info that might be of interest is about other video renderers. madVR gives us the crucial info needed to make this all work but, once we have the custom resolutions set up correctly... theoretically they should be of benefit to whatever video renderer one might choose. Kodi, for instance, in its default version, uses its own renderer. Do the results from this work carry on there? I've never tried (Kodi DSPlayer for me, plus MPC-HC with madVR) but it would be interesting to know.

Edit: I did a preliminary test with standard Kodi, DVDPlayer selected, and it seems to confirm that it works correctly. Two and a half hours with no frames lost or repeated.

Last edited by ashlar42; 21st June 2016 at 18:05.
ashlar42 is offline   Reply With Quote
Old 19th June 2016, 21:51   #19  |  Link
Warner306
Registered User
 
Join Date: Dec 2014
Posts: 495
Quote:
Originally Posted by ashlar42 View Post
I think it would be nice if this guide could be linked here: http://www.avsforum.com/forum/26-hom...rt-thread.html

I do not have a working account on AVS and the approval process is taking ages.

Another piece of info that might be of interest is about other video renderers. madVR gives us the crucial info needed to make this all work but, once we have the custom resolutions set up correctly... theoretically they should be of benefit to whatever video renderer one might choose. Kodi, for instance, in its defaul version, uses its own renderer. Do the results from this work carry on there? I've never tried (Kodi DSPlayer for me, plus MPC-HC with madVR) but it would be interesting to know.

Edit: I did a preliminary test with standard Kodi, DVDPlayer selected, and it seems to confirm that it works correctly. Two and a half hours with no frames lost or repeated.
Added to that AVS Forum link.
Warner306 is offline   Reply With Quote
Old 21st June 2016, 18:05   #20  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 268
Quote:
Originally Posted by Warner306 View Post
Added to that AVS Forum link.
Thanks Warner, didn't realize it was you.
ashlar42 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.