Click here to Skip to main content
15,881,248 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 190.1K   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

 
AnswerRe: How to compile FFMpeg? Pin
Denny503-Jul-07 17:46
Denny503-Jul-07 17:46 
GeneralRe: How to compile FFMpeg? Pin
raytracingx3-Jul-07 18:09
raytracingx3-Jul-07 18:09 
GeneralRe: How to compile FFMpeg? Pin
Denny503-Jul-07 18:22
Denny503-Jul-07 18:22 
GeneralRe: How to compile FFMpeg? Pin
raytracingx3-Jul-07 19:34
raytracingx3-Jul-07 19:34 
GeneralRe: How to compile FFMpeg? Pin
cruz.fernandez24-Jun-08 6:21
cruz.fernandez24-Jun-08 6:21 
GeneralRe: How to compile FFMpeg? Pin
RajaManikandan_R29-Jul-10 21:34
RajaManikandan_R29-Jul-10 21:34 
Generalought to write some about how to debug in windows Pin
ikohl28-Apr-07 16:15
ikohl28-Apr-07 16:15 
AnswerRe: ought to write some about how to debug in windows Pin
PigeonRat30-Jun-07 14:09
PigeonRat30-Jun-07 14:09 
The only way I have found is to use shared libraries.
Generalyes, i found that also Pin
ikohl2-Jul-07 15:52
ikohl2-Jul-07 15:52 

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.