MediaInfo.Wrapper 26.1.0

dotnet add package MediaInfo.Wrapper --version 26.1.0
                    
NuGet\Install-Package MediaInfo.Wrapper -Version 26.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MediaInfo.Wrapper" Version="26.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MediaInfo.Wrapper" Version="26.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MediaInfo.Wrapper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MediaInfo.Wrapper --version 26.1.0
                    
#r "nuget: MediaInfo.Wrapper, 26.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MediaInfo.Wrapper@26.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MediaInfo.Wrapper&version=26.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MediaInfo.Wrapper&version=26.1.0
                    
Install as a Cake Tool

MP-MediaInfo

MP-MediaInfo is .NET wrapper for MediaArea MediaInfo and use native packages NuGet Badge and NuGet Badge.

License Build Core Build

Features

  • Comprehensive Media Analysis: Wraps the MediaInfo library to provide detailed information about video, audio, subtitle, and metadata streams
  • Rich Property Access: Exposes properties for video codecs, bitrates, resolution, frame rates, audio properties, subtitles, chapters, and extensive tag information
  • Multi-Format Support: Supports analysis of virtually all video and audio formats supported by MediaInfo (see Supported Formats)
  • Stream Information: Provides detailed access to individual video streams, audio streams, subtitle streams, chapters, and menu information
  • Metadata Extraction: Extract technical tags and general metadata from media files
  • Cross-Platform: Targets .NET Framework 4.0+, .NET Standard 2.1, .NET 6.0, .NET 8.0, and .NET 10.0
  • Optional Logging: Built-in support for custom logging to track analysis operations

Available packages

Framework Package
.NET Framework 4.0 NuGet Badge
.NET Framework 4.5 NuGet Badge
.NET Standard 2.1 NuGet Badge
.NET 6.0 NuGet Badge
.NET 8.0 NuGet Badge
.NET 10.0 NuGet Badge

Installation

Two packages are available:

  • MediaInfo.Wrapper.Core - For .NET Standard 2.1, .NET 6.0+. Recommended for modern applications, cross-platform projects, and ASP.NET Core services
  • MediaInfo.Wrapper - For .NET Framework 4.0+. Use this if you're on Windows only with .NET Framework

Choose based on your target framework:

.NET Core

dotnet add package MediaInfo.Wrapper.Core --version 26.1.0

.NET Framework

Install-Package MediaInfo.Wrapper -Version 26.1.0

Usage

Basic Setup

Add to usings:

using MediaInfo;

Instantiate a MediaInfoWrapper with the path to your media file:

var media = new MediaInfoWrapper("path/to/media/file.mp4");

Checking Analysis Success

Always verify the file was successfully analyzed:

if (media.Success)
{
    // File analyzed successfully
}
else
{
    // Handle analysis failure
    Console.WriteLine("Failed to analyze media file");
}

General Information

Access basic media information:

var containerFormat = media.Format;              // e.g., "MPEG-4"
var duration = media.Duration;                  // Duration in milliseconds
var overallBitRate = media.OverallBitRate;     // Combined bitrate of all streams
var isScanningNeeded = media.ScanningNeeded;   // Whether file needs deeper analysis

Video Stream Analysis

Extract detailed video information:

if (media.HasVideo)
{
    var videoStream = media.VideoStreams.FirstOrDefault();
    if (videoStream != null)
    {
        var width = videoStream.Width;                          // Resolution width
        var height = videoStream.Height;                        // Resolution height
        var codec = videoStream.Codec;                          // e.g., "AVC"
        var frameRate = videoStream.FrameRate;                  // Frames per second
        var frameRateMode = videoStream.FrameRateMode;         // e.g., CFR, VFR
        var bitRate = videoStream.BitRate;                     // Video stream bitrate
        var standard = videoStream.Standard;                   // e.g., "NTSC", "PAL"
        var aspectRatio = videoStream.AspectRatio;             // e.g., "16:9"
        var chromaSubSampling = videoStream.ChromaSubSampling; // e.g., "4:2:0"
        var colorSpace = videoStream.ColorSpace;               // e.g., "YUV"
        var hdrFormat = videoStream.Hdr;                       // e.g., "HDR10", "Dolby Vision"
        var profile = videoStream.Profile;                     // Codec profile
        var level = videoStream.Level;                         // Profile level
    }
}

Audio Stream Analysis

Access audio track information:

foreach (var audioStream in media.AudioStreams)
{
    var language = audioStream.Language;                    // ISO 639-2 language code
    var codec = audioStream.Codec;                          // e.g., "AAC", "AC-3"
    var bitRate = audioStream.BitRate;                     // Audio bitrate
    var channels = audioStream.Channels;                   // Number of audio channels
    var channelLayout = audioStream.ChannelLayout;         // e.g., "L R C LFE Ls Rs"
    var samplingRate = audioStream.SamplingRate;           // Sample rate in Hz
    var bitDepth = audioStream.BitDepth;                   // Bits per sample
    var bitrateMode = audioStream.BitrateMode;             // CBR, VBR, etc.
    var title = audioStream.Title;                         // Track title if available
}

Subtitle Stream Analysis

Retrieve subtitle information:

foreach (var subtitleStream in media.SubtitleStreams)
{
    var codec = subtitleStream.Codec;              // e.g., "PGS", "ASS"
    var language = subtitleStream.Language;        // ISO 639-2 language code
    var title = subtitleStream.Title;              // Subtitle track name
}

Audio and Video Tags

Extract metadata:

var audioTags = media.AudioTags;       // Audio metadata (album, artist, etc.)
var videoTags = media.VideoTags;       // Video metadata (title, description, etc.)
var generalInfo = media.GeneralTags;   // File-level metadata

if (audioTags != null)
{
    var artist = audioTags.Performer;
    var album = audioTags.Album;
    var title = audioTags.Title;
}

Chapter Information

Access chapter/menu information:

foreach (var chapter in media.ChapterStreams)
{
    var startTime = chapter.StartTime;  // Chapter start timestamp
    // Chapter stream information available
}

Using a Logger

Optionally provide a logger to track analysis:

public class ConsoleLogger : ILogger
{
    public void Log(string message) => Console.WriteLine(message);
}

var logger = new ConsoleLogger();
var media = new MediaInfoWrapper("path/to/file.mp4", logger);

Supported Formats

MP-MediaInfo supports analysis of virtually all media formats supported by the underlying MediaInfo library, including:

Video Formats: MP4, MKV, AVI, MOV, FLV, WebM, WMV, 3GP, and many more

Audio Codecs: H.264/AVC, H.265/HEVC, MPEG-4, VP8, VP9, AV1, Theora, and others

Audio Formats: MP3, AAC, FLAC, Opus, Vorbis, AC-3, DTS, TrueHD, Atmos, and more

Subtitle Formats: PGS, ASS/SSA, SRT, SUBRIP, DVB, and other subtitle types

For a complete and detailed list, refer to the MediaInfo documentation.

Advanced Usage

Error Handling

Handle potential errors gracefully:

try
{
    var media = new MediaInfoWrapper(filePath);
    
    if (!media.Success)
    {
        Console.WriteLine("Analysis was not successful");
        return;
    }
    
    // Process media information
}
catch (FileNotFoundException)
{
    Console.WriteLine("Media file not found");
}
catch (Exception ex)
{
    Console.WriteLine($"Error analyzing media: {ex.Message}");
}

Batch Processing Multiple Files

Analyze multiple files efficiently:

var mediaFiles = Directory.GetFiles("mediaFolder", "*.mp4");

foreach (var file in mediaFiles)
{
    try
    {
        var media = new MediaInfoWrapper(file);
        if (media.Success)
        {
            Console.WriteLine($"{Path.GetFileName(file)}: {media.Format}");
            // Process each file
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Error processing {file}: {ex.Message}");
    }
}

Checking Specific Media Characteristics

var media = new MediaInfoWrapper(filePath);

// Check if file has video
if (media.HasVideo)
{
    var videoStream = media.VideoStreams.FirstOrDefault();
    if (videoStream?.Hdr != null)
    {
        Console.WriteLine($"HDR Format: {videoStream.Hdr}");
    }
}

// Check number of audio tracks
Console.WriteLine($"Audio tracks: {media.AudioStreams.Count}");

// Find specific audio codec
var ac3Tracks = media.AudioStreams
    .Where(s => s.Codec?.Contains("AC-3") ?? false)
    .ToList();

Troubleshooting

Analysis Returns False (media.Success == false)

  • Verify the file path is correct and the file exists
  • Ensure the file is not corrupted
  • Check that the media format is supported
  • On Linux/macOS, verify all dependencies (libzen, zlib) are installed
  • Try enabling logging to see detailed error messages

Missing Native Libraries

Windows: The native MediaInfo libraries are included in the NuGet package. No additional installation needed.

Linux/macOS: Install system dependencies as described in the Dependencies section.

Incomplete Information

Some media files may require deeper scanning. Check media.ScanningNeeded:

if (media.ScanningNeeded)
{
    Console.WriteLine("File may benefit from deeper analysis");
    // Files with streaming headers might have incomplete information
}

Out of Memory Issues

When processing very large files or many files in parallel, be mindful of memory usage. Consider disposing of MediaInfoWrapper objects when done:

using (var media = new MediaInfoWrapper(filePath))
{
    // Use media
}
// Disposed automatically

Demo application

ASP.NET Core demo application is available which shows the usage of the package, serialization and running from the docker container. Code from this demo should not be used in production code, the code is merely to demonstrate the usage of this package.

Dependencies

Make sure that the following dependencies are installed in the operating system before starting the project

.NET Core package supports next operating systems

Operation system Version
MacOS 10.15 (Catalina), 11 (Big Sur)
Ubuntu 16.04, 18.04, 20.04 and 21.04
CenOS 7 and above
Fedora 32 and above
OpenSUSE 15.2 and Tumbleweed
RedHat 7 and above
Debian 9 and above
Arch Linux
Windows 7 and above
Docker buster

MacOS

Some dependencies are available with MacPorts. To install MacPorts: https://guide.macports.org/#installing

port install zlib curl zenlib

Ubuntu

sudo apt-get update
sudo apt-get install libzen0v5 libmms0 zlib1g zlibc libnghttp2-14 librtmp1 curl libcurl4-gnutls-dev libglib2.0-dev

CentOS

CentOS 7
sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y update
sudo yum -y install zlib curl libzen bzip2 libcurl
sudo rpm -ivh https://download1.rpmfusion.org/free/el/updates/7/x86_64/l/libmms-0.6.4-2.el7.x86_64.rpm
CentOS 8
sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo yum -y update
sudo yum -y install zlib curl libzen bzip2 libcurl
sudo rpm -ivh https://download1.rpmfusion.org/free/el/updates/8/x86_64/l/libmms-0.6.4-8.el8.x86_64.rpm

Fedora

sudo dnf update
sudo dnf -y install zlib curl libzen openssl libmms

OpenSUSE

sudo zypper refresh
sudo zypper update -y
sudo zypper install -y zlib curl libmms0 openssl libnghttp2-14

RedHat

RedHat 7
sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y update
sudo yum -y install zlib curl libzen bzip2 libcurl
sudo rpm -ivh https://download1.rpmfusion.org/free/el/updates/7/x86_64/l/libmms-0.6.4-2.el7.x86_64.rpm
RedHat 8
sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo yum -y update
sudo yum -y install zlib curl libzen bzip2 libcurl
sudo rpm -ivh https://download1.rpmfusion.org/free/el/updates/8/x86_64/l/libmms-0.6.4-8.el8.x86_64.rpm

Debian

sudo apt-get update
sudo apt-get install libzen0v5 libmms0 openssl zlib1g zlibc libnghttp2-14 librtmp1 curl libcurl4-gnutls-dev libglib2.0

Windows

Windows package contains all dependencies and does not required any actions.

ArchLinux

sudo pacman -Syu
sudo pacman -S libcurl-gnutls libzen libmms libssh librtmp0

Docker

.NET Core 3.1
FROM mcr.microsoft.com/dotnet/aspnet:3.1
RUN apt-get update && apt-get install -y libzen0v5 libmms0 openssl zlib1g zlibc libnghttp2-14 librtmp1 curl libcurl4-gnutls-dev libglib2.0
.NET 6.0
FROM mcr.microsoft.com/dotnet/aspnet:6.0
RUN apt-get update && apt-get install -y libzen0v5 libmms0 openssl zlib1g zlibc libnghttp2-14 librtmp1 curl libcurl4-gnutls-dev libglib2.0
.NET 8.0
FROM mcr.microsoft.com/dotnet/aspnet:8.0
RUN apt-get update && apt-get install -y libzen0v5 libmms0 openssl zlib1g zlibc libnghttp2-14 librtmp1 curl libcurl4-gnutls-dev libglib2.0
.NET 10.0
FROM mcr.microsoft.com/dotnet/aspnet:10.0
RUN apt-get update && apt-get install -y libzen0v5 libmms0 openssl zlib1g zlibc libnghttp2-14 librtmp1 curl libcurl4-gnutls-dev libglib2.0
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MediaInfo.Wrapper:

Package Downloads
Fly.Toolkit.Wpf

请无视它,它并不好用,只是能给我自己带来一点点的便利而已

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on MediaInfo.Wrapper:

Repository Stars
QL-Win/QuickLook
Bring macOS “Quick Look” feature to Windows
MediaPortal/MediaPortal-1
Home Theater and Digital Video Recording solution for Windows.
FredTungsten/ScriptPlayer
ScriptPlayer is a video player that controls the Handy and lots of other toys in sync with videos.
simontime/Brovicon
BROadcast-quality VIdeo CONverter
Version Downloads Last Updated
26.1.0 57 3/24/2026
21.9.3 26,253 9/29/2022
21.9.2 18,919 10/13/2021
21.9.1 12,028 9/30/2021
21.9.0 648 9/29/2021
21.3.7 591 9/26/2021
21.3.6 647 9/19/2021
21.3.5 2,149 8/24/2021
21.3.4 1,309 6/30/2021
21.3.3 2,485 5/23/2021
21.3.2 877 5/18/2021
21.3.1 5,268 3/31/2021
21.3.0 1,128 3/29/2021
20.9.2 14,338 12/13/2020
20.9.0 862 12/10/2020
20.8.0 1,725 8/14/2020
19.9.4 5,727 6/21/2020
19.9.3 1,055 6/20/2020
19.9.2 7,898 3/17/2020
Loading failed

Copyright © 2017-2026 Yaroslav Tatarenko

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.