1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
import numpy as np
import cv2, time, random, os
from PIL import Image
output = r'C:\Users\toto\Desktop\emojis\frames'
for i,f in enumerate(paths): #paths = liste des chemins des images
img = cv2.imread(os.path.join(output,f))
imgs.append(img)
height, width, layers = img.shape
size = (width,height)
duration = int(f.split('.')[0].split('_')[1]) #msec
print(duration)
fps = nb_of_imgs / (duration/1000)
print('Final fps :',fps)
input("Press any key to create the movie")
out = cv2.VideoWriter('Matrix.avi',cv2.VideoWriter_fourcc(*'DIVX'), fps, size) #of =Output FPS
#print('QUALITY :',out.get(cv2.VIDEOWRITER_PROP_QUALITY))
#out.set(cv2.VIDEOWRITER_PROP_QUALITY,1000)
#print('QUALITY :',out.get(cv2.VIDEOWRITER_PROP_QUALITY))
for i in range(len(imgs)):
out.write(imgs[i])
out.release()
print("VIDEO RELEASED")
input("Press any key to add audio")
import subprocess
subprocess.run("ffmpeg -i Matrix.avi -i Matrix.m4a -c copy Output-HFPS.avi") |
Partager