Skip to content

Instantly share code, notes, and snippets.

@cxy1997
Last active May 14, 2020 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cxy1997/babeb474db7a9e3f352e68ad39ad0cb2 to your computer and use it in GitHub Desktop.
Save cxy1997/babeb474db7a9e3f352e68ad39ad0cb2 to your computer and use it in GitHub Desktop.
Video to Gif in Python
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