Last active
May 14, 2020 18:59
-
-
Save cxy1997/babeb474db7a9e3f352e68ad39ad0cb2 to your computer and use it in GitHub Desktop.
Video to Gif in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import imageio | |
cap = cv2.VideoCapture('stillalive.mov') | |
cap.set(1 ,62) | |
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) - 62 | |
print('length=%d' % length) | |
frames = [] | |
for i in range(1668): | |
ret, frame = cap.read() | |
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) | |
imageio.mimsave("stillalive.gif", frames, fps=60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment