functions/public/Get-FFmpegFormat.ps1
function Get-FFmpegFormat { <# .SYNOPSIS Retrieves a list of supported file formats from FFmpeg. .EXAMPLE Get-FFmpegFormat .EXAMPLE Find all formats that support BOTH muxing and demuxing. Get-FFmpegFormat | Where-Object -FilterScript { $PSItem.Demux -and $PSItem.Mux } .EXAMPLE Find all FFmpeg formats that support ONLY muxing. Get-FFmpegFormat | Where-Object -FilterScript { $PSItem.Mux -and -not $PSItem.Demux } .EXAMPLE Find all FFmpeg formats that support ONLY demuxing. Get-FFmpegFormat | Where-Object -FilterScript { $PSItem.Demux -and -not $PSItem.Mux } .EXAMPLE Find all FFmpeg formats starting with 'd' Get-FFmpegFormat | Where-Object -FilterScript { $PSItem.Extension -like 'd*' } #> [CmdletBinding()] param () $FormatOutput = (ffmpeg -formats 2> $null).Split("`n") $Separator = $FormatOutput.IndexOf(' --') $FileFormats = $FormatOutput | Select-Object -Skip ($Separator+1) $AllFormats = @() foreach ($Format in $FileFormats) { $NewFormat = [PSCustomObject]@{ Demux = $false Mux = $false Extension = '' Description = '' } switch ($Format[1..2] -join '') { 'DE' { $NewFormat.Demux = $true $NewFormat.Mux = $true break } ' E' { $NewFormat.Mux = $true break } 'D ' { $NewFormat.Demux = $true break } } $null = $Format -match '( D | DE | E )(?<extension>[^\s]{3,})(?=\s)\s+(?<description>.*)' $NewFormat.Extension = $matches.extension $NewFormat.Description = $matches.description $AllFormats += $NewFormat #Write-Host -ForegroundColor Blue -Object $Format } return $AllFormats } Get-FFmpegFormat |