Created
March 5, 2018 04:44
-
-
Save pezcode/051a79c9ffc1332627d7815383310ee6 to your computer and use it in GitHub Desktop.
FFmpeg: convert video to .mp4 (PowerShell script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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