小编lia*_*ong的帖子

类型错误:VideoWriter() 缺少必需参数“frameSize”(位置 5),opencv-python ==4.4.0.42

我想使用以下代码创建 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() 吗?非常感谢

python opencv video-capture

5
推荐指数
1
解决办法
9599
查看次数

标签 统计

opencv ×1

python ×1

video-capture ×1