MediaPortal wrapper class for the third-party MediaInfo library.
Inheritance: IDisposable
Ejemplo n.º 1
0
 private static void TestPath(string path)
 {
     var mi = new MediaInfoWrapper();
     if (File.Exists(path))
         TestFile(mi, path);
     else if (Directory.Exists(path))
         foreach (var file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
             TestFile(mi, file);
     else
         Console.WriteLine("Can't find path: {0}", path);
 }
Ejemplo n.º 2
0
      public void AddMediaInfo(MediaInfoWrapper mediaInfo)
      {
        // This method will be called at least one time, for video DVDs it will be called multiple times for the different
        // .ifo files. The first time this method is called, the given media info instance is the "major" instance, i.e.
        // in case of a video DVD, it is the video_ts.ifo file.
        // We will collect most of our interesting attributes by taking the first one which is available. All others will then be
        // ignored. Only for some attributes, all values will be collected.
        for (int i = 0; i < mediaInfo.GetVideoCount(); i++)
        {
          if (!_ar.HasValue)
            _ar = mediaInfo.GetAR(i);
          if (!_frameRate.HasValue)
            _frameRate = mediaInfo.GetFramerate(i);
          if (!_width.HasValue)
            _width = mediaInfo.GetWidth(i);
          if (!_height.HasValue)
            _height = mediaInfo.GetHeight(i);
          if (!_playTime.HasValue)
          {
            long? time = mediaInfo.GetPlaytime(i);
            if (time.HasValue && time > 1000)
              _playTime = time.Value;
          }
          if (!_vidBitRate.HasValue)
            _vidBitRate = mediaInfo.GetVidBitrate(i);
          string vidCodec = mediaInfo.GetVidCodec(i);
          if (!string.IsNullOrEmpty(vidCodec) && !_vidCodecs.Contains(vidCodec))
            _vidCodecs.Add(vidCodec);
        }
        _audioStreamCount = mediaInfo.GetAudioCount();
        for (int i = 0; i < _audioStreamCount; i++)
        {
          if (!_audBitRate.HasValue)
            _audBitRate = mediaInfo.GetAudioBitrate(i);
          string audCodec = mediaInfo.GetAudioCodec(i);
          if (!string.IsNullOrEmpty(audCodec) && !_audCodecs.Contains(audCodec))
            _audCodecs.Add(audCodec);

          string audLang = mediaInfo.GetAudioLanguage(i);
          if (!string.IsNullOrEmpty(audLang) && !_audioLanguages.Contains(audLang))
            _audioLanguages.Add(audLang);
        }
      }
Ejemplo n.º 3
0
 public static VideoResult CreateFileInfo(string fileName, MediaInfoWrapper fileInfo)
 {
   return new VideoResult(fileName, fileInfo);
 }
Ejemplo n.º 4
0
 public static VideoResult CreateDVDInfo(string dvdTitle, MediaInfoWrapper videoTsInfo)
 {
   VideoResult result = new VideoResult(dvdTitle, videoTsInfo) { IsDVD = true, MimeType = "video/dvd" };
   return result;
 }
Ejemplo n.º 5
0
 public VideoResult(string videoTitle, MediaInfoWrapper mainInfo)
 {
   _title = videoTitle;
   AddMediaInfo(mainInfo);
 }
Ejemplo n.º 6
0
    protected MediaInfoWrapper ReadMediaInfo(IFileSystemResourceAccessor mediaItemAccessor)
    {
      MediaInfoWrapper result = new MediaInfoWrapper();

      ILocalFsResourceAccessor localFsResourceAccessor = mediaItemAccessor as ILocalFsResourceAccessor;
      if (ReferenceEquals(localFsResourceAccessor, null))
      {
        Stream stream = null;
        try
        {
          stream = mediaItemAccessor.OpenRead();
          if (stream != null)
            result.Open(stream);
        }
        finally
        {
          if (stream != null)
            stream.Close();
        }
      }
      else
      {
        using (localFsResourceAccessor.EnsureLocalFileSystemAccess())
          result.Open(localFsResourceAccessor.LocalFileSystemPath);
      }

      return result;
    }
 protected MediaInfoWrapper ReadMediaInfo(IResourceAccessor mediaItemAccessor)
 {
   MediaInfoWrapper result = new MediaInfoWrapper();
   Stream stream = null;
   try
   {
     stream = mediaItemAccessor.OpenRead();
     if (stream != null)
       result.Open(stream);
   }
   finally
   {
     if (stream != null)
       stream.Close();
   }
   return result;
 }
Ejemplo n.º 8
0
 private static void TestFile(MediaInfoWrapper mediaInfo, string path)
 {
     Console.WriteLine(mediaInfo.ReadFile(path));
 }
Ejemplo n.º 9
0
 public void Startup(MGDataStore dataStore, long id)
 {
     m_DataStore = dataStore;
     m_MediaInfo = new MediaInfoWrapper();
 }
Ejemplo n.º 10
0
 public void Shutdown()
 {
     m_DataStore = null;
     m_MediaInfo = null;
 }