Thursday, February 2, 2012

Using ffmpeg library in a Qt project


ffmpeg is a wonderful library for creating video applications or even general purpose utilities. ffmpeg takes care of all the hard work of video processing by doing all the decoding, encoding, muxing and demuxing for you.

The improper use of ffmpeg library in  a Qt project result in errors like "undefined reference to av_register_all";"undefined reference to av_free()" and so on. So

How to use ffmpeg library in a Qt project?

For reliable use of ffmpeg library in a Qt project , 3 things are essential:

i) Qt project file should include ffmpeg library paths

ii) Qt project file should include ffmpeg include paths (it worked for me without this )

iii) Link the specific ffmpeg libraries that you are gonna use.

Ok....Now how to do this?

open your Qt project file project.pro, include in it

INCLUDEPATH += /usr/local/include/ (where your ffmpeg libraries are)

LIBS+= -lavcodec \
           
             -lavutil \

           -lswscale \

         -lavformat  (exclude those libraries you don't use)

library paths may also be included like -LC:/usr/local/ffmpeg-0.8.5/libavcodec.so so on....It is not compulsory.

Also include a statement

QMAKE_CXXFLAGS  += -D__STDC_CONSTANT_MACROS in your .pro file.
     




No comments:

Post a Comment