Instructions for OpenCV with mpeg Movies in the CS Department

Most of the OpenCV code examples are being distributed with Makefile configurations suited to run on my Mac. Not surprisingly, they will need to be modified to work on different platforms. Also, when originally distributed the installation on our Linux cluster did not fully support mpeg video. That was fixed on January 30, so you may now proceed using the guideance below.

Before we even think about the Makefile, let us consider environmnent variables. You will want to modify your load library path and path as follows:

export PATH=/usr/local/ffmpeg/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/opencv/lib64

The first line above includes ffmpeg in your run path. The next two lines include libraries from ffmpeg and OpenCV in your load library path. A word of caution, adapt these commands to match your chosen unix shell (they are written for bash) and also to fit in with your other initializations of your path and load library path. For example, the middle line as shown resets the load library path, something you may or may not want to do.

Once you have added these configurations to your Unix session, here is an example of the command needed to compile the ex00movie program:

g++ *.cpp -I/usr/local/OpenCV/include -L/usr/local/OpenCV/lib64 -lopencv_core -lopencv_videoio -lopencv_highgui -lopencv_imgproc -o ex00movie

While we are discussing the ex00movie example, here is an odd quirk between the Mac installation I use in class and our department Unix machines. As distributed, the example on our Unix machines creates a new window for each frame, a tedious and annoying behavior. There is an easy fix; always use the same name, the initial name "MyVideo" in all calls to imshow .