Skip to content

Instantly share code, notes, and snippets.

@aravindpai
Created April 28, 2020 19:24
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 aravindpai/db5cc085bb6cccb3e603b3cbaf1c3a79 to your computer and use it in GitHub Desktop.
Save aravindpai/db5cc085bb6cccb3e603b3cbaf1c3a79 to your computer and use it in GitHub Desktop.
%%time
frames = os.listdir('frames/')
frames.sort(key=lambda f: int(re.sub('\D', '', f)))
frame_array=[]
for i in range(len(frames)):
#reading each files
img = cv2.imread('frames/'+frames[i])
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
height, width, layers = img.shape
size = (width,height)
#inserting the frames into an image array
frame_array.append(img)
out = cv2.VideoWriter('sample_output.mp4',cv2.VideoWriter_fourcc(*'DIVX'), 25, size)
for i in range(len(frame_array)):
# writing to a image array
out.write(frame_array[i])
out.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment