Ask Your Question

nsbendre's profile - activity

2020-06-09 10:07:55 -0600 received badge  Famous Question (source)
2019-10-09 23:22:11 -0600 received badge  Notable Question (source)
2019-01-02 07:29:07 -0600 received badge  Popular Question (source)
2017-04-25 14:35:25 -0600 asked a question Video Resizing and saving it as .avi

How do I resize a video?? The original resolution of a video is 123x456 and I want to resize the video and save it in format of width =320 and height = 240. Below is the code for the same.

import numpy as np

import cv2

cap = cv2.VideoCapture('walking.avi')

print (cap.get(3), 'x', cap.get(4))

cap_w = cap.set(3,320)

cap_h = cap.set(4,240)

print (cap_w, 'x', cap_h)

height = 240

width = 320

fourcc = cv2.VideoWriter_fourcc(*'XVID')

out = cv2.VideoWriter('cap_output.avi',fourcc, 20.0, (320,240))

cap.release()

cv2.destroyAllWindows()

The print output I get is:

768.0 x 576.0

False x False

Thank you.