Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Last active November 29, 2024 03:06
Show Gist options
  • Save Hashbrown777/e939696cd8570a99b0e623712aa25363 to your computer and use it in GitHub Desktop.
Save Hashbrown777/e939696cd8570a99b0e623712aa25363 to your computer and use it in GitHub Desktop.
1..56 `
| %{ "_$($_.ToString().PadLeft(2, '0')).mp4" } `
| &{
Begin {
$filter = ''
$files = @()
}
Process {
$filter += "[$($files.Count / 2):0] [$($files.Count / 2):1] "
$files += '-i',$_
}
End {
& 'C:\Program Files\ffmpeg\bin\ffmpeg.exe' `
$files `
-fps_mode vfr `
-filter_complex "${filter}concat=n=$($files.Count / 2):v=1:a=1 [v] [a]" `
-map '[v]' `
-map '[a]' `
-vcodec libx264 `
-crf 10 `
___720_10.mp4
}
}
. ~/async.ps1
gci -File `
| %{
if ($_.Name -match '^(\d+)\.mp4$') {
$Matches[1]
}
} `
| Async `
-Func { Process {
&'C:\Program Files\ffmpeg\bin\ffmpeg.exe' `
-i "$_.mp4" `
-filter_complex '[0:a:0][0:a:1]amix=2:weights=0.75 2[aout]' `
-map '0:V:0' `
-map '[aout]' `
-c:v copy `
"_$_.mp4"
} }
$input=960,540
$output=150,300
$crop=($input[1] * $output[0] / $output[1]),$input[1]
$time=2.17
$centre=$input[0]/2 - $crop[0]/2
$edge=$input[0] - $crop[0]
$wait=4
&'C:/Program Files/ffmpeg/bin/ffmpeg' `
-hide_banner `
-loglevel error `
-stats `
-y `
-an `
-i 'GLLeqAH.mp4' `
-filter:v "crop=$($crop -join ':'):$centre+max(0\,$wait*t/$time-$($wait - 1))*$($edge-$centre):0,scale=$($output -join ':')" `
_.gif
# -vcodec libx264 `
# -crf 0 `
1..56 `
| %{ "_$($_.ToString().PadLeft(2, '0')).mp4" } `
| &{
Begin {
$files = @()
$lines = ''
$v = ''
$a = ''
}
Process {
$files += '-i',$_
$lines += "movie=$_, scale=1920:1080 [v$($files.Count / 2)] ; amovie=$_ [a$($files.Count / 2)] ; "
$v += " [v$($files.Count / 2)]"
$a += " [a$($files.Count / 2)]"
}
End {
& 'C:\Program Files\ffmpeg\bin\ffmpeg.exe' `
$files `
-fps_mode vfr `
-filter_complex "$lines$v concat=n=$($files.Count / 2):v=1:a=0 [outv] ;$a concat=n=$($files.Count / 2):v=0:a=1 [outa]" `
-map '[outv]' `
-map '[outa]' `
-vcodec libx264 `
-crf 10 `
_.mp4
}
}
@Hashbrown777
Copy link
Author

transpose=0 90° counter-clockwise and vertical flip (default)
transpose=1 90° clockwise
transpose=2 90° counter-clockwise
transpose=3 90° clockwise and vertical flip

@Hashbrown777
Copy link
Author

centre and pad to size
-vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1"

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