Index: Core/Player/g_player.cs
===================================================================
--- Core/Player/g_player.cs	(revision 27952)
+++ Core/Player/g_player.cs	(working copy)
@@ -37,6 +37,7 @@
 using Un4seen.Bass.AddOn.Cd;
 using Action = MediaPortal.GUI.Library.Action;
 using MediaPortal.Player.Subtitles;
+using System.Threading;
 
 namespace MediaPortal.Player
 {
@@ -65,6 +66,7 @@
     #region variables
 
     private static MediaInfoWrapper _mediaInfo = null;
+    private static Thread _delayedrefreshratechanger = null;
     private static int _currentStep = 0;
     private static int _currentStepIndex = -1;
     private static DateTime _seekTimer = DateTime.MinValue;
@@ -590,6 +592,11 @@
       }
       if (_player != null)
       {
+        if (_delayedrefreshratechanger != null)
+        {
+          _delayedrefreshratechanger.Abort();
+          _delayedrefreshratechanger = null;
+        }
         Log.Debug("g_Player.doStop() keepTimeShifting = {0} keepExclusiveModeOn = {1}", keepTimeShifting,
                   keepExclusiveModeOn);
         OnStopped();
@@ -1225,6 +1232,12 @@
           ChangeDriveSpeed(strFile, DriveType.CD);
         }
 
+        if (_delayedrefreshratechanger != null)
+        {
+          _delayedrefreshratechanger.Abort();
+          _delayedrefreshratechanger = null;
+        }
+
         _mediaInfo = new MediaInfoWrapper(strFile);
         Starting = true;
 
@@ -1235,23 +1248,33 @@
             Log.Debug("g_Player.Play - Mediatype Unknown, forcing detection as Video");
             type = MediaType.Video;
           }
-          // refreshrate change done here.
-          RefreshRateChanger.AdaptRefreshRate(strFile, (RefreshRateChanger.MediaType)(int)type);
 
-          if (RefreshRateChanger.RefreshRateChangePending)
+          if (_mediaInfo == null || _mediaInfo.Framerate <= 0)
           {
-            TimeSpan ts = DateTime.Now - RefreshRateChanger.RefreshRateChangeExecutionTime;
-            if (ts.TotalSeconds > RefreshRateChanger.WAIT_FOR_REFRESHRATE_RESET_MAX)
+            // using DelayedRefreshrateChanger
+            _delayedrefreshratechanger = new Thread(delegate() { RefreshRateChanger.DelayedRefreshrateChanger(strFile, type); });
+            _delayedrefreshratechanger.Start();
+          }
+          else
+          {
+            // refreshrate change done here.
+            RefreshRateChanger.AdaptRefreshRate(strFile, (RefreshRateChanger.MediaType)(int)type, _mediaInfo.Framerate);
+
+            if (RefreshRateChanger.RefreshRateChangePending)
             {
-              Log.Info(
-                "g_Player.Play - waited {0}s for refreshrate change, but it never took place (check your config). Proceeding with playback.",
-                RefreshRateChanger.WAIT_FOR_REFRESHRATE_RESET_MAX);
-              RefreshRateChanger.ResetRefreshRateState();
+              TimeSpan ts = DateTime.Now - RefreshRateChanger.RefreshRateChangeExecutionTime;
+              if (ts.TotalSeconds > RefreshRateChanger.WAIT_FOR_REFRESHRATE_RESET_MAX)
+              {
+                Log.Info(
+                  "g_Player.Play - waited {0}s for refreshrate change, but it never took place (check your config). Proceeding with playback.",
+                  RefreshRateChanger.WAIT_FOR_REFRESHRATE_RESET_MAX);
+                RefreshRateChanger.ResetRefreshRateState();
+              }
+              else
+              {
+                return true;
+              }
             }
-            else
-            {
-              return true;
-            }
           }
         }
 
Index: Core/Player/RefreshRateChanger.cs
===================================================================
--- Core/Player/RefreshRateChanger.cs	(revision 27987)
+++ Core/Player/RefreshRateChanger.cs	(working copy)
@@ -525,7 +525,7 @@
       {
         foreach (double fpsSetting in setting.Fps)
         {
-          if (fps == fpsSetting)
+          if (Math.Abs(fps - fpsSetting) < 0.1)
           {
             newRR = setting.Hz;
             newExtCmd = setting.ExtCmd;
@@ -638,7 +638,7 @@
       _refreshrateChangeCurrentRR = 0;
     }
 
-    public static void SetRefreshRateBasedOnFPS(double fps, string strFile, MediaType type)
+    public static bool SetRefreshRateBasedOnFPS(double fps, string strFile, MediaType type)
     {
       int currentScreenNr = GUIGraphicsContext.currentScreenNumber;
       double currentRR = 0;
@@ -665,7 +665,7 @@
         if (!enabled)
         {
           Log.Info("RefreshRateChanger.SetRefreshRateBasedOnFPS: 'auto refreshrate changer' disabled");
-          return;
+          return false;
         }
         force_refresh_rate = xmlreader.GetValueAsBool("general", "force_refresh_rate", false);
         deviceReset = xmlreader.GetValueAsBool("general", "devicereset", false);
@@ -703,17 +703,98 @@
           Log.Info(
             "RefreshRateChanger.SetRefreshRateBasedOnFPS: could not find a matching refreshrate based on {0} fps (check config)",
             fps);
+          return false;
         }
         else
         {
           Log.Info(
             "RefreshRateChanger.SetRefreshRateBasedOnFPS: no refreshrate change required. current is {0}hz, desired is {1}",
             currentRR, newRR);
+          return false;
         }
       }
+      return true;
     }
 
 
+    public static void DelayedRefreshrateChanger(string strFile, MediaPortal.Player.g_Player.MediaType type)
+    {
+
+      Log.Info("RefreshRateChanger.DelayedRefreshrateChanger: using delayed framerate detection");
+      double fps = -1;
+      int maxretries = 100;
+
+      // wait until graph is build
+      while (VMR9Util.g_vmr9 == null)
+      {
+        Thread.Sleep(200);
+      }
+
+      // wait that the video file is played a while
+      Thread.Sleep(2000);
+
+      do
+      {
+        if (VMR9Util.g_vmr9 != null)
+        {
+          fps = VMR9Util.g_vmr9.GetEVRVideoFPS(0);
+          if (fps > 1)
+          {
+            break;
+          }
+        }
+        Thread.Sleep(200);
+      } while (--maxretries > 0);
+
+      int verify = 2;
+      while (fps > 1 || --verify > 0)
+      {
+        Log.Info("RefreshRateChanger.DelayedRefreshrateChanger: detected new render framerate of:{0} fps", fps);
+
+        // refreshrate change done here.
+        bool rchanged = RefreshRateChanger.AdaptRefreshRate(strFile, (RefreshRateChanger.MediaType)(int)type, fps);
+
+        if (RefreshRateChanger.RefreshRateChangePending)
+        {
+          TimeSpan ts = DateTime.Now - RefreshRateChanger.RefreshRateChangeExecutionTime;
+          if (ts.TotalSeconds > RefreshRateChanger.WAIT_FOR_REFRESHRATE_RESET_MAX)
+          {
+            Log.Info(
+              "RefreshRateChanger.DelayedRefreshrateChanger: waited {0}s for refreshrate change, but it never took place (check your config). Proceeding with playback.",
+              RefreshRateChanger.WAIT_FOR_REFRESHRATE_RESET_MAX);
+            RefreshRateChanger.ResetRefreshRateState();
+          }
+          else
+          {
+            Log.Info("RefreshRateChanger.DelayedRefreshrateChanger: waited {0}s for refreshrate change. Proceeding with playback.", ts.TotalSeconds);
+          }
+        }
+
+        if (rchanged && VMR9Util.g_vmr9 != null)
+        {
+          Thread.Sleep(500);
+          Log.Info("RefreshRateChanger.DelayedRefreshrateChanger: UpdateEVRDisplayFPS");
+          VMR9Util.g_vmr9.UpdateEVRDisplayFPS();
+        }
+
+        // recheck the fps rate
+        Thread.Sleep(10000);
+
+        double newfps = VMR9Util.g_vmr9.GetEVRVideoFPS(0);
+        Log.Info("RefreshRateChanger.DelayedRefreshrateChanger: verify refresh rate new render framerate: {0} fps old {1} fps", newfps, fps);
+        if (Math.Abs(fps - newfps) > 1 && VMR9Util.g_vmr9 != null)
+        {
+          // seems that the refreshrate we detected first has now changed again
+          fps = newfps;
+        }
+        else
+        {
+          // end while no new changed needed
+          fps = 0;
+        }
+      }
+    }
+
     // defaults the refreshrate
     public static void AdaptRefreshRate()
     {
@@ -777,11 +858,11 @@
     }
 
     // change screen refresh rate based on media framerate
-    public static void AdaptRefreshRate(string strFile, MediaType type)
+    public static bool AdaptRefreshRate(string strFile, MediaType type, double fps)
     {
       if (_refreshrateChangePending)
       {
-        return;
+        return true;
       }
 
       bool isTV = Util.Utils.IsLiveTv(strFile);
@@ -789,11 +870,6 @@
       bool isVideo = Util.Utils.IsVideo(strFile);
       bool isRTSP = Util.Utils.IsRTSP(strFile); //rtsp users for live TV and recordings.
 
-      if (!isTV && !isDVD && !isVideo && !isRTSP)
-      {
-        return;
-      }
-
       bool enabled = false;
       NumberFormatInfo provider = new NumberFormatInfo();
       provider.NumberDecimalSeparator = ".";
@@ -806,7 +882,7 @@
         if (!enabled)
         {
           Log.Info("RefreshRateChanger.AdaptRefreshRate: 'auto refreshrate changer' disabled");
-          return;
+          return false;
         }
 
         deviceReset = xmlreader.GetValueAsBool("general", "devicereset", false);
@@ -819,46 +895,28 @@
       {
         Log.Error(
           "RefreshRateChanger.AdaptRefreshRate: TV section not found in mediaportal.xml, please delete file and reconfigure.");
-        return;
+        return false;
       }
 
-      List<double> tvFPS = setting.Fps;
-      double fps = -1;
 
-      if ((isVideo || isDVD) && (!isRTSP && !isTV))
+      if ((isTV || isRTSP) && fps <= 0)
       {
-        if (g_Player.MediaInfo != null)
-        {
-          fps = g_Player.MediaInfo.Framerate;
-        }
-        else
-        {
-          StackTrace st = new StackTrace(true);
-          StackFrame sf = st.GetFrame(0);
-
-          Log.Error("RefreshRateChanger.AdaptRefreshRate: g_Player.MediaInfo was null. file: {0} st: {1}", strFile,
-                    sf.GetMethod().Name);
-          return;
-        }
-      }
-      else if (isTV || isRTSP)
-      {
+        List<double> tvFPS = setting.Fps;
         if (tvFPS.Count > 0)
         {
           fps = tvFPS[0];
         }
       }
 
-      if (fps < 1)
+      if (fps <= 0)
       {
         Log.Info("RefreshRateChanger.AdaptRefreshRate: unable to guess framerate on file {0}", strFile);
+        return false;
       }
-      else
-      {
-        Log.Info("RefreshRateChanger.AdaptRefreshRate: framerate on file {0} is {1}", strFile, fps);
-      }
 
-      SetRefreshRateBasedOnFPS(fps, strFile, type);
+      Log.Info("RefreshRateChanger.AdaptRefreshRate: framerate on file {0} is {1}", strFile, fps);
+
+      return SetRefreshRateBasedOnFPS(fps, strFile, type);
     }
 
     #endregion
Index: Core/Player/VMR9.cs
===================================================================
--- Core/Player/VMR9.cs	(revision 27952)
+++ Core/Player/VMR9.cs	(working copy)
@@ -104,6 +104,12 @@
     [DllImport("dshowhelper.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
     private static extern unsafe void EVRNotifyDVDMenuState(bool pIsInMenu);
 
+    [DllImport("dshowhelper.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+    private static extern unsafe double EVRGetVideoFPS(int fpsSource);
+
+    [DllImport("dshowhelper.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+    private static extern unsafe void EVRUpdateDisplayFPS();
+
     #endregion
 
     #region static vars
@@ -526,6 +532,26 @@
     }
 
     /// <summary>
+    /// Gets EVR frame rate 
+    /// Get video FPS - returns FPS from filter graph if 'getReported' is true,
+    /// otherwise returns FPS estimated from video timestamps
+    /// </summary>
+    public double GetEVRVideoFPS(int fpsSource)
+    {
+      return EVRGetVideoFPS(fpsSource);
+    }
+
+    /// <summary>
+    /// Gets EVR frame rate 
+    /// Get video FPS - returns FPS from filter graph if 'getReported' is true,
+    /// otherwise returns FPS estimated from video timestamps
+    /// </summary>
+    public void UpdateEVRDisplayFPS()
+    {
+      EVRUpdateDisplayFPS();
+    }
+
+    /// <summary>
     /// Notifies EVR presenter if the DVD menu is active
     /// </summary>
     public void EVRSetDVDMenuState(bool isInDVDMenu)
