Build ffmpeg development environment under Windows environment

Source: Internet
Author: User

FFmpeg is an open source, cross-platform library, can be used in Windows, Linux and other platforms, this article will briefly explain the Windows environment FFMPEG development environment Building process, I use the operating system for Windows 7, integrated development environment forthe Visual Studio 2005,ffmpeg version is 2.2. One might say what age it was, vs. 2005, and now the VS 2010/2012/2013 are out. I also installed the computer VS2010, each open, with the hard drive led flashing, and the squeak of the hard disk, after a long time before the splash screen pop-up page, your thoughts may have floated to the South Pole, start a really too slow, completely old cow pull the feeling, so follow vs2012/ 2013 is no longer installed and used. Personally feel vs2005/2008 relatively sharp, relatively light, fast startup speed, of course, a lot of shortcut keys are also used. let's start with a very simple ffmpeg example and talk about the development environment Setup process:1. Open the VS editor and create a new win C + + console application. 2. Enter the FFmpeg sourceDoc/examples folder, find the Metadata.c file, the file is a standalone demo, run the result for the print audio and video media file basic information. The file volume is less than 2k, the number of lines of code in these demos at least, it seems easy to understand. For METADATA.C file source code, open the file, copy the code inside to our new win 32 project, if you try to compile the above code,The compiler will report a variety of errors, the main cause of the error is ffmpeg in the Windows environment of the various acclimatized, in the Linux environment is much better, not so much what data type is not recognized, macro definition missing and so on, based on the error type, set up the project andModify the above code to complete the correct compilation.
(1) Set up project header files and Lib library dependencies. FFmpeg's header files and Lib library can be compiled by themselves, but I did not try, but directly to download the compiled version of the FFmpeg windows, extracted after the following files:


copy the Include header file, the Lib library file, and the DLL file under the bin directory to your project, and then set the additional include directory in the project properties:$ (ProjectDir) \include and additional library directories: $ (ProjectDir) \lib, This setting is simple. The project catalog looks like this:
(2) At this point the compile project will be like the error shown, the workaround is to locate the error, directly comment it.
(3) Compile the project again, as shown in the error:
Locate the error after the discovery or Common.h header file has a problem, the workaround is below the comment, add the following code:#ifndef Int64_c#defineInt64_c(C)  (C## LL)#defineUint64_c(C) (C##ULL)#endif(4) If you compile the project again at this time, there will be errors, the wrong reason is that our new win C + + project directly call FFmpeg of the library, resulting in C function can not be resolved, for such as C + + and C function names compiled after the naming mechanism of different causes unresolved problems, Simply add when referencing the C function libraryextern "C"and, of course, a reference Lib library. The modified code is as follows:
#include "stdafx.h" #include <stdio.h> #include <stdlib.h>extern "C" {    #include <libavformat/ avformat.h>    #include <libavutil/dict.h>} #pragma comment (lib, "Avformat.lib") #pragma comment (lib, " Avutil.lib ") int main () {    Avformatcontext *fmt_ctx = NULL;    Avdictionaryentry *tag = NULL;    int ret = 0;    Av_register_all ();    if (ret = Avformat_open_input (&fmt_ctx, "Iphone.mp3", NULL, NULL))) {        return ret;}    while (tag = Av_dict_get (Fmt_ctx->metadata, "", Tag, Av_dict_ignore_suffix)) {        printf ("%s=%s\n", Tag->key , tag->value);}    Avformat_close_input (&FMT_CTX); System ("pause");    return 0;}
at this point can be successfully compiled, run the result is as follows:
of course, with the development in-depth, when using data types such as uint8_t, int64_t, and so on, the compiler will report the following error:fatal error C1083:cannot open include file: ' stdint.h ': No such file or directory, that is, the related header files cannot be found, and the package of the header file can be found in the project file directory I uploaded, After decompression, copy the two header files toMicrosoft Visual Studio 8/Vc/includedirectory.
Project Download Link: http://download.csdn.net/detail/u013085897/7428719because the project operation depends on a few DLL volume is relatively large, so in the upload project I deleted it, the DLL can be mentioned in the link to download. namely:http://ffmpeg.zeranoe.com/builds/




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.