Created
March 31, 2018 16:31
-
-
Save jhyang12345/e3c77132c8cfcb1aedf97c3f7744a678 to your computer and use it in GitHub Desktop.
Simple python file to create video and gif from mov
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
from moviepy.editor import * | |
from moviepy.video.fx.all import crop, fadeout | |
import cv2 | |
def get_image_clip(): | |
images_list = ["frame79.jpg"] * 30 | |
print(images_list) | |
clip = ImageSequenceClip(images_list, fps=30) | |
clip = fadeout(clip, 1, final_color=[32, 32, 32]) | |
return clip | |
def get_frames(): | |
vidcap = cv2.VideoCapture("jariyo.mp4") | |
success, image = vidcap.read() | |
count = 0 | |
while success: | |
success,image = vidcap.read() | |
print('Read a new frame: ', success) | |
cv2.imwrite("frame%d.jpg" % count, image) # save frame as JPEG file | |
count += 1 | |
def main(): | |
clip = VideoFileClip("jariyo.mov") | |
clip = crop(clip, x1=690, x2=1165, y1=460, y2=740) | |
clip = concatenate_videoclips([clip, get_image_clip()]) | |
clip.write_videofile("jariyo.mp4") | |
clip.write_gif("jariyo.gif", fps=24) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment