通过脚本安装OpenCV和FFMPEG时出错

我正在写一个RightScript在Linux服务器上安装OpenCV-2.3.1。 我正在使用FFMPEG包:ffmpeg-0.7-rc1

我正在做什么,而我手动安装在服务器上,但是当我尝试启动框使用的脚本获取一些错误。 OpenCV在通过bash手动构build时安装并工作正常。

我得到的错误是:

In file included from /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg.cpp:45: /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function 'void CvCapture_FFMPEG::close()': /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:451: warning: 'void av_close_input_file(AVFormatContext*)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1533) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:451: warning: 'void av_close_input_file(AVFormatContext*)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1533) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function 'bool CvCapture_FFMPEG::reopen()': /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:483: warning: 'void av_close_input_file(AVFormatContext*)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1533) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:483: warning: 'void av_close_input_file(AVFormatContext*)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1533) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:486: error: 'av_open_input_file' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:487: warning: 'int av_find_stream_info(AVFormatContext*)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1357) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:487: warning: 'int av_find_stream_info(AVFormatContext*)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1357) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:494: error: 'avcodec_thread_init' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:497: warning: 'int avcodec_open(AVCodecContext*, AVCodec*)' is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:3380) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:497: warning: 'int avcodec_open(AVCodecContext*, AVCodec*)' is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:3380) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function 'bool CvCapture_FFMPEG::open(const char*)': /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:524: error: 'av_open_input_file' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:529: warning: 'int av_find_stream_info(AVFormatContext*)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1357) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:529: warning: 'int av_find_stream_info(AVFormatContext*)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1357) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:541: error: 'avcodec_thread_init' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:550: warning: 'int avcodec_open(AVCodecContext*, AVCodec*)' is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:3380) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:550: warning: 'int avcodec_open(AVCodecContext*, AVCodec*)' is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:3380) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In function 'AVStream* icv_add_video_stream_FFMPEG(AVFormatContext*, CodecID, int, int, int, double, int)': /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:999: warning: 'AVStream* av_new_stream(AVFormatContext*, int)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1557) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:999: warning: 'AVStream* av_new_stream(AVFormatContext*, int)' is deprecated (declared at /usr/local/include/libavformat/avformat.h:1557) In file included from /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg.cpp:45: /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In function 'int icv_av_write_frame_FFMPEG(AVFormatContext*, AVStream*, uint8_t*, uint32_t, AVFrame*)': /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1121: warning: 'int avcodec_encode_video(AVCodecContext*, uint8_t*, int, const AVFrame*)' is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:4077) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1121: warning: 'int avcodec_encode_video(AVCodecContext*, uint8_t*, int, const AVFrame*)' is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:4077) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function 'void CvVideoWriter_FFMPEG::close()': /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1298: error: 'url_fclose' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function 'bool CvVideoWriter_FFMPEG::open(const char*, int, double, int, int, bool)': /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1411: error: 'av_set_parameters' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1415: error: 'dump_format' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1442: warning: 'int avcodec_open(AVCodecContext*, AVCodec*)' is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:3380) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1442: warning: 'int avcodec_open(AVCodecContext*, AVCodec*)' is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:3380) /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1479: error: 'URL_WRONLY' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1479: error: 'url_fopen' was not declared in this scope /OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1485: error: 'av_write_header' was not declared in this scope 20:09:04: make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o] Error 1 20:09:04: make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 20:09:04: make: *** [all] Error 2 20:09:04: cd: 23: can't cd to /root/OpenCV-2.3.1/samples/c 20:09:04: chmod: cannot access `build_all.sh': No such file or directory 20:09:04: /var/cache/rightscale/right_scripts/right_scripts_cookbook/recipes/CVScripts___Install_OpenCV: 25: ./build_all.sh: not found *ERROR> Chef converge failed *ERROR> An external command returned an error during the execution of Chef: 

我做了一个谷歌search,我明白,现在一些FFMPEGfunction已被弃用。 我已经尝试安装最新的FFMPEG包,以及我得到相同的错误。 此外,我想知道为什么我没有得到这些错误,当我通过bash手动安装在服务器上,只有当我安装使用的脚本。

Solutions Collecting From Web of "通过脚本安装OpenCV和FFMPEG时出错"

使用FFMPEG包ffmpeg-0.8解决了这个问题。 它在OpenCV-2.3.1上可以正常工作。FFMPEG最近有一些修复引起了一些冲突。 ffmpeg-0.8是稳定的,工作正常。

我不需要ffmpeg,因为我只是识别图像,所以使用这个选项跳过combile视频模块:

make -DWITH_FFMPEG=OFF xxxxxx

如果你的发行版有一个,你也需要安装ffmpeg-dev软件包。 如果没有,你可能需要安装libavcodec-devlibavformat-devlibswscale-dev

如果你安装了它们,但OpenCV的构建仍然无法找到它们,这可能是因为pkg-config找不到ffmpeg头文件。 这个信息通常位于/usr/lib/pkgconfig ,这意味着如果你的路径不同,你可能需要手动添加正确的路径。 例如,如果pkg-config ffmpeg文件位于/usr/local/lib/pkgconfig ,那么在再次运行CMake之前,应该执行:

 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig