Created
December 17, 2015 23:34
-
-
Save celoyd/06c845b55c3e4f584151 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# based on https://gist.github.com/celoyd/55b8876c02e968c599f8 | |
# makes lots of big assumptions like 1280x720 video | |
import numpy as np | |
import cv2 | |
from sys import argv | |
movf, outf = argv[1:] | |
viddy = cv2.VideoCapture(movf) | |
# width = viddy.get(3) # can you tell this API is by C programmers? | |
# height = viddy.get(4) | |
rows = np.empty((720, 1280, 3)) | |
ct = 0 | |
while ct < 720: | |
print "%s/720" % (ct+1) | |
okay, frame = viddy.read() | |
if not okay: break | |
rows[ct,...] = frame[ct,...] | |
ct += 1 | |
cv2.imwrite(outf, rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment