2

It's two days I'm search around the web for a tutorial to compile OpenCV 2.3 with ffmpeg support under windows, but nothing found. I'm using pre-built version of OpenCV in VS2010 but I cannot read from network camera, it's why I need ffmeg support.

Maysam
  • 7,246
  • 13
  • 68
  • 106

3 Answers3

4

The answer your looking for is here and it works for the 32 bit and 64 bit configurations. I used this build of FFMPEG. http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z

1) Download OpenCV 2.3

2) Open the root CMakeLists.txt and insert the line set(HAVE_FFMPEG 1)

3) Download http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z (or the 32 bit build if u fancy it)

4) Edit avformat.h found in the ffmpeg include dir with #define INT64_C

5) Edit cap_ffmpeg_impl.hpp from the highgui project with #define snprintf _snprintf

6) in your highgui project properties under C/C++>Additional Include Directories add path of the include directory of FFMPEG you just downloaded

7)On the same property page under Linker>General>Additional Library Dependencies add the path of the lib directory of FFMPEG you just downloaded

8)On the same property page under Linker>Input>Additional dependencies add ALL the names of the libraries of ffmpeg found in lib (avformat.lib, avscale.lib, avcore.lib etc)

9) build the highgui project

10) Add the path of the .dll files that came with FFMPEG to the System Path environment variable.

That's it! 10 easy steps ;)

octi
  • 1,470
  • 1
  • 17
  • 28
  • This was tested and I was able to call the videoWriter from the python opencv library and encode to an XVID video. – octi May 02 '12 at 21:07
  • Also opencv 2.4 will add thte FFMPEG functionality automatically. It actually has a WITH_FFMPEG flag in the CMAKE variables – octi Jun 22 '12 at 15:02
  • this must be done also in opencv_gpu if you want to compile it (ie. WITH_CUDA enabled) – Dredok May 03 '13 at 15:56
3

Build OpenCV with CMake from sources. Choose USE_FFMPEG flag.

Get ffmpeg from http://ffmpeg.zeranoe.com/builds/

red1ynx
  • 3,639
  • 1
  • 18
  • 23
  • 3
    I documented whole process here: https://docs.google.com/document/d/1tMoRQ3GevHHMSXI31WGF9qt4y3uW2saS0ElQVSS4AZ0/edit?hl=en_US – Maysam Aug 16 '11 at 09:58
  • 2
    There is no USE_FFMPEG flag under Windows. And none of the instruction in the doc specifies it. – octi May 02 '12 at 17:26
1

In my experiment, FFMPEG is not directly supported in window. The flag WITH_FFMPEG only appears under UNIX(opencv 2.3 CMakeLists.txt). So, if you want to build opencv 2.3 with ffmpeg support, you should edit the CmakeLists.txt or the project opencv_highgui yourself. And then get ffmpeg from WWW. You may also need to edit cap_ffmpeg_impl.hpp.

huey
  • 11
  • 1
  • I noticed this and I'm wondering what kind of edits do I need to peform in the cap_ffmpeg_impl.hpp. Any help would be appreciated. – octi May 02 '12 at 17:45