Saturday, January 28, 2012

Playing video on 60 FPS (Update 2)

So you had played games on your PC on 60 FPS, your eyes had been used to it and you are sick of the console frame rate that capped on 30 FPS. And on top of it, you got yourself a 60 Hz capable monitor yet you are playing your HD video collection on the native NTSC (23.976) or PAL (25.000) frame rate. However, not all of us are financial capable enough to purchase a 120Hz HDTV. If you ever had question on whether it is possible to play those HD videos that you treasured so much on your beloved 60 Hz monitor, ask no further as it is possible, provided that you have a decent processor (Core 2 Duo and above).



Changes:
  1. Added some screenshots in the steps. 
  2. Added additional step (step 4) to configure MPC-HC video player.
  3. Consolidate the AviSynth script into a single script.
  4. Explain some bits of details about the scripts.
  5. Added the third alternative approach to achieve the same result using Smooth Video Project (SVP).

The following guides had been compiled for general audience.

Step 1: Download and install

1. Download and install K-Lite Mega Codec Pack 8.1.0 and above. When prompted, just select FULL installation.

2. Download and install Avisynth 2.5.8.

3. Download the Avisynth MT (Multi-threating pack)


This will allow multi-threading. Extract the archive and put the avisynth.dll in your C:\Windows\system32 (for 32-bit OS) folder or SysWOW64 (for 64-bit OS). You should be prompted to replace the existing file if you had placed it in the correct folder.

4. Download the MvTools2 (version 2.5.11.3 as of current).

The link is at the bottom of the page. Place it in your AviSynth plugin directory, e.g: C:\Program Files\AviSynth 2.5\plugins or C:\Program Files (x86)\AviSynth 2.5\plugins (for 64 bit OS).

Step 2: Customizing ffdshow Avisynth plugin

a) Go to ffdshow video decoder configuration window (Start > Program Files > K-Lite Codec Pack > Configuration)

b) Under the Codec tab on the left column and then the Decoder column, make sure AviSynth format is using 'AviSynth' (default is disabled) and Raw video is set as 'all supported'.

Codecs settings

c) Next go to AviSynth tab and ONLY tick the following settings:

- AviSynth
- 3:2 Pulldown: Ignore pulldown
- Input colorspaces: YV12
- Buffer back/ahead: 0 10 (the first value is the number of used frames to keep in buffer and the second value is the number of used frames to buffer ahead). Note that the first value must be greater or equal to the second value, not vice versa.


AviSynth settings



d) Go to the Output tab and verify that 'High quality YV12 to RGB conversion' is ticked. Verify the same setting also in the RGB conversion tab just below the Output tab.

RGB conversion settings
Output settings

Step 3: Inserting AviSynth script

Go to the AviSynth tab page in ffdshow video decoder setting and copy and paste the AviSynth script below.

E.g.


AviSynth Script

SetMTMode(1,0)
ffdShow_source()
SetMTMode(2)
super=MSuper(pel=1, hpad=0, vpad=0, rfilter=4)
backward_1=MAnalyse(super, chroma=false, isb=true, blksize=16, searchparam=3, plevel=0, search=3, badrange=(-24))
forward_1=MAnalyse(super, chroma=false, isb=false, blksize=16, searchparam=3, plevel=0, search=3, badrange=(-24))
backward_2 = MRecalculate(super, chroma=false, backward_1, blksize=8, searchparam=1, search=3)
forward_2 = MRecalculate(super, chroma=false, forward_1, blksize=8, searchparam=1, search=3)
backward_3 = MRecalculate(super, chroma=false, backward_2, blksize=8, searchparam=0, search=3)
forward_3 = MRecalculate(super, chroma=false, forward_2, blksize=8, searchparam=0, search=3)
MBlockFps(super, backward_3, forward_3, num=60, den=1, mode=0)
SetMTMode(1)
GetMTMode(false) > 0 ? distributor() : last


Some explanations about the script:
Line 1 
SetMTMode(1,0)

This line is used to set the multithreading (MT) mode. The number '1' denotes the MT mode (there are a total of 6 modes which will explained below) and the number '0' means to use all available cores. If you would like to use only x number of cores, just changed the number 0 to x. For example, if I wanted to use 2 cores, this line would be SetMTMode(1,2)


Listed below is the description for each mode. Normally mode 2 and mode 3 works just fine.

Mode 1 is the fastest but only works with a few filter.
Mode 2 should work with most filters but uses more memory.
Mode 3 should work with some of the filters that doesn't work with mode 2 but is slower.
Mode 4 is a combination of mode 2 and 3 and should work with even more filter but is both slower and uses more memory
Mode 5 is slowest but should work with all filters that don't require linear frameserving (that is the frames come in order (frame 0,1,2 ... last).
Mode 6 is a modified mode 5 that might be slightly faster. 

Source: http://avisynth.org/mediawiki/Internal_functions/Multithreading_functions 

Line 4
super=MSuper(pel=1, hpad=0, vpad=0, rfilter=4)

The pel=x number dictates the accuracy of the estimation values being 1, 2 and 4. If you have less than 60% cpu usage, you might consider increasing the pel value. Vice versa for freeing up some cpu without changing scripts. Overall, cpu usage should not go over 80~85% otherwise frames will get dropped. To cut things short, the higher the value of pel, hpad, and vpad, the greater the quality of the outputted frames. Typically the following settings should work just fine.

super=MSuper(pel=2, hpad=4, vpad=4, rfilter=4)


You might notice a considerable high CPU load when changing the pel value to 4 when playing 1080p videos.What this means is that you will notice a huge number of frames that are being dropped, hence lagging frames. However, 720p videos works fine under the same settings.




Third line from last line
MBlockFps(super, backward_3, forward_3, num=60, den=1, mode=0)

The num=xx value is the outputed framerate. Since our desired framerate is 60 FPS, it is common sense to change this num to 60.


Step 4: Configuring Media Player Classic-Home Theater (MPC-HC)
Since this guide is created to use MPC-HC as the default media player, it is essential to configure it properly so that it uses ffdshowvideo decoder instead of the internal filter.

a) Configure MPC-HC to use Haali Video Renderer.

Go to View > Options. Under the output tab and in the DirectShow Video section, select Haali Renderer.

MPC-HC output settings

b) Now configure MPC-HC to bypass all internal and external filters.

Go to both Internal Filters and External filters settings and untick all options.
MPC-HC internal filters settings


Step 5: Verify that the video is playing @ 60 FPS.

a) Go to View > Statistic under Media Player Classic (or press Ctrl+4). Desired result is the frame rate
shows 60 and the number of frames dropped is 0 or very minimal.



Alternative solution 1: using the framedouble plugin (48 FPS instead of 60 FPS)
*Note that the effects might not be so prominent compared to the AviSynth, it's purely subjective.

1) Go to ffdshow video encoder configuration page and then navigate to Deinterlacing tab.

2) On the right pane window, tick 'Deinterlacing', 'Process whole image', and 'Process frames tagged as progressive'. Under the 'Method' drop down menu, select Framerate double.  

Deinterlacing settings

3) Hit Apply and OK.

Alternative solution 2: use Splash Pro media player.

You can try out this media player that uses their own proprietary technique to render the smooth image. The PRO version is trial though.

http://mirillis.com/en/downloads/downloads_splashpro.html

Alternative solution 3: Smooth Video Project (SVP) 

I will not cover this topic as it deviates from the intent of this post. In short, SVP achieve the same results with AviSynth without using AviSynth.


http://www.svp-team.com/wiki/Main_Page

---

The guide is compiled from the following source. All credits goes to the author:

6 comments:

  1. All movies on my computer looks amazing because of this.
    Thanks man !

    ReplyDelete
  2. It keeps saying "Script error: There is no function named 'MSuper' (ffdshow_filter_avisynth_script, line 4)"

    I have done everything right and downloaded every version of everything you are using and copied all the files to folders, my other problem was out the ffdshow Output tab there was place to check High Quality YV12 -> RGB Conversion (But there was a box in RGB Conversion tab)

    ReplyDelete
  3. Hi, I'm having a problem when I fast forward or back forward using the time slider on media player classic.
    When I fast/back forward the first time it works well, but when I tried it again under 10 seconds from the first I fast/back forward, It played 3-6 seconds frame from the time I first jumped into.

    So I'm watching a video until 10:00
    First jump I fast forward into 12:30 (it played from 12:30) OK
    second jump (under 10s from 1st) I fast forward into 15:00 (it played from 12:30 for 3-6 seconds, than continue to play 15:07)
    3rd, 4th, 5th,...... is the same with second jump

    So where is the problem and how do I fix it?
    THanks

    ReplyDelete
  4. ///

    I spent years waiting for find something like this.

    Thank you !!!!!


    Saludos ;)

    //////

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. nice guide, but how can i reduce artifacts in fast sences??

    ReplyDelete

If you found this article or post helpful to you, feel free to enter your comments below ;)