< Back
Get-MediaDuration
Post
NAME Get-MediaDuration
SYNOPSIS
Query duration time and other properties from video or audio files using ffprobe command.
SYNTAX
Get-MediaDuration [[-Path] <String[]>] [[-Filter] <String>] [-Recurse] [-Total] [-Progress] [[-items] <Object[]>]
[<CommonParameters>]
DESCRIPTION
You can generate the item list with Get-ChildItem command and pipe it into
Get-MediaDuration cmdlet. The resulting output is a list of objects and
can be pipelined as well into Sort-Object, Where-Object, Measure-Object, etc.
Mind that Measure-Object requires an integer as an input property, so you'll
have to convert the Duration field of type TimeSpan, to milliseconds
(see examples section).
PARAMETERS
-Path <String[]>
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Filter <String>
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Recurse [<SwitchParameter>]
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Total [<SwitchParameter>]
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Progress [<SwitchParameter>]
Show progress bar while calculating. Defaults to $true when the Total
parameter is $true.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-items <Object[]>
Required? false
Position? 3
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None or list of items from Get-ChildItem.
OUTPUTS
Object[]. Returns the list of objects, use the Duration property to get the
time of media. When using -Total parameter, outputs System.String for convinience.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-MediaDuration -Recurse -Total
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-MediaDuration -Recurse -Total -Path "Podcasts"
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-MediaDuration -Recurse -Total '.\\Audiobook A','.\\Audiobook B' '*.m4a'
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Get-MediaDuration -Recurse "Movies" '*.*'
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>Get-MediaDuration -Recurse "Movies" '*.mp4' -Total
-------------------------- EXAMPLE 6 --------------------------
PS C:\\>Get-MediaDuration -Recurse "Movies" '*.mp4' | ForEach-Object { $_.Duration = $_.Duration.TotalMilliseconds
; $_ }
-------------------------- EXAMPLE 7 --------------------------
PS C:\\>Get-MediaDuration -Recurse `
| ForEach-Object { $_.Duration = $_.Duration.TotalMilliseconds ; $_ } `
| Measure-Object -Sum Duration `
| % { [TimeSpan]::FromMilliseconds($_.Sum).ToString() }
-------------------------- EXAMPLE 8 --------------------------
PS C:\\>Get-ChildItem -Recurse | Get-MediaDuration
-------------------------- EXAMPLE 9 --------------------------
PS C:\\>Get-ChildItem -Recurse | Get-MediaDuration -Total
-------------------------- EXAMPLE 10 --------------------------
PS C:\\>Get-ChildItem -Recurse "Movies" | Get-MediaDuration | Sort Duration -Descending
RELATED LINKS
https://superuser.com/questions/650291/ ... in-seconds
SYNOPSIS
Query duration time and other properties from video or audio files using ffprobe command.
SYNTAX
Get-MediaDuration [[-Path] <String[]>] [[-Filter] <String>] [-Recurse] [-Total] [-Progress] [[-items] <Object[]>]
[<CommonParameters>]
DESCRIPTION
You can generate the item list with Get-ChildItem command and pipe it into
Get-MediaDuration cmdlet. The resulting output is a list of objects and
can be pipelined as well into Sort-Object, Where-Object, Measure-Object, etc.
Mind that Measure-Object requires an integer as an input property, so you'll
have to convert the Duration field of type TimeSpan, to milliseconds
(see examples section).
PARAMETERS
-Path <String[]>
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Filter <String>
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Recurse [<SwitchParameter>]
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Total [<SwitchParameter>]
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Progress [<SwitchParameter>]
Show progress bar while calculating. Defaults to $true when the Total
parameter is $true.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-items <Object[]>
Required? false
Position? 3
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None or list of items from Get-ChildItem.
OUTPUTS
Object[]. Returns the list of objects, use the Duration property to get the
time of media. When using -Total parameter, outputs System.String for convinience.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-MediaDuration -Recurse -Total
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-MediaDuration -Recurse -Total -Path "Podcasts"
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-MediaDuration -Recurse -Total '.\\Audiobook A','.\\Audiobook B' '*.m4a'
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Get-MediaDuration -Recurse "Movies" '*.*'
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>Get-MediaDuration -Recurse "Movies" '*.mp4' -Total
-------------------------- EXAMPLE 6 --------------------------
PS C:\\>Get-MediaDuration -Recurse "Movies" '*.mp4' | ForEach-Object { $_.Duration = $_.Duration.TotalMilliseconds
; $_ }
-------------------------- EXAMPLE 7 --------------------------
PS C:\\>Get-MediaDuration -Recurse `
| ForEach-Object { $_.Duration = $_.Duration.TotalMilliseconds ; $_ } `
| Measure-Object -Sum Duration `
| % { [TimeSpan]::FromMilliseconds($_.Sum).ToString() }
-------------------------- EXAMPLE 8 --------------------------
PS C:\\>Get-ChildItem -Recurse | Get-MediaDuration
-------------------------- EXAMPLE 9 --------------------------
PS C:\\>Get-ChildItem -Recurse | Get-MediaDuration -Total
-------------------------- EXAMPLE 10 --------------------------
PS C:\\>Get-ChildItem -Recurse "Movies" | Get-MediaDuration | Sort Duration -Descending
RELATED LINKS
https://superuser.com/questions/650291/ ... in-seconds