【发布时间】:2015-04-09 04:53:49
【问题描述】:
几天前,我在没有 ffmpeg 的情况下安装了最新的 2.4 分支。我使用的是 Ubuntu 14.04,我的虚拟机中根本没有 ffmpeg。
我想写 .mp4 视频文件,输入文件也是 .mp4。输入编解码器是avc1。
我无法获得任何结果,错误可以在下面看到。
错误
[libx264 @ 0x9357bc0] broken ffmpeg default settings detected
[libx264 @ 0x9357bc0] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x9357bc0] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x9357bc0] speed presets are listed in x264 --help
[libx264 @ 0x9357bc0] profile is optional; x264 defaults to high
Could not open codec 'libx264': Unspecified error
Could not open the output video for write: /home/margarida/exams_2014/Output.mp4
简化代码
int main(int argc, char *argv[]) {
VideoWriter outputVideo;
// Get Codec Type
int ex = static_cast<int>(cap.get(CV_CAP_PROP_FOURCC));
// Transform from int to char via Bitwise operators
char EXT[] = { (char) (ex & 0XFF), (char) ((ex & 0XFF00) >> 8),
(char) ((ex & 0XFF0000) >> 16), (char) ((ex & 0XFF000000)
>> 24), 0 };
// Acquire input size
Size S = Size((int) cap.get(CV_CAP_PROP_FRAME_WIDTH),
(int) cap.get(CV_CAP_PROP_FRAME_HEIGHT));
cout << "Input codec type: " << EXT << endl;
// Open the output
outputVideo.open(newname, ex, cap.get(CV_CAP_PROP_FPS), S, true);
if (!outputVideo.isOpened()) {
cout << "Could not open the output video for write " << endl;
return -1;
}
while (true) {
cap >> frame;
if (frame.empty()) {
cerr << "nao apanhou frame" << endl;
break;
}
cinzento = acinzentar(frame);
imshow("Cinzento", cinzento);
outputVideo.write(cinzento);
switch(waitKey(10)){
case 27:
//'esc' has been pressed (ASCII value for 'esc' is 27)
//exit program.
return 0;
}
}
return 0;
}
我的 cmake 是这样的:
cmake -D WITH_TBB=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D WITH_FFMPEG=OFF -D WITH_IPP=OFF ..
谁能帮助解决我的问题?
提前致谢。
【问题讨论】:
标签: opencv video mp4 ubuntu-14.04 libx264