CYGWIN下编译FFMpeg

1、首先安装cygwin。

2、下载ffmpeg源码包:
http://ffmpeg.org/download.html


3、下载ffmpeg源码后,解压到相应目录;打开cygwin,进入ffmpeg相应目录。

4、开始编译,运行以下命令:
    ./configure --enable-memalign-hack --enable-ffserver --enable-network --enable-protocols --enable-muxers
    make
    make install


说明:

1)这次安装只是测试整个安装过程,所以配置的参数只选了最基本的;

2)在执行./configure过程中,曾经出现以下报错:
    ./configure
    ./configure: line 9: $'/r': command not found
    ./configure: line 12: $'/r': command not found
    ...
  这是因为使用SVN下载ffmpeg源码,./configure文件中的换行是'/r/n',cygwin无法识别导致的。
解决办法有几种:a)在linux下或cygwin下用svn去获取ffmpeg代码;b)使用工具替换'/r/n' -> '/n',用UltraEdit即可;c)通过google搜索以下关键词“ffmpeg configure unexpected token”。

3)在执行make命令过程中,又出现以下错误:
    line 53: syntax error near unexpected token `fi'
    line 53: `fi"

解决方法:使用 dos2unix filename
    dos2unix configure
 

4)ffmpeg yasm not found, use --disable-yasm for a crippled build
  yasm是汇编编译器,因为ffmpeg中为了提高效率用到了汇编指令,比如MMX和SSE。解决这个问题方面有两个:a) 在网上下载一个yasm.exe并安装在mingw/bin下面,编译代码时会发现asm后缀的文件用的编译器是yasm,c文件用的是gcc;b) 不使用汇编指令,即./configure  --disable-yasm。
  yasm下载地址:http://yasm.tortall.net/Download.html
下载yasm-1.2.0-cygwin.exe,改名后放到cygwin/bin下。

5、编译完成

  回到Windows目录下,看到已经生成ffmpeg.exe/ffserver.exe。但是这个时候运行会报错,因为刚才我们是用动态方式编译的,所以生成的动态的dll(cygavcodec-51.dll/cygavformat-51.dll/cygavutil-49.dll)是放在类似libavcodec的目录下,所以要么加入到系统环境目录中,要么与ffmpeg.exe放在同一目录下。
  最后,也必须对cygwin的一系列dll加载到Windows的环境目录中。现在即可运行生成的ffmpeg与ffserver!

原文地址:https://www.cnblogs.com/tairikun/p/2678324.html