Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoWriter issues

I'm trying to save a video but I have really problems, because I create the video but when I try to play it doesn't work just stay black. I try to follow the opencv documentation but it didn't works.

https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html

Im on win10, maybe its important to know...?

A piece of code:

import numpy as np
import cv2

cap = cv2.VideoCapture("myVideo.mp4")

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('newVideo.avi',fourcc, 20.0, (640,480))

while(cap.isOpened()):
    grabbed, frame = cap.read()
    if (grabbed==True):
        frame = cv2.flip(frame,0)
        out.write(frame)

        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break


cap.release()
out.release()
cv2.destroyAllWindows()