Errors while installing OpenCV and FFMPEG through Rightscripts

天涯浪子 提交于 2019-12-04 01:56:22

问题


I am writing a RightScript to install OpenCV-2.3.1 on a linux server. I am using FFMPEG package: ffmpeg-0.7-rc1

I am doing exactly whatever I did while installing it manually on the server, but am getting some errors when I try booting the box using the rightscripts. OpenCV installs and works fine when built manually through bash.

The errors I am getting are:

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:

I did a google search and I understand that some of the FFMPEG functions are deprecated now. I have tried installing the latest FFMPEG package as well, and I am getting the same errors. Also, I am wondering why I don't get these errors when I install it manually on the server via bash, and only when I install using Rightscripts.


回答1:


Using FFMPEG package ffmpeg-0.8 solves the issue. It works fine with OpenCV-2.3.1 There has been a number of recent fixes to FFMPEG that is giving rise to some clashes. ffmpeg-0.8 is stable and works fine.




回答2:


I don't need ffmpeg since I do only identify images, so use this option to skip combile Video module:

make -DWITH_FFMPEG=OFF xxxxxx




回答3:


You need to install the ffmpeg-dev package too, if your distro has one. If not, you might need to install libavcodec-dev, libavformat-dev and libswscale-dev too.

If you have them installed but OpenCV's build still can't find them, it is probably because pkg-config cannot locate ffmpeg headers. This info is usually at /usr/lib/pkgconfig, which means that you might have to add the proper path manually if your's are in a different path. For instance, if ffmpeg files for pkg-config are located at /usr/local/lib/pkgconfig, before running CMake again you should execute:

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


来源:https://stackoverflow.com/questions/11024843/errors-while-installing-opencv-and-ffmpeg-through-rightscripts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!