示例#1
0
 public static bool IsMp4(string path)
 {
     using (var mi = new MediaInfo.MediaInfo())
     {
         mi.Open(path);
         var format = mi.Get(StreamKind.General, 0, @"Format");
         return(string.Equals(format, @"MPEG-4", StringComparison.Ordinal));
     }
 }
示例#2
0
        public static List <string> GetAllFlvList(string dir)
        {
            var list = Directory.GetFiles(dir, @"*.flv", SearchOption.AllDirectories);
            var res  = new List <string>();

            using (var mi = new MediaInfo.MediaInfo())
            {
                foreach (var p in list)
                {
                    var path = Path.GetFullPath(p);
                    mi.Open(path);
                    var format = mi.Get(StreamKind.General, 0, @"Format");
                    if (string.Equals(format, @"Flash Video", StringComparison.Ordinal))
                    {
                        res.Add(path);
                    }
                }
            }
            return(res);
        }
示例#3
0
        void AdaptRefreshRateFromCacheFile()
        {
            if (!PluginConfiguration.Instance.AllowRefreshRateChange)
            {
                refreshRateAdapted = true;
                return;
            }

            if (!string.IsNullOrEmpty(cacheFile))
            {
                try
                {
                    MediaInfo.MediaInfo mi = new MediaInfo.MediaInfo();
                    mi.Open(cacheFile);
                    double framerate;
                    double.TryParse(mi.Get(MediaInfo.StreamKind.Video, 0, "FrameRate"), System.Globalization.NumberStyles.AllowDecimalPoint, new System.Globalization.NumberFormatInfo()
                    {
                        NumberDecimalSeparator = "."
                    }, out framerate);
                    if (framerate > 1)
                    {
                        Log.Instance.Info("OnlineVideosPlayer got {0} FPS from MediaInfo", framerate);
                        double matchedFps = RefreshRateHelper.MatchConfiguredFPS(framerate);
                        if (matchedFps != default(double))
                        {
                            refreshRateAdapted = true;
                            RefreshRateHelper.ChangeRefreshRateToMatchedFps(matchedFps, cacheFile);
                            try
                            {
                                if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.EVR)
                                {
                                    EVRUpdateDisplayFPS();
                                }
                            }
                            catch (EntryPointNotFoundException)
                            {
                                Log.Instance.Warn("OnlineVideosPlayer: Your version of dshowhelper.dll does not support FPS updating.");
                            }
                            catch (Exception ex)
                            {
                                Log.Instance.Warn("OnlineVideosPlayer: Exception trying update refresh rate fo EVR: {0}", ex.ToString());
                            }
                        }
                        else
                        {
                            Log.Instance.Info("No matching configured FPS found - skipping RefreshRate Adaption from Cache File");
                        }
                    }
                    else
                    {
                        Log.Instance.Info("OnlineVideosPlayer got no FPS from MediaInfo");
                    }
                }
                catch (Exception ex)
                {
                    Log.Instance.Warn("OnlineVideosPlayer: Exception trying refresh rate change from cache file: {0}", ex.ToString());
                }
            }
            else
            {
                Log.Instance.Info("OnlineVideosPlayer: No cache file, skipping FPS detection via MediaInfo");
            }
        }