我在我的Ubuntu 16.04操作系统上安装了Opencv 2.4.13.6
。
我ffmpeg
Opencv
安装期间我WITH_FFMPEG ON
。
我的ffmpeg正在运作。
如果我在命令窗口输入ffmpeg,我有
ffmpeg version N-90982-gb995ec0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --prefix=/home/nyan/ffmpeg_build --enable-shared --extra-cflags=-I/home/nyan/ffmpeg_build/include --extra-ldflags=-L/home/nyan/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/nyan/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 56. 18.100 / 56. 18.100
libavcodec 58. 19.100 / 58. 19.100
libavformat 58. 13.101 / 58. 13.101
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 21.100 / 7. 21.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
然后我将ffmpeg路径放到.bashrc
export PATH=/home/bin${PATH:+:${PATH}}
export PATH=/home/ffmpeg_build${PATH:+:${PATH}}
export PATH=/home/ffmpeg_build/include${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/home/ffmpeg_build/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
在我的Opencv库中,我有libopencv_video.so。所以视频输入/输出应该没问题。
我的以下程序为我"can't read video"
。可能是什么原因?
我试过VideoCapture cap(0);
给了我同样的错误。有什么问题?
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(void){
VideoCapture cap("IMG_5715.MOV"); // open the default camera
if(!cap.isOpened()) // check if we succeeded
{
cout << "can't read video"<< endl;
return -1;
}
while(1){
Mat frame;
// Capture frame-by-frame
cap >> frame;
imshow( "Frame", frame );
waitKey(1);
// If the frame is empty, break immediately
if (frame.empty())
break;
}
cap.release();
return 0;
}