Example #1
0
        public static MediaFile GetMediaFile(string filePath)
        {
            int               duration, fps = 0, height = 0, width = 0;
            bool              hasVideo, hasAudio;
            string            audioCodec = "", videoCodec = "";
            MultimediaFactory factory;
            IMetadataReader   reader = null;

            try{
                factory = new MultimediaFactory();
                reader  = factory.getMetadataReader();
                reader.Open(filePath);
                duration = (int)reader.GetMetadata(MetadataType.Duration);
                hasVideo = (bool)reader.GetMetadata(MetadataType.HasVideo);
                hasAudio = (bool)reader.GetMetadata(MetadataType.HasAudio);
                if (hasAudio)
                {
                    audioCodec = (string)reader.GetMetadata(MetadataType.AudioEncoderType);
                }
                if (hasVideo)
                {
                    videoCodec = (string)reader.GetMetadata(MetadataType.VideoEncoderType);
                    fps        = (int)reader.GetMetadata(MetadataType.Fps);
                }
                height = (int)reader.GetMetadata(MetadataType.DimensionX);
                width  = (int)reader.GetMetadata(MetadataType.DimensionY);

                return(new MediaFile(filePath, duration * 1000, (ushort)fps,
                                     hasAudio, hasVideo, videoCodec, audioCodec,
                                     (uint)height, (uint)width));
            }
            catch (GLib.GException ex) {
                throw new Exception(Catalog.GetString("Invalid video file:") + "\n" + ex.Message);
            }
            finally {
                reader.Close();
                reader.Dispose();
            }
        }