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.

Locked
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 https://pypi.org/project/opencv-python/
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)
    img_array.append(img)

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)))
    out.write(img_array[i])
out.release()

#########
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
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 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

Locked