public getMetadataReader ( ) : IMetadataReader | ||
Результат | IMetadataReader |
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(); } }
public static new PreviewMediaFile GetMediaFile(string filePath) { int duration=0; bool hasVideo; bool hasAudio; string AudioEncoderType = ""; string VideoEncoderType = ""; int fps=0; int height=0; int width=0; Pixbuf preview=null; MultimediaFactory factory; IMetadataReader reader; IFramesCapturer thumbnailer; try{ factory = new MultimediaFactory(); reader = factory.getMetadataReader(); reader.Open(filePath); hasVideo = (bool) reader.GetMetadata(MetadataType.HasVideo); hasAudio = (bool) reader.GetMetadata(MetadataType.HasAudio); if (hasAudio){ AudioEncoderType = (string) reader.GetMetadata(MetadataType.AudioEncoderType); } if (hasVideo){ VideoEncoderType = (string) reader.GetMetadata(MetadataType.VideoEncoderType); fps = (int) reader.GetMetadata(MetadataType.Fps); thumbnailer = factory.getFramesCapturer(); thumbnailer.Open(filePath); thumbnailer.SeekTime(1000,false); preview = thumbnailer.GetCurrentFrame(THUMBNAIL_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT); duration =(int) ((thumbnailer as GstPlayer).StreamLength/1000); /* On Windows some formats report a 0 duration, try a last time with the reader */ if (duration == 0) duration = (int)reader.GetMetadata(MetadataType.Duration); thumbnailer.Dispose(); } height = (int) reader.GetMetadata(MetadataType.DimensionX); width = (int) reader.GetMetadata (MetadataType.DimensionY); reader.Close(); reader.Dispose(); return new PreviewMediaFile(filePath,duration*1000, (ushort)fps,hasAudio, hasVideo,VideoEncoderType, AudioEncoderType,(uint)height, (uint)width,preview); } catch (GLib.GException ex){ throw new Exception (Catalog.GetString("Invalid video file:")+"\n"+ex.Message); } }