I\'m trying to output a video file with opencv and python but the video is not p
ID: 3853972 • Letter: I
Question
I'm trying to output a video file with opencv and python but the video is not playing.
Python 2.7.13 (v2.7.13: a06454b1afa1, Dec 17 2016, 20: 42: 59) [MSC v. 1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. Traceback (most recent call last): File "C: Python27img.py", line 3, in qq NameError: name 'qq' is not defined import numpy as np import cv2 cap - cv2.VideoCapture ('test.mp4') while (Cap.isOpened()): ret, frame - cap.red() if ret == True: gray = cv2.cvtColor (frame, cv2.COLOR_BGR2GRAY) cv2. how('frame', gray) if gv2.waitkey(1) & 0xEE == ord('g): break else: break cap.release() cv2.destroyAllWindows()Explanation / Answer
main.py
import numpy as np
import cv2
import os
#For primary Webcam Feed :- 0
#For secondary Webcam Feed :- 1
#Capturing Images.
cap=cv2.VedioCapture(0) #For Primary webcam
#To use recoded vedio as a feed
'''cap=cv2.VedioCapture('Location of the vedio')'''
#To save each frames
fourcc=cv2.VedioWriter("Output_name.avi",fourcc,20.0,(720,640))
#Looping the continuos caption .
while True:
ret,frame=cap.read()
grey=cv2.cvtColor(frame,cv2.COLOR_BGR2GREY) cv2.imshow("Grey Title",grey)
cv2.imshow("Title",frame)
out.write(frame)
if cv2.waitKey(1) & 0xFF=='q':
break
cap.release()
out.release()
cv2.destroyAllWindows()
=================================================================================