2015-04-23 39 views
0

當我嘗試使用VideoWriter寫入幀時,它不起作用。我已經嘗試了許多FOURCC代碼,如defaul,h264,mjpg,divx,xvid等。是的,我已經安裝了ffmpeg所有必要的配置(--enable-shared,--enable-libx264,... )並且opencv安裝在ffmpeg支持上。VideoWriter不會寫任何東西

我已經谷歌它很多,我發現一切都甚至幾乎沒有解決這個問題,這是在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.10 的Ubuntu 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的顯示secution時間以下消息:

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

爲什麼這個hqppen,我該如何解決這個問題? 。

+0

你能也張貼代碼寫作的片段? – newbie

回答

0

給OUTPUTFILE 「與extention」 嘗試了這一點: 與CV_FOURCC示例 - outputfile.avi( 'M', 'J', 'P', 'G')