git OpenCV 3.0.0 使用 FFMPEG 出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31663498/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
OpenCV 3.0.0 make error with FFMPEG
提问by Ujjwal Aryan
I have been using OpenCV for a while. However I have recently changed my system to a cluster where I do not have any admin permission. The problem is like this :
我一直在使用 OpenCV 一段时间。但是,我最近将系统更改为没有任何管理员权限的集群。问题是这样的:
In my home folder, I installed FFMPEG (latest stable version available on ffmpeg site). I installed it in $HOME, and so in $HOME/lib there are the library files installed. For more information I compiled FFMPEG with following options :
在我的主文件夹中,我安装了 FFMPEG(ffmpeg 站点上提供的最新稳定版本)。我将它安装在 $HOME 中,因此在 $HOME/lib 中安装了库文件。有关更多信息,我使用以下选项编译了 FFMPEG:
./configure --prefix=$HOME --enable-shared --enable-pic
I then downloaded the latest stable version of OpenCV 3.0.0 and configured it using ccmake. When I try to make -j8
, it gives me the following error.
然后我下载了 OpenCV 3.0.0 的最新稳定版本并使用 ccmake 对其进行了配置。当我尝试时make -j8
,它给了我以下错误。
Scanning dependencies of target opencv_videoio
[ 63%] [ 63%] [ 63%] [ 63%] [ 63%] [ 63%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_decoder.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_images.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_v4l.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_encoder.cpp.o
Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o
In file included from /home/uujjwal/libraries/opencv-nogpu/opencv-3.0.0/modules/videoio/src/cap_ffmpeg.cpp:45:0:
/home/uujjwal/libraries/opencv-nogpu/opencv-3.0.0/modules/videoio/src/cap_ffmpeg_impl.hpp:1546:71: error: use of enum 'AVCodecID' without previous declaration
/home/uujjwal/libraries/opencv-nogpu/opencv-3.0.0/modules/videoio/src/cap_ffmpeg_impl.hpp:1556:83: error: use of enum 'AVCodecID' without previous declaration
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
However without ffmpeg support it works fine. However I need ffmpeg support due to the nature of my work.
但是没有 ffmpeg 支持它工作正常。但是,由于我的工作性质,我需要 ffmpeg 支持。
In trying to resolve the problem, I tried installing OpenCV 2.4.11 but it also gave this error. The latest GIT version does not give me this error but rather an error a part of which goes like this
在尝试解决该问题时,我尝试安装 OpenCV 2.4.11,但它也出现了此错误。最新的 GIT 版本没有给我这个错误,而是一个错误,其中的一部分是这样的
Linking CXX shared library ../../lib/libopencv_highgui.so /usr/bin/ld: /home/matheus/ffmpeg_build/lib/../lib/libavcodec.a(avpacket.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used
I have pasted the above error from another unresolved question online and so the folder names are different but the relocation error is exactly the same.
我从另一个未解决的在线问题中粘贴了上述错误,因此文件夹名称不同,但重定位错误完全相同。
In trying to resolve the problem I searched and found the following link http://answers.opencv.org/question/12597/build-problems-for-opencv-241-with-ubuntu-1204-lts/
在尝试解决问题时,我搜索并找到了以下链接http://answers.opencv.org/question/12597/build-problems-for-opencv-241-with-ubuntu-1204-lts/
However, one of the answers over there mentioned changing some lines in cap_ffmpeg_impl.hpp file. I tried doing that but either i am not able to do it correctly or something else is going wrong and it is not working. Exact line numbers and exact changes are not mentioned and so I am having difficulty changing things and being sure.
但是,那里的答案之一提到更改 cap_ffmpeg_impl.hpp 文件中的某些行。我尝试这样做,但要么我无法正确执行此操作,要么出现其他问题并且无法正常工作。没有提到确切的行号和确切的变化,所以我很难改变事情并确定。
I am using Fedora 19 (Schrodinger Cat) as the operating system I hope the details of my question are clear and I hope that the community would oblige me with a good response.
我使用 Fedora 19(薛定谔猫)作为操作系统我希望我的问题的细节是清楚的,我希望社区能够给予我良好的回应。
Regards Ujjwal
问候 Ujjwal
回答by Ulrich Stern
I ran into this as well trying to build OpenCV 3.0.0 on Ubuntu 12.04. The problem appears to be a bug in OpenCV. I edited opencv-3.0.0/modules/videoio/src/cap_ffmpeg_impl.hpp, replacing AVCodecID
with CV_CODEC_ID
in all places but the #define
-- in lines 1174 (optional), 1546, and 1556 -- and the build worked.
我也遇到了这个问题,试图在 Ubuntu 12.04 上构建 OpenCV 3.0.0。该问题似乎是 OpenCV 中的一个错误。我编辑了 opencv-3.0.0/modules/videoio/src/cap_ffmpeg_impl.hpp,在除第 1174 行(可选)、1546 和 1556 行之外的所有地方替换AVCodecID
为,并且构建工作正常。CV_CODEC_ID
#define
For more details, see my poston the OpenCV issue tracker. And the bug had been fixed on the OpenCV master branch prior to my post as part of thiscommit.
有关更多详细信息,请参阅我在 OpenCV 问题跟踪器上的帖子。作为此次提交的一部分,在我发布之前,该错误已在 OpenCV 主分支上修复。
回答by Airman00
Assuming you don't use FFMPEG with OpenCV, you can disable it being compiled:
假设您不将 FFMPEG 与 OpenCV 一起使用,您可以禁用它正在编译:
When you run Cmake i.e. when you did this:
当你运行 Cmake ie 时:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON2_PACKAGES_PATH=~/.virtualenvs/cv/lib/python2.7/site-packages \
-D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/bin \
-D PYTHON2_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers \
-D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
Add this flag to the mix -DWITH_FFMPEG=0 to not compile the FFMPEG part
将此标志添加到混合 -DWITH_FFMPEG=0 以不编译 FFMPEG 部分
回答by Kershaw
This version supports ffmpeg
此版本支持ffmpeg
conda install --channel conda-forge