我想使用以下代码创建 VideoWriter:
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter('out.mp4',fourcc,fps,(frame_width,frame_height))
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
TypeError: VideoWriter() missing required argument 'frameSize' (pos 5)
Run Code Online (Sandbox Code Playgroud)
当我将代码更改为:
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter(filename='out.mp4',fourcc=fourcc,fps=fps,frameSize=(frame_width,frame_height))
Run Code Online (Sandbox Code Playgroud)
我收到另一个错误:
TypeError: VideoWriter() missing required argument 'apiPreference' (pos 2)
Run Code Online (Sandbox Code Playgroud)
所以我将代码更改为:
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter(filename='out.mp4',apiPreference=0,fourcc=fourcc,fps=fps,frameSize=(frame_width,frame_height))
Run Code Online (Sandbox Code Playgroud)
我收到错误:
TypeError: VideoWriter() missing required argument 'params' (pos 6)
Run Code Online (Sandbox Code Playgroud)
我该如何解决它?谁能告诉我如何使用 api:VideoWriter() 吗?非常感谢