![]() |
VOOZH | about |
dotnet add package MediaInfo.Wrapper --version 26.1.0
NuGet\Install-Package MediaInfo.Wrapper -Version 26.1.0
<PackageReference Include="MediaInfo.Wrapper" Version="26.1.0" />
<PackageVersion Include="MediaInfo.Wrapper" Version="26.1.0" />Directory.Packages.props
<PackageReference Include="MediaInfo.Wrapper" />Project file
paket add MediaInfo.Wrapper --version 26.1.0
#r "nuget: MediaInfo.Wrapper, 26.1.0"
#:package MediaInfo.Wrapper@26.1.0
#addin nuget:?package=MediaInfo.Wrapper&version=26.1.0Install as a Cake Addin
#tool nuget:?package=MediaInfo.Wrapper&version=26.1.0Install as a Cake Tool
MP-MediaInfo is .NET wrapper for MediaArea MediaInfo and use native packages 👁 NuGet Badge
and 👁 NuGet Badge
.
👁 License
👁 Build Core
👁 Build
| 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 |
Two packages are available:
Choose based on your target framework:
dotnet add package MediaInfo.Wrapper.Core --version 26.1.0
Install-Package MediaInfo.Wrapper -Version 26.1.0
Add to usings:
using MediaInfo;
Instantiate a MediaInfoWrapper with the path to your media file:
var media = new MediaInfoWrapper("path/to/media/file.mp4");
Always verify the file was successfully analyzed:
if (media.Success)
{
// File analyzed successfully
}
else
{
// Handle analysis failure
Console.WriteLine("Failed to analyze media file");
}
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
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
}
}
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
}
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
}
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;
}
Access chapter/menu information:
foreach (var chapter in media.ChapterStreams)
{
var startTime = chapter.StartTime; // Chapter start timestamp
// Chapter stream information available
}
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);
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.
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}");
}
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}");
}
}
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();
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.
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
}
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
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.
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 |
Some dependencies are available with MacPorts. To install MacPorts: https://guide.macports.org/#installing
port install zlib curl zenlib
sudo apt-get update
sudo apt-get install libzen0v5 libmms0 zlib1g zlibc libnghttp2-14 librtmp1 curl libcurl4-gnutls-dev libglib2.0-dev
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
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
sudo dnf update
sudo dnf -y install zlib curl libzen openssl libmms
sudo zypper refresh
sudo zypper update -y
sudo zypper install -y zlib curl libmms0 openssl libnghttp2-14
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
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
sudo apt-get update
sudo apt-get install libzen0v5 libmms0 openssl zlib1g zlibc libnghttp2-14 librtmp1 curl libcurl4-gnutls-dev libglib2.0
Windows package contains all dependencies and does not required any actions.
sudo pacman -Syu
sudo pacman -S libcurl-gnutls libzen libmms libssh librtmp0
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
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
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
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net40 net40 is compatible. net403 net403 was computed. net45 net45 is compatible. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
Showing the top 1 NuGet packages that depend on MediaInfo.Wrapper:
| Package | Downloads |
|---|---|
|
Fly.Toolkit.Wpf
请无视它,它并不好用,只是能给我自己带来一点点的便利而已 |
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 | 1,286 | 3/24/2026 |
| 21.9.3 | 28,461 | 9/29/2022 |
| 21.9.2 | 19,460 | 10/13/2021 |
| 21.9.1 | 12,718 | 9/30/2021 |
| 21.9.0 | 667 | 9/29/2021 |
| 21.3.7 | 607 | 9/26/2021 |
| 21.3.6 | 658 | 9/19/2021 |
| 21.3.5 | 2,176 | 8/24/2021 |
| 21.3.4 | 1,341 | 6/30/2021 |
| 21.3.3 | 2,502 | 5/23/2021 |
| 21.3.2 | 895 | 5/18/2021 |
| 21.3.1 | 5,337 | 3/31/2021 |
| 21.3.0 | 1,147 | 3/29/2021 |
| 20.9.2 | 14,879 | 12/13/2020 |
| 20.9.0 | 875 | 12/10/2020 |
| 20.8.0 | 1,746 | 8/14/2020 |
| 19.9.4 | 5,746 | 6/21/2020 |
| 19.9.3 | 1,077 | 6/20/2020 |
| 19.9.2 | 8,008 | 3/17/2020 |
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.