Page 1 of 1

[Script] Powershell script to extract multiple videos at once

Posted: Sat Sep 25, 2021 5:46 pm
by Korben

I dont know if this should go here but I have a powershell script that allows to extract multiple videos at once.

Code: Select all

<#
This script will extract the faces for all the files in a specified folder. 
For a folder with this content:
Somevideo.mp4
An-OtherVideo.mp4

The final content of the foldre wouldc be:
Somevideo.mp4
Somevideo.fsa
\Somevideo\<Allimages>
An-OtherVideo.mp4
An-OtherVideo.fsa
\An-OtherVideo\<Allimages>
#>

conda activate "faceswap"
$everyN=1  #every nth frame
$minSize =1 #min face size
#Get all the files in a folder matching a filter.
$Files = Get-ChildItem -Path "D:\ExampleFolder\*.m*"

Write-Host "**********Found " $files.count " files***********"
$done= New-Object System.Collections.Generic.List[System.Object]
#loop through all the files and extract them if they dont already have a .fsa file
$files | foreach-object {     
$outPut= $_.DirectoryName +"\"+$_.BaseName
if((Get-Item "$($outPut)_alignments.fsa" -ErrorAction SilentlyContinue)) { #do nothing faces already extracted. Write-Host "Already exists:" $_.FullName } else { Write-Host "EXTRACTING:" $_.Name
#Adjust this according to your settings. python.exe C:\<pathToYourFaceSwap>\faceswap.py extract -i "$($_.FullName)" -o "$($outPut)" -M unet-dfl -D s3fd -A fan -nm none -min $minSize -l 0.4 -een $everyN -sz 256 -si 0 -L INFO
$done.add($_.FullName)
} } Write-Host "WORK DONE:" $done | foreach-object { Write-Host $_ }