user985030
user985030

Reputation: 1617

Opencv 3.0 with which Version of FFMPEG?

I can't seem to get OpenCV 3.0 to build properly with ffmpeg 2.7 or 2.4. Does anyone know which version works? I am running Mac OSX Yosemite. I seem to get linking errors when attempting to build opencv with ffmpeg support:

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

Here are the flags which I compiled ffmpeg, maybe that could be the cause?:

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

Upvotes: 0

Views: 2523

Answers (1)

Cornstalks
Cornstalks

Reputation: 38218

Most of those aren't ffmpeg (libavcodec, libavformat, libavutils, libswscale, etc.) linker errors. They're dependencies ffmpeg was built with: iconv, swresample (which is part of ffmpeg), lzma, x264, and xvid. You need to link to libiconv, libswresample, liblzma, libx264, and libxvid.

A particular version of ffmpeg isn't the problem here. The problem is that ffmpeg has some dependencies you need to link to.

You can --enable-libx264 if you want, but you need to actually have libx264 on your machine for OpenCV/ffmpeg to be able to link to. Same with all the others.

Upvotes: 1

Related Questions