Welcome to HD blog with some random geek stuffs.

Underwater shader (Archive)

Comments are closed
Here a little shader that I have wrotten a while back. It uses fractional Brownian motion for caustics, some color shift depending on depth and height for water effect, and vertex displacement for waving effect (It's not physically realist, but funny).



Play video at 50fps with SVP (Smooth Video Project)

Comments are closed
SVP is a little software that improves the smoothness of a video by increasing the number of images per second displayed.
In short, SVP estimates scene's movements with a grid, and configure a filter to render the video, but this operation can take a lot of ressources (especially on a laptop or low end hardware).
These are my configurations to decrease CPU and GPU consumption.


Principle

The default configuration of SVP converts a video frame rate to screen frame rate, which are most of the time respecively 24 fps and 60fps.

To do so it matches every set of 2 video frames to 5 screen frames by either :
  • generates 3 interpolated frames and display 2 original frames, which will result in an uneven smoothness.
  • generates 4 consecutive interpolated frames, display the first original frames and drop the second. It achieves a better smoothness at the cost of a higher resource consumption and more visible artifacts (SVP uses a grid to estimate movements which can be visible on some complex scene, the more SVP generates frame, the more these artifacts are visible)

To avoid these problems, I use a screen frame rate of 50Hz which is almost the double of the video frame rate, and then I speed up the playback a little bit.
With these little tricks, only half of the frame displayed are interpolated, which reduce artifacts, result to a low cpu workload, and an even smoother playback.

Installation

First you need to install SVP dependancies :


The filter used by SVP :

  • aviSynth (decompress the library in C:\Windows\SysWOW64, it's a special version made for SVP)

The newer version of SVP is the V4, but I didn't see any visual improvement from V3 and it removes the advanced configuration panel we'll need. The 3.1.7a provide better performance than previous versions, but doesn't provide full installation (detailed here).


Then some MPC plugins :

  • ffdShow (Install only the raw video filter used to decode video with SVP)
  • MadVr (extract in installation location and execute install.bat, it's a video renderer for MPC that allows us to speed up playback a little bit)
  • ReClock (just do the minimal installation, it will play the audio at the same speed of the video)

And the the video player we'll use :


Initial configuration

First you need to configure MPC to use ffdShow filter :

  • options -> external filter -> add filter -> ffdShow raw filter and then put the filter option at "prefered"
  • options -> internal filter -> video decoder -> Hardware decoder to use -> DXVA2 (copy-back)

Now verify the installation by playing a video and start SVP manager. The icon of SVP should turn gray, and a message in the video should indicate SVP status during few seconds. The video playback may take few second to stabilize (SVP take a lot of resources and can take 100% of the CPU while the player is buffering the beginning of the video)

Optimisations

Screen Configuration :

  • It depends on your system, use 50Hz refresh rate.

Configure MPC to use MadVr and ReClock :

  • options -> playback -> output -> madVr
  • options -> playback -> audio output -> ReClock

Restart MPC. Now You can read advanced statistics from madVR in MPC with Ctrl-J shortcut.

MadVr Configuration :

  • scaling algorithms -> croma upscaling -> Bilinear
  • scaling algorithms -> image downscaling -> Bilinear
  • scaling algorithms -> image upscaling -> Bilinear

These options are less nicer than the default, but a lot faster on low end hardware, rendering time should goes from ~10ms to ~1ms in statistics.

For some reason fullscreen drops frames, here a little fix :

  • rendering -> general settings -> uncheck "enable automatic fullscreen exclusive mode"

With SVP the frame rate is less stable, more frames should be calculated in advance :

  • rendering -> windowed mode -> how many video frames shall be presented in advance -> 8

ReClock Configuration :

  • Audio settings -> Quality -> best Sinc Interpolation (It improves quality and is almost free)
  • Video settings -> Speed change of media with PCM audio -> Maximum Speedup -> 10%

It allows ReClock to speed up playback a little bit faster. Its icon in the taskbar should turn green while playing.

SVP Settings

Now enable Expert mode in SVP and create a new profile :

  • right click on SPV icon -> Interface type -> Expert
  • right click on SPV icon -> Advanced -> Video Profile -> Remove all and create a new one.

Here my settings with some commentaries :



  • Almost everything is put at a minimum, but i didn't see any visual improvement by increasing them.
  • Frame interpolation mode is the number of times it displays original frames : 1m stand for 1x, 1.5m depend on timing, 2m for 2x, uniform generate every frame. We want 1m.
  • SVP shader : "Simple lite" seems to yield good results, block, sharp and fastest let too much visible artifact and look like artist painting... and other use much higher power without significant visual improvement.
  • Target frame rate uses 2x magic number (23fps x 2 is almost 50fps).
  • Motion vector grid is the size of blocks moved during interplation. 16px seems the best settings. Lower, the workload increase too much without improving the quality significantly, and higher does'nt decrase workload.
  • Decrease frame size seems slow for whatever reason, MadVr does this much faster and lets to SVP more CPU available for the extra resolution (and therefore give better quality).

Now the resource consumption of SVP is lower than default configuration, and the video should be absolutely smooth without any frame repeated or dropped. For a 23.976fps video, the statistics are :

  • composition rate : 50.0000Hz
  • clock deviation : 3.57892Hz

You can verify the installation with SVP tearing test, a red vertical bar should move horizontally at 50fps.
There is also a demonstration mode to compare the interpolated video with the original.