SolarisFalls

Main PY File

Aug 20th, 2020 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. import cv2
  2. import os
  3. import datetime
  4. import configparser
  5. from time import sleep as s
  6.  
  7. config = configparser.ConfigParser()
  8. config.read('config.ini')
  9.  
  10. dateTime = datetime.datetime.now()
  11.  
  12. fps = int(config['SETTINGS']['FPS'])
  13. outputName = 'Render_' + config['SETTINGS']['OUTPUT_COUNT']
  14. repository = config['SETTINGS']['repository']
  15.  
  16. print("Settings:\n")
  17. print("FPS:             " + str(fps))
  18. print("Output Name:     " + str(outputName))
  19. print("Image File:      " + str(repository))
  20.  
  21. verify = input("\nPress [Enter] if these settings are correct ~ ")
  22. if verify == '':
  23.     next
  24. else:
  25.     quit()
  26.  
  27. print("\nRendering...\n")
  28. s(2)
  29.  
  30. images = []
  31. for f in os.listdir(repository):
  32.     images.append(f)
  33.     print("Loaded image: [" + f + "]")
  34.     s(0.01)
  35.  
  36. s(2)
  37.  
  38. print("\nReading frame data...")
  39. frame = cv2.imread(repository + images[0])
  40. height, width, channels = frame.shape
  41. s(2)
  42.  
  43. print("Creating " + outputName + ".mp4...")
  44. fourcc = cv2.VideoWriter_fourcc(*'mp4v')
  45. out = cv2.VideoWriter(outputName + '.mp4', fourcc, fps, (width, height))
  46. s(2)
  47.  
  48. count_output = int(config['SETTINGS']['OUTPUT_COUNT'])
  49. count_output += 1
  50.  
  51. parse = configparser.SafeConfigParser()
  52. parse.read('config.ini')
  53. parse.set('SETTINGS', 'OUTPUT_COUNT', str(count_output))
  54. with open('config.ini', 'w') as configfile:
  55.     parse.write(configfile)
  56.  
  57. print()
  58. for i in images:
  59.     frame = cv2.imread(repository + i)
  60.     out.write(frame)
  61.     print("Created frames: [" + i + "]")
  62.  
  63. print("\nRendered!")
  64. print("Closing processes...")
  65.  
  66. out.release()
  67. cv2.destroyAllWindows()
  68. s(2)
  69.  
Add Comment
Please, Sign In to add comment