现在的位置: 首页 > 综合 > 正文

【Linux】Linux下MIPS平台交叉编译FFmpeg库 及使用库截取视频中的某一帧

2012年12月11日 ⁄ 综合 ⁄ 共 2044字 ⁄ 字号 评论关闭

一.Linux下MIPS平台交叉编译FFmpeg库:

1.下载ffmpeg库的源代码
(http://sourceforge.net/project/showfiles.php?group_id=205275&package_id=248632):
[root@localhost ffmpeg]# ls
ffmpeg-laster.tar.gz
2.解压:
[root@localhost ffmpeg]# tar zxvf ffmpeg-laster.tar.gz 
3.开始配置,并编译:
[root@localhost ffmpeg]# mkdir ffmpeg-release
[root@localhost ffmpeg]# cd ffmpeg
[root@localhost ffmpeg]# ./configure --enable-cross-compile --target-os=linux --cross-prefix=mipsel-linux- --cc=mipsel-linux-gcc --enable-shared --arch=mips --prefix=/opt/brcm/ffmpeg/ffmpeg-release
[root@localhost ffmpeg]# make
[root@localhost ffmpeg]# make install
[root@localhost ffmpeg]# cd ../ffmpeg-release
[root@localhost ffmpeg-release]# tar -zcvf ffjpeg_lib.tar.gz ./lib


板子上运行:
# cp ffjpeg_lib.tar.gz /usr/local/lib/
# cd /usr/local/lib/
# tar -zxvf ffjpeg_lib.tar.gz -C ../
# rm ffjpeg_lib.tar.gz

# cp ffmpeg-release/bin/* /bin/  
# ffmpeg 
FFmpeg version SVN-r21694, Copyright (c) 2000-2010 Fabrice Bellard, et al.
  built on Nov 17 2012 02:25:17 with gcc 4.5.3
  configuration: --enable-cross-compile --target-os=linux --cross-prefix=mipsel-linux- --cc=mipsel-linux-gcc --enable-shared --arch=mips --prefix=/opt/brcm/ffmpeg/ffmpeg-release
  libavutil     50. 9. 0 / 50. 9. 0
  libavcodec    52.52. 0 / 52.52. 0
  libavformat   52.51. 0 / 52.51. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0.10. 0 /  0.10. 0
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
#

到现在为止, 我们就成功的将 ffmpeg 移植到我们的开发板上了。

 

二.Linux下使用ffmpeg库:

1.命令行使用:
ffmpeg -i test.mp4 -y -f image2 -ss 30 -s 95*95 -vframes 1 a.jpg
找一个MP4文件:test.mp4,然后使用上面的命令就可以取得30秒时视频的图像,保存为
95*95像素的JPG文件。

ffmpeg -i 000094.mp4 -vframes 30 -pix_fmt rgb24  -y -f gif a.gif
把前30帧转化为GIF文件。

2.在程序中调用函数截获视频图片:
首先加入库支持,在我们的可执行程序的Makefile文件中,加入:
CFLAGS += -I/opt/brcm/ffmpeg/ffmpeg-release/include/ 
LFLAGS += -L/opt/brcm/ffmpeg/ffmpeg-release/lib/ -lavutil -lavformat -lavcodec -lswscale
(记住,后面最后四个参数缺一不可,否则编译不通过)
然后关于在编程中使用FFMPEG库的方法,附带一个成熟的Demo。
(test_snap.c和Makefile)

附带几个我自己看过的网站:

http://ray.imiddle.net/2008/10/ffmpeg-install-and-usage/

http://blog.csdn.net/menuconfig/article/details/2600890

http://bbs.chinaunix.net/thread-1932536-1-1.html

抱歉!评论已关闭.