Skip to content

Instantly share code, notes, and snippets.

@JamesDBartlett3
Created August 10, 2021 14:45
Show Gist options
  • Save JamesDBartlett3/ecac4616fae42178f187fa7ef10e722d to your computer and use it in GitHub Desktop.
Save JamesDBartlett3/ecac4616fae42178f187fa7ef10e722d to your computer and use it in GitHub Desktop.
Compress-WebinarVideo: A PowerShell function that leverages ffmpeg to reduce the size of a webinar video file for more efficient storage
#------------------------------------------------------------------------------------------------------------------
# Author: James Bartlett @jamesdbartlett3
# Synopsis: Uses ffmpeg to compress a webinar video to a much more manageable size
# Requires: ffmpeg CLI application, accessible in path
# Assumes:
#------------------------------------------------------------------------------------------------------------------
function Compress-WebinarVideo {
Param(
[Parameter(Mandatory=$True, Position=0, ValueFromPipeline=$True)]
[string]$inputVid,
[Parameter(Mandatory=$False, Position=1, ValueFromPipeline=$False)]
[int]$frameRate=12
)
[string]$targetDir = Get-ItemPropertyValue -Path $inputVid -Name FullName | Split-Path -Path {$_}
[string]$inputFileBase = Get-ItemPropertyValue -Path $inputVid -Name BaseName
[string]$inputFileExtension = Get-ItemPropertyValue -Path $inputVid -Name Extension
[string]$outputFile = "$targetDir\$inputFileBase" + "_[" + $frameRate + "fps]" + $inputFileExtension
ffmpeg -i $inputVid -c:v libx265 -filter:v fps=fps=$frameRate -ac 1 -ar 22050 $outputFile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment