代码如下:
import cv2 as cv
import numpy as np
def video_demo():
cap = cv.VideoCapture("C:\Users\joysu\Videos\dancing.mp4")
w = cap.get(cv.CAP_PROP_FRAME_WIDTH)
h = cap.get(cv.CAP_PROP_FRAME_HEIGHT)
fps = cap.get(cv.CAP_PROP_FPS)
output = cv.VideoWriter("C:\test01.mp4",cv.CAP_ANY.np.int(cap.get(cv.CAP_PROP_FOURCC)), fps, (np.int(w), np.int(h)), True)
print(w, h, fps)
while True:
ret, frame = cap.read()
if ret is not True:
break
cv.imshow("frame", frame)
output.write(frame)
c = cv.waitKey(10)
if c == 27:
break
cv.destroyAllWindows()
if name == 'main':
video_demo()
报错信息:
Traceback (most recent call last):
File "C:\Users\joysu\PycharmProjects\pythonProject01\opencvtest01.py", line 83, in
video_demo()
File "C:\Users\joysu\PycharmProjects\pythonProject01\opencvtest01.py", line 63, in video_demo
** cv.CAP_ANY.np.int(cap.get(cv.CAP_PROP_FOURCC)), fps, (np.int(w), np.int(h)), True)**
AttributeError: 'int' object has no attribute 'np'