Skip to content

Instantly share code, notes, and snippets.

@williammincy
Created March 15, 2023 10:31
Show Gist options
  • Save williammincy/3bd3f8ef9c6b280b440f73ce6362ede0 to your computer and use it in GitHub Desktop.
Save williammincy/3bd3f8ef9c6b280b440f73ce6362ede0 to your computer and use it in GitHub Desktop.
Creates a video from a folder of images using ffmpeg, with an optional frame rate parameter
function New-VideoFromImages {
param (
[string]$InputFolder,
[string]$OutputFile,
[int]$FrameRate = 30
)
$cmd = "ffmpeg -framerate $FrameRate -pattern_type glob -i '$InputFolder\*.png' -vf `"scale=1280:-1:flags=lanczos`" -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p -vf `"pad=ceil(iw/2)*2:ceil(ih/2)*2`" `"$OutputFile`""
Invoke-Expression $cmd
}
@williammincy
Copy link
Author

This would be invoked like:
.\New-VideoFromImages.ps1 -InputFolder "C:\Images" -OutputFile "output.mp4" -FrameRate 24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment