Convert from frames to video

Got questions or tips about the Conversion process? This is the place to discuss them.

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 with Converting faces from your trained model.

If you are having issues with the Convert process not working as you would expect, then you should post in the Convert Support forum.

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

User avatar
Erik Loo
Posts: 1
Joined: Wed Nov 04, 2020 2:08 am

Convert from frames to video

Post by Erik Loo »

I noticed quite a few people have trouble converting frames to video. This can actually be done quite easily with OpenCV.
You just need to:
Step 1. Install OpenCV-Python. The instructions can be found at
Step 2: Create an image folder to store all the swapped images.
Step 3: Create a Python script and copy and paste the following code:


Code: Select all

import cv2
import numpy as np
import glob

img_array = []
# note glob does not take absolute or relative path
for filename in glob.glob('images/*.png'):
    img = cv2.imread(filename)
    height, width, layers = img.shape
    # cv2.imshow('img', img)
    print("processing..." + filename)
    size = (width, height)

print("Outputting file...")
out = cv2.VideoWriter('ouput.avi', cv2.VideoWriter_fourcc(*'DIVX'),30, size)

for i in range(len(img_array)):
    print("writing img " + str(i) + "/" + str(len(img_array)))

Notes: Make sure your python script is at the same subdirectory level as the image folder.

Step 4:Run the script and be patient.

Hope it helps. My gratitude towards the developers of Faceswap . :-)

User avatar
Posts: 1503
Joined: Fri Jul 12, 2019 12:53 am
Answers: 126
Has thanked: 54 times
Been thanked: 288 times

Re: Convert from frames to video

Post by torzdf »

We actually have the EFFMPEG tool to do exactly this, but it doesn't hurt to have another method.

My word is final