When I try to use VideoWriter to write a frame it does not work. I already tried lots of FOURCC codes, like the defaul, h264, mjpg, divx, xvid, etc. And yes, I have installed ffmpeg with all the necessary configurations (--enable-shared, --enable-libx264, ...) and the opencv installation is with ffmpeg support on.
I already google it a lot and everything that I found do not even nearly solve this problem, that is recurrent in OpenCV. The code is the simplest possible, and it worked a few weeks back, but not it does not.
A few insights: get(CV_CAP_PROP_FPS) returns the unknown option message, with the -1 value (the same happens for the set). The following part of the cmake process of opencv is also interesting:
-- 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.10 Ubuntu 14.04
EDIT: I found out that the problem is that the VideoWriter object isn't open, even after the constructor call:
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)));
And using the CV_CAP_PROP_FPS makes OpenCV show the following message in secution time:
HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(5) - Invalid argument
Why this hqppen, how can I fix that?