Ask Your Question

Revision history [back]

Video corrupted after using Canny then writing. Can you guys spot the mistake

import cv2
import numpy as np
cap = cv2.VideoCapture("video.mp4")
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
out = cv2.VideoWriter('manipulated_video.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 25, (frame_width,frame_height))
while(cap.isOpened()):
    ret, frame = cap.read()
    if ret == True:
        edges = cv2.Canny(frame, 100, 200)
        cv2.imshow('Edges', edges)
        if cv2.waitKey(25) & 0xFF == ord('q'):
            break
    else:
        break
cap.release()
out.release()
cv2.destroyAllWindows()