Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import os
- import datetime
- import configparser
- from time import sleep as s
- config = configparser.ConfigParser()
- config.read('config.ini')
- dateTime = datetime.datetime.now()
- fps = int(config['SETTINGS']['FPS'])
- outputName = 'Render_' + config['SETTINGS']['OUTPUT_COUNT']
- repository = config['SETTINGS']['repository']
- print("Settings:\n")
- print("FPS: " + str(fps))
- print("Output Name: " + str(outputName))
- print("Image File: " + str(repository))
- verify = input("\nPress [Enter] if these settings are correct ~ ")
- if verify == '':
- next
- else:
- quit()
- print("\nRendering...\n")
- s(2)
- images = []
- for f in os.listdir(repository):
- images.append(f)
- print("Loaded image: [" + f + "]")
- s(0.01)
- s(2)
- print("\nReading frame data...")
- frame = cv2.imread(repository + images[0])
- height, width, channels = frame.shape
- s(2)
- print("Creating " + outputName + ".mp4...")
- fourcc = cv2.VideoWriter_fourcc(*'mp4v')
- out = cv2.VideoWriter(outputName + '.mp4', fourcc, fps, (width, height))
- s(2)
- count_output = int(config['SETTINGS']['OUTPUT_COUNT'])
- count_output += 1
- parse = configparser.SafeConfigParser()
- parse.read('config.ini')
- parse.set('SETTINGS', 'OUTPUT_COUNT', str(count_output))
- with open('config.ini', 'w') as configfile:
- parse.write(configfile)
- print()
- for i in images:
- frame = cv2.imread(repository + i)
- out.write(frame)
- print("Created frames: [" + i + "]")
- print("\nRendered!")
- print("Closing processes...")
- out.release()
- cv2.destroyAllWindows()
- s(2)
Add Comment
Please, Sign In to add comment