Latest version: v1.0.0.0 (2013-01-05)
Project Page:SourceForge.netGoogle Project Hosting
License: Open-Source (GNU General Public License v2)
About
MediaInfoNET is a .NET wrapper for the MediaInfo library.
MediaInfoNET.dll can be added to any VB or C# project and used for reading information from audio and video files.
Downloads
MediaInfoNET Binaries (835 KB)
MediaInfoNET Source (15 KB)
Usage
- Add a reference to MediaInfoNET.dll to your project and import the MediaInfoNET namespace.
VB:
Imports MediaInfoNET
CS:
using MediaInfoNET;
- Create an object of the MediaFile class and pass the file path as a parameter. The file properties can be read from the MediaFile object.
VB:
Dim aviFile As MediaFile = New MediaFile("C:\Sample.avi")
CS:
MediaFile aviFile = new MediaFile("C:\Sample.avi");
- Download the latest copy of MediaInfo.dll from the MediaInfo website (32-bit DLL without installer) or use the file that is included with the MediaInfoNET download package. Place MediaInfo.dll in the application directory.
Complete Examples:
VB:
Imports MediaInfoNET
Module Module1
Sub Main()
Dim aviFile As MediaFile = New MediaFile("C:\Sample.avi")
Console.WriteLine()
Console.WriteLine("General ---------------------------------")
Console.WriteLine()
Console.WriteLine("File Name : {0}", aviFile.Name)
Console.WriteLine("Format : {0}", aviFile.General.Format)
Console.WriteLine("Duration : {0}", aviFile.General.DurationString)
Console.WriteLine("Bitrate : {0}", aviFile.General.Bitrate)
If aviFile.Audio.Count > 0 Then
Console.WriteLine()
Console.WriteLine("Audio ---------------------------------")
Console.WriteLine()
Console.WriteLine("Format : {0}", aviFile.Audio(0).Format)
Console.WriteLine("Bitrate : {0}", aviFile.Audio(0).Bitrate.ToString())
Console.WriteLine("Channels : {0}", aviFile.Audio(0).Channels.ToString())
Console.WriteLine("Sampling : {0}", aviFile.Audio(0).SamplingRate.ToString())
End If
If aviFile.Video.Count > 0 Then
Console.WriteLine()
Console.WriteLine("Video ---------------------------------")
Console.WriteLine()
Console.WriteLine("Format : {0}", aviFile.Video(0).Format)
Console.WriteLine("Bit rate : {0}", aviFile.Video(0).Bitrate.ToString())
Console.WriteLine("Frame rate : {0}", aviFile.Video(0).FrameRate.ToString())
Console.WriteLine("Frame size : {0}", aviFile.Video(0).FrameSize.ToString())
End If
Console.ReadLine()
End Sub
End Module
CS:
using System;
using System.Text;
using MediaInfoNET;
namespace SampleCS
{
class Program
{
static void Main(string[] args)
{
MediaFile aviFile = new MediaFile("C:\Sample.avi");
Console.WriteLine();
Console.WriteLine("General ---------------------------------");
Console.WriteLine();
Console.WriteLine("File Name : {0}", aviFile.Name);
Console.WriteLine("Format : {0}", aviFile.General.Format);
Console.WriteLine("Duration : {0}", aviFile.General.DurationString);
Console.WriteLine("Bitrate : {0}", aviFile.General.Bitrate);
if (aviFile.Audio.Count > 0)
{
Console.WriteLine();
Console.WriteLine("Audio ---------------------------------");
Console.WriteLine();
Console.WriteLine("Format : {0}", aviFile.Audio[0].Format);
Console.WriteLine("Bitrate : {0}", aviFile.Audio[0].Bitrate.ToString());
Console.WriteLine("Channels : {0}", aviFile.Audio[0].Channels.ToString());
Console.WriteLine("Sampling : {0}", aviFile.Audio[0].SamplingRate.ToString());
}
if (aviFile.Video.Count > 0)
{
Console.WriteLine();
Console.WriteLine("Video ---------------------------------");
Console.WriteLine();
Console.WriteLine("Format : {0}", aviFile.Video[0].Format);
Console.WriteLine("Bit rate : {0}", aviFile.Video[0].Bitrate.ToString());
Console.WriteLine("Frame rate : {0}", aviFile.Video[0].FrameRate.ToString());
Console.WriteLine("Frame size : {0}", aviFile.Video[0].FrameSize.ToString());
}
Console.ReadLine();
}
}
}