Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2019-06-14 19:30:26 -0600

Nbb gravatar image

why my saved video cannot play?

I read video, do operation, then save. But why cant my video open? I am using windows 10.

 import numpy as np
import cv2

vid = cv2.VideoCapture("./results/videos/0.avi")
out = cv2.VideoWriter("./results/videos/0_processed.avi", cv2.VideoWriter_fourcc(*'MJPG'), 10, (960,378))
while(vid.isOpened()):
    ret, im = vid.read()
    if(ret==False):
        break

    im = im.astype(np.float)
    im_median = np.median(im)
    im = im + (155-im_median)
    im[im > 255] = 255
    im = im.astype(np.uint8)    
    out.write(im)

# When everything done, release the capture
vid.release()
out.release()