Open antpas opened 6 years ago
def make_video():
try: os.chdir(r"C:\Users\antth\PycharmProjects\EC500Project2\output") for index, oldfile in enumerate(glob.glob("*.jpg"), start=1): newfile = 'image{}.jpg'.format(index) os.rename(oldfile, newfile) os.chdir(r"C:\Users\antth\PycharmProjects\EC500Project2\output") os.system('ffmpeg -y -loglevel panic -framerate 1/3 -i image%d.jpg video.avi') except (RuntimeError, TypeError, NameError): print("ERROR: ffmpeg unable to to create video") pass else: print("Video done. Saved as out.mp4")
This is hard-coded for my directory on my windows machine.
Function definition to make video from images using Ffmpeg
def make_video():
uses subprocess.call to use the ffmpeg command, also crops images to fit within frame