window下编译ffmpeg

我再ffmpeg下使用的是MinGW+msys来编译:(首先你要安装微软的Visual Studio或是Visual C++,我们要用他们的命令来编译,下边会提到

1 下载 MinGW 和 MSYS
    MinGW(Minimalist GNU on Windows):一个可自由使用和自由发布的Windows特定头文件和使用GNU工具集导入库的集合,允许你生成本地的Windows程序而不需要第三方C运行时库。
    到:
http://sourceforge.net/projects/mingw/ 去下载即可 
    A 点击“DownLoad mingw-get-inst-...exe”
    B 切换到页面:download? Check your browser's security bar, or try a direct link, or try another mirror.
    C 点击“direct link”下载类似:mingw-get-inst-20111118.exe 的文件
    提示:msys此处就不用再下载了,mingw-get-inst-20111118.exe 中已经包含了msys1.0,后面安装的时候就可以看到该选项。
2 下载 yasm(汇编编译器)
    ffmpeg编译的时候里面的汇编代码需要yasm.exe
    去官网:
http://yasm.tortall.net/Download.html 下载
    在Latest Release栏,直接下载:Win32 .exe (for general use on 32-bit Windows) 
    文件名类似为:yasm-1.2.0-win32.exe
3 下载 ffmpeg
    ffmpeg可以到 
http://www.ffmpeg.org/releases/ 下载
    选择的一个最新版本下载即可,如:ffmpeg-0.8.6.tar.gz 
    文件名类似为:ffmpeg-0.8.6.tar.gz
    当然你也使用网上介绍的使用SVN直接下载源代码的方法。  
    svn://svn.mplayerhq.hu/ffmpeg/trunk

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

上边的是我从其他的博客里扒的,。。。。下边是我自己安装和下载什么样的资源。

如果你从MinGW官网去下载,只能下载在线安装的安装器,这个安装器本身不是MinGW,需要我们在安装器中下载去安装,有点类似插件安装似的。

建议还是从网上直接下载离线版MinGW+msys, ffmpeg编译过程中需要yasm,例如下载yasm-1.3.0-win64.exe,然后修改成yasm.exe 放C:\Windows\System32中,这样就不需要设置环境变量,拿来就用。

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

配置 msys.bat 批处理文件
    为了方便VS200X以及VS2010调用ffmpeg的动态库,可以通过配置让ffmpeg编译时产生windows下调用dll对应的lib,当然,如果你没有这个需要,那么就可以省略以下处理,直接进入步骤3。
    进入:C:\MinGW\msys\1.0\文件夹,使用UltraEdit打开msys.bat文件,在文件的最最前面加入如下一行:
    call "D:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
    添加后效果如下:
      
call "D:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
         @echo off
         rem Copyright (C):  2001, 2002, 2003, 2004, 2005  Earnie Boyd
         rem   
mailto:earnie@users.sf.net
         rem This file is part of Minimal SYStem
         rem   
http://www.mingw.org/msys.shtml
         rem
         rem File:     msys.bat
         rem Revision:     2.4
         rem Revision Date:  December 8th, 2005
         rem ember to set the "Start in:" field of the shortcut.
         rem A value similar to C:\msys\1.0\bin is what the "Start in:" field needs
         rem to represent.
    其中“D:\Program Files\Microsoft Visual Studio 10.0”为你机器上安装VS200X或VS2010的目录,我的电脑安装的是VS2010,并且安装在了D盘。文件修改后保存即可。

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

系统整合
    使用UltraEdit修改C:\MinGW\msys\1.0\etc目下的fstab文件,如果不存在fstab,请复制一份fstab.sample,然后改名为:fstab,再修改其内容为:C:/MinGW /mingw,也即为MinGW的安装路径。

配置 yasm
    为了减少配置环境变量的麻烦,本处直接把 yasm-1.1.0-win32.exe 文件名修改成:yasm.exe,并放到系统目录下:C:\WINDOWS\system32。

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

剩下的最后就是编译ffmpeg了:

1、找到mingw下的msys下的1.0下的msys.bat,打开之后就是模拟linux命令的命令行了。

2、使用cd命令进入到ffmpeg目录,例如 cd /d  这时候会进入到d盘,如果我使用的是cd D:然后回车也是可以的,然后我们就可以使用configure里边的东西了,这是一个ffmpeg里的配置文件,命令如下: ./configure --prefix=D:/ffmpeg_build --enable-shared --disable-static --enable-memalign-hack 然后回车,等待较长时间之后就会看到正在编译的过程,这时候应该还没有编译(目前知道make命令是用来编译的,刚入门,不知道啦,不重要),等到提示当前路径(也就是说上一个命令执行完了,可以开始下一个命令了),执行make 命令,然后执行make install,执行完之后就可以在D:/ffmpeg_build目录下看到编译完成的代码。

3、上述命令中 --frefix=D:/ffmpeg_build 是用来设置编译后输出的目录,也就是make install之后输入的目录。

   --enable-memalign-hack这个查资料是说window上编译成功必须的,好像是什么内存方面的东西,具体的不懂,这个命令是必须有的。

4、如果从ffmpg官网上下载最新的源码去编译的话,可能ffmpeg的configure文件中没有--enable-memalign-hack,这个就难倒我了,蛋疼。没有这个命令我怎么编译成功啊,找个版本低的编译吧。具体原因,身为大牛的你可以去研究研究。

5、Windows下使用MinGW+msys编译FFmpeg错误

In file included from libavformat/hlsenc.c:26:0:
c:\mingw\include\unistd.h:79:1: error: expected ',' or ';' before 'int'
 int __mingw_sleep( unsigned long, unsigned long );
 ^
In file included from libavformat/hlsenc.c:26:0:
c:\mingw\include\unistd.h:105:1: error: expected ',' or ';' before 'int'
 int nanosleep( const struct timespec *, struct timespec * );
 ^
c:\mingw\include\unistd.h:125:28: error: expected ',' or ';' before 'usleep'
 int _cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                            ^
c:\mingw\include\unistd.h:138:10: error: conflicting types for '_cdecl'
 unsigned _cdecl __MINGW_NOTHROW sleep( unsigned );
          ^
c:\mingw\include\unistd.h:125:5: note: previous declaration of '_cdecl' was here


 int _cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
     ^
c:\mingw\include\unistd.h:138:33: error: expected ',' or ';' before 'sleep'
 unsigned _cdecl __MINGW_NOTHROW sleep( unsigned );
                                 ^
c:\mingw\include\unistd.h:153:12: error: expected '=', ',', ';', 'asm' or '__att
ribute__' before 'ftruncate'
 int _cdecl ftruncate( int, off_t );
            ^
libavformat/hlsenc.c: In function 'hls_window':
libavformat/hlsenc.c:271:5: warning: format '%d' expects argument of type 'int',
 but argument 3 has type 'int64_t' [-Wformat=]
     avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
     ^
libavformat/hlsenc.c:274:12: warning: format '%d' expects argument of type 'int'
, but argument 4 has type 'int64_t' [-Wformat=]
            sequence);
            ^
libavformat/hlsenc.c:280:26: warning: format '%i' expects argument of type 'int'
, but argument 3 has type 'int64_t' [-Wformat=]
                          en->size, en->pos);
                          ^
libavformat/hlsenc.c:280:26: warning: format '%i' expects argument of type 'int'
, but argument 4 has type 'int64_t' [-Wformat=]

make: *** [libavformat/hlsenc.o] Error 1


编译以下文件:

libavutil\file.c
libavutil\file_open.c
libavutil\log.c
libavutil\random_seed.c
libavutil\time.c
libavformat\cache.c
libavformat\dashenc.c
libavformat\file.c
libavformat\hdsenc.c
libavformat\smoothstreamingenc.c
libavformat\hlsenc.c
libavcodec\libxvid.c
libavcodec\libxvid_rc.c
ffmpeg.c

都有这个错误。其实是没有找到 _EXTERN_C _cdecl __MINGW_NOTHROW ,其在 window.h 中。


解决办法:在以上文件中, #include <unistd.h> 之前加上 #include <windows.h>

6、还有其他一些错误:

1、*\FFmpeg.h:12: error: libavcodec/avcodec.h: No such file or directory
下载安装ffmpeg库。
2、E:\BRT-Project\BRT-Windows\windows-demos\qtRtspClient\RTSPClient\include\libavutil\common.h:30: error: #error missing -D__STDC_CONSTANT_MACROS / 
#define __STDC_CONSTANT_MACROS
extern "C"{
#ifdef __cplusplus
 #define __STDC_CONSTANT_MACROS
 #ifdef _STDINT_H
  #undef _STDINT_H
 #endif
 # include <stdint.h>
#endif
}
3、*\include\libavutil\common.h:183: error: 'UINT64_C' was not declared in this scope
ffmpeg 是使用C语言写的,默认使用C编译,如果要在C++中调用ffmpeg,则有可能出现错误:
ffmpeg: 'UINT64_C' was not declared in this scope
解决办法三种:
一种是:
extern "C"{
#ifdef __cplusplus
 #define __STDC_CONSTANT_MACROS
 #ifdef _STDINT_H
  #undef _STDINT_H
 #endif
 # include <stdint.h>
#endif
}
第二种是在ffmpeg的common.h文件中添加语句:
/usr/local/include/libavutil/common.h中添加:
#ifndef   UINT64_C
#define   UINT64_C(value)__CONCAT(value,ULL)
#endif
http://code.google.com/p/ffmpegsource/issues/detail?id=11
第三种:
在该头文件加以下语句就行了。
#ifndef INT64_C
#define INT64_C
#define UINT64_C
#endif
 这个要放在
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavutil/avutil.h>
}
来源:http://blog.csdn.net/kidleaf2/article/details/7733284
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

研究这个浪费了好几天,要从网上查很多资料,毕竟没有人可以问。如果还有其他错误,自己去google吧,世界资源时很多的,你的问题说不定人家已经走过n次了。。。。。。。。让我们愉快的玩耍吧,玩转你的ffmpeg



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值