ubuntu和arm平台下的ffmpeg和x264相关库的移植

本文讲解在ubuntu和arm平台下的ffmpeg和x264相关库的移植,最终实现使用ffmpeg进行H.264编码。


1、源码下载:

      本文使用的相关库已经上传,可以从本地址下载本次编译所使用的库:http://download.csdn.net/detail/yxtouch/7527291

或者本个链接:http://onersw9j1.bkt.clouddn.com/fileffmpeg+H264.tar.gz

2、编译

    2.1、yasm-1.2.0移植

      PC可使用如下命令对yasm库进行配置、编译和安装,库的安装目录需要根据自己的需要进行配置修改:

[html]  view plain  copy
 print ?
  1. ./configure --enable-shared --prefix=/home/fyx/workspace/ffmpeg/x64/  
  2. make  
  3. make install  

       ARM平台使用如下命令进行配置、编译和安装:

[html]  view plain  copy
 print ?
  1. ./configure --enable-shared --prefix=/home/fyx/workspace/ffmpeg/arm --host=arm-linux  
  2. make  
  3. make install  

      2.2、设置临时环境变量

    使用如下命令将yasm的安装目录设置为临时环境变量,具体目录按照自己的实际需要进行配置修改。

     PC平台

[html]  view plain  copy
 print ?
  1. export PATH=$PATH:/home/fyx/workspace/ffmpeg/x64/bin  
    ARM平台

[html]  view plain  copy
 print ?
  1. export PATH=$PATH:/home/fyx/workspace/ffmpeg/arm/bin  

   2.3、x264移植

    PC端使用如下命令进行配置、编译和安装。

[html]  view plain  copy
 print ?
  1. ./configure --enable-shared --prefix=/home/fyx/workspace/ffmpeg/x86  
  2. make  
  3. make install  
   ARM平台使用如下命令进行配置。

[html]  view plain  copy
 print ?
  1. ./configure --enable-shared --disable-asm --host=arm-linux --prefix=/home/fyx/workspace/ffmpeg/arm  
    配置完成后编辑config.mak文件,修改如下配置为如下选项:

[html]  view plain  copy
 print ?
  1. ARCH=arm  
  2. CC=arm-linux-gcc  
  3. LD=arm-linux-gcc -o  
  4. AR=arm-linux-ar rc  
  5. AS=  
  6. RANLIB=arm-linux-ranlib  
   编译和安装
[html]  view plain  copy
 print ?
  1. make  
  2. make install  

  2.4、xvid移植

   PC端使用如下命令进行配置、编译和安装。

[html]  view plain  copy
 print ?
  1. ./configure --prefix=/home/fyx/workspace/ffmpeg/x64/  
  2. make  
  3. make install  

  ARM平台使用如下命令进行配置、编译和安装。

[html]  view plain  copy
 print ?
  1. ./configure --host=arm-linux --target=arm-linux  --prefix=/home/fyx/workspace/ffmpeg/arm  
  2. make  
  3. make install  

   2.5、ffmpeg移植

   PC端使用如下命令进行配置、编译和安装。

[html]  view plain  copy
 print ?
  1. ./configure --enable-shared --enable-gpl --enable-libx264 --prefix=/home/fyx/workspace/ffmpeg/x64/ --extra-cflags=-I/home/fyx/workspace/ffmpeg/x64/include --extra-ldflags=-L/home/fyx/workspace/ffmpeg/x64/lib  
  2. make  
  3. make install  

   ARM平台使用如下命令进行配置、编译和安装。

[html]  view plain  copy
 print ?
  1. ./configure --target-os=linux --cc=arm-linux-gcc --arch=arm --enable-shared --enable-cross-compile --cross-prefix=arm-linux- --enable-gpl --enable-libx264 --prefix=/home/fyx/workspace/ffmpeg/arm --extra-cflags=-I/home/fyx/workspace/ffmpeg/arm/include --extra-ldflags=-L/home/fyx/workspace/ffmpeg/arm/lib  
  2. make  
  3. make install  


3、测试

使用eclipse建立C++工程,将本机编译生成的include和lib目录拷贝到工程目录中,将ffmpeg源文件的doc目录下的example中的avcodec.c拷贝到工程中,设置工程的头文件目录。将生成的lib添加到工程中。编译通过后测试即可。

本机测试工程目录结构:

工程属性中添加如下库的连接,并将工程头文件添加到头文件目录中。

编译之后运行运行可执行程序,如果提示找不到库将需要的库拷贝到/lib目录下即可。本例中使用FFmpeg h264测试使用FFmpeg编码h264数据,编码后用VLC播放器打开生成的test.h264视频,效果如下:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值