Build ffmpeg Libraries in Windows via MinGW

本文详细介绍了如何在MinGW环境下从源代码编译FFmpeg多媒体框架。包括安装必要的工具、配置编译参数、修改源代码以适配Windows平台等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



  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.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值