[Script] Powershell script to extract multiple videos at once

Want to know about the Faceswap's Face Extraction process? Got tips, ideas or just want to learn about how it all works? Then this is the place for you

Forum rules

Read the FAQs and search the forum before posting a new topic.

This forum is for discussing tips and understanding the process involved for Extracting and preparing face sets for training a model in Faceswap.

If you have found a bug are having issues with the Extraction process not working, then you should post in the Extract Support forum.

Please mark any answers that fixed your problems so others can find the solutions.

User avatar
Posts: 21
Joined: Wed Aug 19, 2020 3:17 pm
Has thanked: 2 times
Been thanked: 3 times

[Script] Powershell script to extract multiple videos at once

Post 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:

The final content of the foldre wouldc be:

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
} } Write-Host "WORK DONE:" $done | foreach-object { Write-Host $_ }