VideoWriter什么都不写

VideoWriter do not write anything

本文关键字:什么 VideoWriter      更新时间:2023-10-16

当我尝试使用VideoWriter编写帧时,它不起作用。我已经尝试了很多FOURCC代码,比如defaul、h264、mjpg、divx、xvid等。是的,我已经安装了带有所有必要配置的ffmpeg(--enable-shared、--enable-libx264…),opencv安装支持ffmpeg。

我已经在谷歌上搜索了很多,我发现的所有东西都几乎不能解决这个问题,这在OpenCV中反复出现。这个代码是最简单的,几周前它就工作了,但事实并非如此。

一些见解:get(CV_CAP_PROP_FPS)返回未知的选项消息,其值为-1(该集也是如此)。opencv的cmake过程的以下部分也很有趣:

-- Could NOT find Jasper (missing:  JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
-- checking for module 'gstreamer-video-1.0'
--   package 'gstreamer-video-1.0' not found
-- checking for module 'gstreamer-app-1.0'
--   package 'gstreamer-app-1.0' not found
-- checking for module 'gstreamer-riff-1.0'
--   package 'gstreamer-riff-1.0' not found
-- checking for module 'gstreamer-pbutils-1.0'
--   package 'gstreamer-pbutils-1.0' not found
-- checking for module 'gstreamer-base-0.10'
--   package 'gstreamer-base-0.10' not found
-- checking for module 'gstreamer-video-0.10'
--   package 'gstreamer-video-0.10' not found
-- checking for module 'gstreamer-app-0.10'
--   package 'gstreamer-app-0.10' not found
-- checking for module 'gstreamer-riff-0.10'
--   package 'gstreamer-riff-0.10' not found
-- checking for module 'gstreamer-pbutils-0.10'
--   package 'gstreamer-pbutils-0.10' not found
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found

Opencv 2.4.10Ubuntu 14.04

编辑:我发现问题是VideoWriter对象没有打开,即使在构造函数调用之后也是如此

VideoWriter wr(outputFile, CV_FOURCC('D','I','V','X'), capture.get(CV_CAP_PROP_FPS,Size(capture.get(CV_CAP_PROP_FRAME_WIDTH),capture.get(CV_CAP_PROP_FRAME_HEIGHT)));

使用CV_CAP_PROP_FPS使OpenCV在安全时间内显示以下消息:

HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(5) - Invalid argument

为什么这个hqppen,我该怎么修?

给出输出文件。"带有扩展"试试这个:示例-带CV_FOURCC('M','J','P','G')的outputfile.avi