Get-MediaInfo
Get-MediaInfo is a PowerShell MediaInfo solution.
It consists of three functions:
Installation
Installation or download via PowerShellGet:
No build provided for PSGallery. Options:
- Manually install repo files
- Manually install the xxx.nupkg file: Installing PowerShell scripts from a NuGet package
- Copy the \Packages\xxx.nupkg to a local share, configured with new-PsRepository, then install via install-module,
- or use Doug Finke's Install-ModuleFromGitHub module to direct download from the repo and build a local module install.
Get-MediaInfoRAW
SYNOPSIS
Get-MediaInfoRAW.ps1 - Returns an object reflecting all of the raw 'low-level' MediaInfo properties of a media file.
DESCRIPTION
Created this variant because I want the full low-level range of MediaInfo.dll properties, and not simply a subset. So this function parses out the -RAW text returned, into a nested General|Video|Audio object
PARAMETERS
-Path
Path to a media file. Can also be passed via pipeline.[-Path D:\path-to\video.ext]
-StorageUnits
-Decimals
-fixNames
Switch to replace spaces and forward-slashes in default MediaInfo property names, with underscores (default's True)
-noPostConversion
EXAMPLE 1
PS>$data = Get-MediaInfoRAW 'D:\Samples\Downton Abbey.mkv' ;
Assign the Raw MediaInfo.dll properties for the specified video, as a System.Object to the $data variable.
Get-MediaInfoSummary
SYNOPSIS
Get-MediaInfoSummary.ps1 - - Shows a summary in text format for a media file.
DESCRIPTION
Get-MediaInfoSummary.ps1 - - Shows a summary in text format for a media file.
PARAMETERS
-Path
Path to a media file. Can also be passed via pipeline.[-Path D:\path-to\video.ext]
-Full
-Raw
Switch to show not the friendly parameter names but rather the names as they are used in the MediaInfo API.[-Raw]
-RawParsed
EXAMPLE 1
PS>Get-MediaInfoSummary 'D:\Samples\Downton Abbey.mkv'
Output the default Full media summary for the specified video.
Get-MediaInfoValue
SYNOPSIS
Get-MediaInfoValue.ps1 - Returns specific properties from media files.
DESCRIPTION
Get-MediaInfoValue.ps1 - Returns specific properties from media files.
PARAMETERS
-Path
-Kind
A MediaInfo kind (General|Video|Audio|Text|Image|Menu).[-Kind Video] Kinds and their properties can be seen with MediaInfo.NET.
-Index
-Parameter
Name of the property to get.[-param 'Performer'] The property names can be seen with MediaInfo.NET with following setting enabled: Show parameter names as they are used in the MediaInfo API They can also be seen with Get-MediaInfoSummary with the -Raw flag enabled.
EXAMPLE 1
PS>Get-MediaInfoValue '.\Meg Myers - Desire (Hucci Remix).mp3' -Kind General -Parameter Performer
output:
Meg Myers
Get the artist from a MP3 file.
EXAMPLE 2
PS>'.\Meg Myers - Desire (Hucci Remix).mp3' | Get-MediaInfoValue -Kind Audio -Parameter 'Channel(s)'
output:
2
Get the channel count in a MP3 file. Return types are always strings and if necessary must be cast to integer.
EXAMPLE 3
PS C:\>Get-MediaInfoValue '.\The Warriors.mkv' -Kind Audio -Index 1 -Parameter 'Language/String'
output:
English
Get the language of the second audio stream in a movie.
The Index parameter is zero based.
EXAMPLE 4
PS C:\>Get-MediaInfoValue '.\The Warriors.mkv' -Kind General -Parameter 'TextCount'
output:
2
Get the count of subtitle streams in a movie.
EXAMPLE 5
PS C:\>$mi = New-Object MediaInfo -ArgumentList $Path ;
$value1 = $mi.GetInfo($Kind, $Index, $Parameter) ;
$value2 = $mi.GetInfo($Kind, $Index, $Parameter) ;
$mi.Dispose() ;
To retrieve specific properties with highest possible performance the .NET class must be used directly: