-
-
Save sahilsk/8f1334aa9fc96f0874d08020a8fe0218 to your computer and use it in GitHub Desktop.
Video Cropping and Frame addition
This file contains hidden or 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