AtillaA
AtillaA

Reputation: 91

Saving cropped Video with opencv

I try to crop away the left most part of my video and save the processed video. The cv2.imshow part works fine but the saved file can't be played. Thanks in advance!

import cv2


cap = cv2.VideoCapture('Vid.mov')
outcrop = cv2.VideoWriter('outcrop.mov', -1, 20.0, (640,480))

while True:
    ret, frame = cap.read()
    sky = frame[100:, 100:]
    cv2.imshow('Video', sky)
    outcrop.write(sky)         #I guess the problem lies in "(sky)" ??

    k = cv2.waitKey(5) & 0xFF
    if k == 27:
        break

cap.release()
outcrop.release()
cv2.destroyAllWindows()

Upvotes: 1

Views: 1094

Answers (1)

AtillaA
AtillaA

Reputation: 91

try to resize sky to 640x480, try

sky = cv2.resize(sky, (640, 480))

and write it

Upvotes: 2

Related Questions