移植FFmpeg到DaVinci开发环境上
最近想在DaVinci环境上做一个播放器,选了FFmpeg。
编译环境:主机FC7,目标机:DaVinci dm6446,目标OS:Linux
1)下载FFmpeg,FFmpeg通过SVN版本管理系统发布,可以通过命令获取:svn checkout svn://svn.mplayerhq.hu/FFmpeg/trunk FFmpegs
2)交叉编译工具使用mvlinux带的for armv5t的工具链(arm_v5t_le-),gcc版本是3.4.3,当然也可以自己安装一个交叉编译工具;
3)由于FFmpeg的播放器ffplay需要SDL支持,需要先下载编译SDL,可以到http://www.libsdl.org/里面下载源码,目前版本是SDL-1.2.13
解压后执行configure
./configure --prefix=/vlc/cross/SDL-1.2.13/install --host=arm-linux --disable-arts --disable-nasm --disable-video-x11 --disable-nas --disable-joystick --disable-cdrom CC=arm_v5t_le-gcc AR=arm_v5t_le-ar RANLIB=arm_v5t_le-ranlib
然后make,再make install就行了
4)编译FFmpeg,本来在FC上面编译FFmpeg是件非常简单的事情,但是交叉编译由于需要SDL的支持变得比较麻烦,需要修改configure文件,因为SDL是交叉编译的,安装的路径不会是系统的默认路径,会导致FFmpeg configure的时候找不到SDL的信息,configure修改如下(search SDL):
sdl_cflags='-I/vlc/cross/SDL-1.2.13/install/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT'
temp_cflags $sdl_cflags
temp_extralibs '-L/vlc/cross/SDL-1.2.13/install/lib -Wl,-rpath,/vlc/cross/SDL-1.2.13/install/lib -lSDL -lpthread'
enable sdl
restore_flags
#end
#luojc
echo "SDL_CFLAFS=-I/vlc/cross/SDL-1.2.13/install/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT" >>config.mak
echo "SDL_LIBS=-L/vlc/cross/SDL-1.2.13/install/lib -Wl,-rpath,/vlc/cross/SDL-1.2.13/install/lib -lSDL -lpthread" >>config.mak
#end
改完configure后,再执行
./configure --arch=armv5t --cross-prefix=arm_v5t_le- --enable-cross-compile --target-os=linux --disable-optimizations --cc=gcc --enable-shared
然后再make就行啦,看到ffplay了吧:)
5)看看ffplay需要的库
[root@Nemooo FFmpegs]# arm_v5t_le-ldd ffplay
libavdevice.so.52 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/libavdevice.so.52 (0xdead1000)
libavformat.so.52 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/libavformat.so.52 (0xdead2000)
libavcodec.so.51 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/libavcodec.so.51 (0xdead3000)
libavutil.so.49 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/libavutil.so.49 (0xdead4000)
libm.so.6 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/tls/libm.so.6 (0xdead5000)
libSDL-1.2.so.0 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/libSDL-1.2.so.0 (0xdead6000)
libpthread.so.0 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/tls/libpthread.so.0 (0xdead7000)
libc.so.6 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/tls/libc.so.6 (0xdead8000)
libz.so.1 => /opt/montavista/pro/devkit/arm/v5t_le/target/usr/lib/libz.so.1 (0xdead9000)
libbz2.so.1.0 => /opt/montavista/pro/devkit/arm/v5t_le/target/usr/lib/libbz2.so.1.0 (0xdeada000)
libdl.so.2 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/tls/libdl.so.2 (0xdeadb000)
libts-0.0.so.0 => /opt/montavista/pro/devkit/arm/v5t_le/target/usr/lib/libts-0.0.so.0 (0xdeadc000)
/lib/ld-linux.so.3 => /opt/montavista/pro/devkit/arm/v5t_le/target/lib/ld-linux.so.3 (0xdeadd000)
[root@Nemooo FFmpegs]#
将相关的库文件拷贝到目标机器相关目录/usr/lib/下,再把ffplay拷贝到目标机器执行目录,运行ffplay,OK【注意:SDL默认会去找 /dev/fb0的framebuffer设备,而mvlinux上面framebuffer设备是/dev/fb/0,如果不要改SDL源码,可以建立 一个符号链接,ln /dev/fb/0 /dev/fb0就行啦】,可以播放h.264和mpeg4的视频格式文件啦,只是这个由于解码是arm做的而不是dsp做的所以看起来比较慢,但是流程 已经通啦,下一步的目标是将解码工作扔给dsp做,就大功告成啦。