-
Notifications
You must be signed in to change notification settings - Fork 0
/
gifconvert.py
27 lines (22 loc) · 887 Bytes
/
gifconvert.py
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
#!/usr/bin/python3.7
# UTF8
# Date: Thu 11 Jul 2019 11:39:39 CEST
# Author: Nicolas Flandrois
# Description: This script is a simple video converter. Initially intended to
# convert videos into GIF files. See further application to convert in other
# formats with imageio
# Requierments: imageio & imageio-ffmpeg (pip install imageio imageio-ffmpeg)
import imageio
import os
def gifMaker(inputPath, targetFormat):
outputPath = os.path.splitext(inputPath)[0] + targetFormat
print(f"converting {inputPath} \n to {outputPath}")
reader = imageio.get_reader(inputPath)
fps = reader.get_meta_data()['fps']
writer = imageio.get_writer(outputPath, fps=fps)
for frame in reader:
writer.append_data(frame)
print(f'Done! \n {inputPath} has been converted to {outputPath}')
writer.close()
clip = os.path.abspath('pathtovideo.mp4')
gifMaker(clip, '.gif')