Ask Your Question
0

Alter the video dimensions

asked 2016-04-11 16:37:19 -0600

As shown in the code below, currently I am getting video to save at 640X480, however I'm looking to modify the dimensions of the saved video. Every time I attempt to simply change the parameters within the parentheses, I get this error: "warning: Error pushing buffer to GStreamer pipeline (/builddir/build/BUILD/opencv-2.4.12.3/modules/highgui/src/cap_gstreamer.cpp:1609)"

I'm using Python 2.7, and I'm assuming the issue is trying to send too much information/data from the video. I was hoping someone would be able to help out a little. Thanks :)

import numpy as np import cv2

video = cv2.VideoCapture(0)

fourcc = cv2.cv.CV_FOURCC(*'MJPG') out = cv2.VideoWriter('sample.avi',fourcc,15.0, (640,480))

while video.isOpened(): ret, frame = video.read() if ret == True: out.write(frame)

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

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-04-12 02:25:56 -0600

pklab gravatar image

frame size in out.write(frame) must be the same as the size argument in the constructor VideoWriter.

You could change the size properties to VideoCapture or resize the grabbed frame as your needs

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-04-11 16:37:19 -0600

Seen: 1,150 times

Last updated: Apr 12 '16