Opencv 3.0 与哪个版本的 FFMPEG?

Opencv 3.0 with which Version of FFMPEG?

我似乎无法使用 ffmpeg 2.7 或 2.4 正确构建 OpenCV 3.0。有谁知道哪个版本有效?我是运行MacOSXYosemite。尝试使用 ffmpeg 支持构建 opencv 时,我似乎遇到了链接错误:

Linking CXX shared library ../../lib/libopencv_videoio.dylib
Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
  "_iconv_close", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
  "_iconv_open", referenced from:
      _avcodec_open2 in libavcodec.a(utils.o)
      _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
  "_lzma_code", referenced from:
      _decode_frame in libavcodec.a(tiff.o)
  "_lzma_end", referenced from:
      _decode_frame in libavcodec.a(tiff.o)
  "_lzma_stream_decoder", referenced from:
      _decode_frame in libavcodec.a(tiff.o)
  "_swr_alloc", referenced from:
      _opus_decode_init in libavcodec.a(opusdec.o)
  "_swr_close", referenced from:
      _opus_decode_packet in libavcodec.a(opusdec.o)
      _opus_decode_flush in libavcodec.a(opusdec.o)
  "_swr_convert", referenced from:
      _opus_decode_packet in libavcodec.a(opusdec.o)
  "_swr_free", referenced from:
      _opus_decode_close in libavcodec.a(opusdec.o)
  "_swr_init", referenced from:
      _opus_decode_packet in libavcodec.a(opusdec.o)
  "_swr_is_initialized", referenced from:
      _opus_decode_packet in libavcodec.a(opusdec.o)
  "_x264_bit_depth", referenced from:
      _X264_init_static in libavcodec.a(libx264.o)
      _X264_frame in libavcodec.a(libx264.o)
  "_x264_encoder_close", referenced from:
      _X264_close in libavcodec.a(libx264.o)
  "_x264_encoder_delayed_frames", referenced from:
      _X264_frame in libavcodec.a(libx264.o)
  "_x264_encoder_encode", referenced from:
      _X264_frame in libavcodec.a(libx264.o)
  "_x264_encoder_headers", referenced from:
      _X264_init in libavcodec.a(libx264.o)
  "_x264_encoder_open_142", referenced from:
      _X264_init in libavcodec.a(libx264.o)
  "_x264_encoder_reconfig", referenced from:
      _X264_frame in libavcodec.a(libx264.o)
  "_x264_levels", referenced from:
      _X264_init in libavcodec.a(libx264.o)
  "_x264_param_apply_fastfirstpass", referenced from:
      _X264_init in libavcodec.a(libx264.o)
  "_x264_param_apply_profile", referenced from:
      _X264_init in libavcodec.a(libx264.o)
  "_x264_param_default", referenced from:
      _X264_init in libavcodec.a(libx264.o)
  "_x264_param_default_preset", referenced from:
      _X264_init in libavcodec.a(libx264.o)
  "_x264_param_parse", referenced from:
      _X264_init in libavcodec.a(libx264.o)
  "_x264_picture_init", referenced from:
      _X264_frame in libavcodec.a(libx264.o)
  "_xvid_encore", referenced from:
      _xvid_encode_init in libavcodec.a(libxvid.o)
      _xvid_encode_frame in libavcodec.a(libxvid.o)
      _xvid_encode_close in libavcodec.a(libxvid.o)
  "_xvid_global", referenced from:
      _xvid_encode_init in libavcodec.a(libxvid.o)
  "_xvid_plugin_2pass2", referenced from:
      _xvid_encode_init in libavcodec.a(libxvid.o)
      _ff_xvid_rate_control_init in libavcodec.a(libxvid_rc.o)
      _ff_xvid_rate_estimate_qscale in libavcodec.a(libxvid_rc.o)
      _ff_xvid_rate_control_uninit in libavcodec.a(libxvid_rc.o)
  "_xvid_plugin_lumimasking", referenced from:
      _xvid_encode_init in libavcodec.a(libxvid.o)
  "_xvid_plugin_single", referenced from:
      _xvid_encode_init in libavcodec.a(libxvid.o)
  "_xvid_plugin_ssim", referenced from:
      _xvid_encode_init in libavcodec.a(libxvid.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_videoio.3.0.0.dylib] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2

这是我编译 ffmpeg 的标志,也许这可能是原因?:

./configure --prefix=~/Software/ffmpeg-2.4.10/ --enable-shared --enable-avresample --enable-libx264 --enable-libxvid --enable-opencl --enable- gpl

其中大部分不是 ffmpeg(libavcodec、libavformat、libavutils、libswscale 等)linker 错误。它们是 ffmpeg 的依赖项:iconv、swresample(它是 ffmpeg 的一部分)、lzma、x264 和 xvid。您需要 link 到 libiconv、libswresample、liblzma、libx264 和 libxvid。

特定版本的 ffmpeg 不是这里的问题。问题是 ffmpeg 有一些你需要 link 的依赖关系。

如果需要,您可以 --enable-libx264,但您的机器上实际上需要安装 libx264,OpenCV/ffmpeg 才能 link。其他的都一样。