Build ffmpeg Libraries in Windows via MinGW

3856 ワード

It is trite, but I nmot how to build the ffmpeg in this article.
ゼロ
   Set up your MinGW environment, you could download 32/64 bit installation file from here 
 you could select which compiler you would like to install. The necessary is mingwg-developer-toolkit, mingw32-base and mingw32-gcc-g++:
After your installation done, open the MinGW shell (on
YourMigwPATH\msys\1.0\msys.bat ) to check if the gcc works or not:
Gaiger@i5-4570 ~
$ gcc
sh: gcc: command not found

If the gcc be not existing, move all the folder besides msys in
YourMigwPATH into the folder
YourMigwPATH\msys\1.0
Currently, the gcc would be work in the MinGW environment.
Gaiger@i5-4570 ~
$ gcc
gcc.exe: fatal error: no input files
compilation terminated.

Gaiger@i5-4570 ~
$

一.
   Download the FFmpeg source code,  choose which version you like. Warning : HEVC (h264) supporting after verion 2.0.
   Uncompress the tar ball file and move the source folder into the folder
YourMigwPATH\32\msys\1.0\home\
YourUserName .
二.
   Go into the ffmpeg source folder on the MinGW shell,  my configure be :
./configure --enable-memalign-hack --arch=x86 --target-os=mingw32 --enable-cross-compile --enable-w32threads --cross-prefix= --prefix=$PWD/built

The configuring time in MinGW costs time more than it in linux, Do not be suspicious  the MingW hanging and wait it done.
三.
   Open the file
ffmpegSourceRootRoot\libavformat\os_support.h, add the 2 line, about line number 32:
#include "config.h"

#if defined(__MINGW32__) && !defined(__MINGW32CE__)
#define WIN32_LEAN_AND_MEAN
# include <windows.h>
#  include <fcntl.h>
#  define lseek(f,p,w) _lseeki64((f), (p), (w))
#  define stat _stati64
#  define fstat(f,s) _fstati64((f), (s))
#endif /* defined(__MINGW32__) && !defined(__MINGW32CE__) */

  And Check the file
ffmpegSourceRootRoot\cmdutils.c added the code or not , about line number 172:
#if defined(_WIN32) && !defined(__MINGW32CE__)
#include <windows.h>
#include <shellapi.h>
/* Will be leaked on exit */
static char** win32_argv_utf8 = NULL;
static int win32_argc = 0;

If it is not being added, complement that. Or you could add the parameter in the configurate command :
CFLAGS="-Wno-implicit-function-declaration"

四:
   All preparations have been done , type "make"to build it.
  After the build done, type "make install", the portable binaries and  libraries would be under folder
ffmpegSourceRootRoot\built.