Skip to content

Instantly share code, notes, and snippets.

@pezcode
Created March 5, 2018 04:44
Show Gist options
  • Save pezcode/051a79c9ffc1332627d7815383310ee6 to your computer and use it in GitHub Desktop.
Save pezcode/051a79c9ffc1332627d7815383310ee6 to your computer and use it in GitHub Desktop.
FFmpeg: convert video to .mp4 (PowerShell script)
# convert video to .mp4 (x264)
# copies audio stream
param(
[Parameter(Mandatory=$true)][string]$InputPath,
[string]$OutputPath,
[int]$Height=0, # 0 for input height
[switch]$Fast=$false
)
if(-not $OutputPath) {
$OutputPath = [System.IO.Path]::ChangeExtension($InputPath, "mp4")
}
$filters = "scale=-1:${Height}:flags=lanczos"
$preset = if($Fast) { 'faster' } else { 'slow' }
ffmpeg -y -v warning -i $InputPath -vf $filters -c:v libx264 -preset $preset -crf 18 -c:a copy $OutputPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment