Click here to Skip to main content
15,868,141 members
Articles / Programming Languages / C++

Using FFMpeg in the Microsoft Visual C++ Environment

Rate me:
Please Sign up or sign in to vote.
2.75/5 (26 votes)
28 Jan 2007CPOL2 min read 189.8K   2.5K   56   38
Integrate the FFMpeg library into your Visual C++ project.

Sample Image - ffmpeglogo.jpg

Introduction

FFMpeg is a free video library that can record and convert audio and video data. FFMpeg is under GNU Lesser General Public License, but FFMpeg also uses some third party library which maybe under GNU General Public License. So before using FFMpeg library, you'd better spend some time on the license.

FFMpeg includes the following libraries:

  • libavcodec: All of the video and audio encoders and decoders.
  • libavformat: Demuxers and muxers for audio and video formats.
  • libavutil: Useful utils of FFMpeg.

Get FFMpeg Source Code

There are no formal releases of FFMpeg; however, you can get the FFMpeg source code on a daily basis.

svn://svn.mplayerhq.hu/ffmpeg/trunk

For example, you can checkout the source code using TortoiseSVN,

Checkout FFMpeg Source Code

Compiling FFMpeg

FFmpeg is developed under Linux, but it can be compiled under most Operating Systems.

For Windows, FFMpeg can be compiled with MSYS and MingGW. If you have setup MSYS and MingGW systems correctly, you can compile FFMpeg under its folder.

  1. Cleanup former build results.
  2. make distclean
  3. Setup build parameters.
  4. ./configure --enable-shared --disable-static --enable-memalign-hack

    If there are no errors, and config.mak and config.h were generated, you can build the library, and then, if you want, you can install them into the MSYS environment.

    make
    make install

Using FFMpeg in Your Visual C++ Environment

  1. Create inttypes.h and stdint.h if you don't have them. Provided in the above link is a copy of these two files. You can get them from another place if you want.
  2. Set up additional include directories and additional library directories. By default, these folders are under your MSYS folder, for example:
  3. /usr/local/include
    /usr/local/lib
  4. Add FFmpeg's shared libraries, including libavutil.lib, libavcodec.lib, and libavformat.lib.
  5. Include the FFMpeg header:
  6. C++
    #include <ffmpeg/avformat.h>
    #include <ffmpeg/avcodec.h>

Using the FFMpeg code

There is an example within FFMpeg, output_example.c. But if you have copied code from this example, following tips may ensure you compile successfully.

  1. Add the required casts.
  2. Change snprintf to _snprintf.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
jshaa6-Jan-11 2:44
jshaa6-Jan-11 2:44 
GeneralThe procedure entry point url_fclose could not be located in the dynamic link library avcodec-52.dll exception Pin
ndquangr9-Nov-10 16:29
ndquangr9-Nov-10 16:29 
GeneralRe: The procedure entry point url_fclose could not be located in the dynamic link library avcodec-52.dll exception Pin
llllskywalker13-Jun-11 12:10
llllskywalker13-Jun-11 12:10 
GeneralVideo Encoding with FFMPEG using avcodec Pin
GPUToaster™4-Jul-10 1:19
GPUToaster™4-Jul-10 1:19 
GeneralUsing FFmpeg article Pin
soft_support30-Mar-10 12:56
soft_support30-Mar-10 12:56 
GeneralRe: Using FFmpeg article Pin
lsyueh25-Oct-10 16:05
lsyueh25-Oct-10 16:05 
Generalno lib files Pin
Ayman Alterawi17-Jan-10 6:41
Ayman Alterawi17-Jan-10 6:41 
GeneralRe: no lib files Pin
Member 9800116-Mar-10 9:03
Member 9800116-Mar-10 9:03 
GeneralRe: no lib files Pin
Ayman Alterawi16-Mar-10 9:14
Ayman Alterawi16-Mar-10 9:14 
GeneralRe: no lib files - Instructions for Generating the dynamic libs from dll files. Pin
Quickshot17-Mar-10 5:39
Quickshot17-Mar-10 5:39 
You can generate lib files from the dll files. This allows you to use the dynamically linked ffmpeg libraries. This is useful if you want to update ffmpeg without recompiling your program.

http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/

visual studio provides the dumpbin program

dumpbin /exports avcodec.dll

Extract the names using MS Excel import functionality. Then using the names make an avcodec.def file starting with "EXPORTS" Then the names all on separate lines.

Finally using the lib command you can generate the lib file from the def file

lib /def:avcodec.def /out:libavcodec.lib /machine:x86

Assuming everything worked correctly you now have a lib file that goes with your dll file. Make sure your dll files are in a path that the executable can find.
GeneralRe: no lib files - main.cpp file that this was tested and verified with. Pin
Quickshot17-Mar-10 10:48
Quickshot17-Mar-10 10:48 
GeneralRe: no lib files - swscale lib and configure command Pin
Quickshot17-Mar-10 10:53
Quickshot17-Mar-10 10:53 
GeneralRe: no lib files Pin
JaydeepB17-Mar-10 13:11
JaydeepB17-Mar-10 13:11 
QuestionHow to convert .wma format data to mp3 format, on the fly? Pin
semaphore124-Dec-09 23:10
semaphore124-Dec-09 23:10 
GeneralLink error Pin
metalmonkey16-Jun-09 13:53
metalmonkey16-Jun-09 13:53 
GeneralRe: Link error Pin
metalmonkey16-Jun-09 17:15
metalmonkey16-Jun-09 17:15 
GeneralMy vote of 1 Pin
squibman25-Mar-09 11:52
squibman25-Mar-09 11:52 
AnswerRe: My vote of 1 Pin
squibman26-Mar-09 11:40
squibman26-Mar-09 11:40 
GeneralRe: My vote of 1 Pin
RajaManikandan_R16-Sep-10 17:38
RajaManikandan_R16-Sep-10 17:38 
Generalexecute configure Pin
JlkBrgr23-Jul-08 23:32
JlkBrgr23-Jul-08 23:32 
GeneralRe: execute configure Pin
JlkBrgr23-Jul-08 23:56
JlkBrgr23-Jul-08 23:56 
GeneralRe: execute configure Pin
squibman26-Mar-09 11:48
squibman26-Mar-09 11:48 
QuestionIs it possible to compile the ffmpeg under VC++? Pin
Shuang. Wu22-Jun-08 18:21
Shuang. Wu22-Jun-08 18:21 
AnswerRe: Is it possible to compile the ffmpeg under VC++? Pin
RajaManikandan_R16-Sep-10 18:09
RajaManikandan_R16-Sep-10 18:09 
Generalask about the features in this project Pin
mulyky1-Dec-07 18:17
mulyky1-Dec-07 18:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.