Created
June 8, 2020 15:24
-
-
Save Cyklan/718538fe37a5702a39a24a5856558dd9 to your computer and use it in GitHub Desktop.
Stitch multiple video-files together in batches of n
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
param([int]$episodes_per_file) | |
$file_count = ( Get-ChildItem .\input | Measure-Object).Count; | |
$batches = $file_count / $episodes_per_file; | |
$files = Get-ChildItem .\input | | |
Foreach-Object {$_.Name} | |
for ($i = 0; $i -lt $batches; $i++) { | |
$file_text = 'ffmpeg -i "concat:' | |
for ($j = 0; $j -lt $episodes_per_file; $j++) { | |
$file = $files[$i * $episodes_per_file + $j] | |
$file_text += ".\input\$file|" | |
} | |
$file_text = $file_text.Substring(0, $file_text.Length - 1); | |
$file_text += "`"-c:a copy -c:v copy .\output\$i.mp4" | |
Invoke-Expression $file_text | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment