生命不止,奋斗不息。
分类: 嵌入式
2013-07-02 00:00:12
[root@localhost libmad-0.15.1b]# ./configure CC=arm-linux-gcc --enable-fpm=arm --host=arm-linux --disable-shared --disable-debugging --prefix=/opt/s3c2440/video/MPlayer-1.0rc2
[root@localhost libmad-0.15.1b]#make
cc1: error: unrecognized command line option "-fforce-mem"
make[2]: *** [version.lo] 错误 1
make[2]: Leaving directory `/home/fyyy/mplayer/libmad-0.15.1b'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/home/fyyy/mplayer/libmad-0.15.1b'
make: *** [all] 错误 2
[root@localhost libmad-0.15.1b]#
这时如果出现错误:cc1: error: unrecognized command line option “-fforce-mem”
(其实这个错误是编译安装libmad时候引起的,audacity包含libmad)
解决方式是:找到libmad configure之后的Makefile,并vi Makefile
去掉129行"-fforce-mem"字符串,因为arm-eabi编译器都不支持这个选项,将其删除之后,就ok了
creating libmad.la
(cd .libs && rm -f libmad.la && ln -s ../libmad.la libmad.la)
make[2]: Leaving directory `/home/fyyy/mplayer/libmad-0.15.1b'
make[1]: Leaving directory `/home/fyyy/mplayer/libmad-0.15.1b'
[root@localhost libmad-0.15.1b]#
[root@localhost libmad-0.15.1b]# make install
make install-recursive
make[1]: Entering directory `/home/fyyy/mplayer/libmad-0.15.1b'
make[2]: Entering directory `/home/fyyy/mplayer/libmad-0.15.1b'
make[3]: Entering directory `/home/fyyy/mplayer/libmad-0.15.1b'
mkdir -p -- . /opt/s3c2440/video/MPlayer-1.0rc2/lib
/bin/sh ./libtool --mode=install /usr/bin/install -c libmad.la /opt/s3c2440/video/MPlayer-1.0rc2/lib/libmad.la
/usr/bin/install -c .libs/libmad.lai /opt/s3c2440/video/MPlayer-1.0rc2/lib/libmad.la
/usr/bin/install -c .libs/libmad.a /opt/s3c2440/video/MPlayer-1.0rc2/lib/libmad.a
arm-linux-ranlib /opt/s3c2440/video/MPlayer-1.0rc2/lib/libmad.a
chmod 644 /opt/s3c2440/video/MPlayer-1.0rc2/lib/libmad.a
PATH="$PATH:/sbin" ldconfig -n /opt/s3c2440/video/MPlayer-1.0rc2/lib
----------------------------------------------------------------------
Libraries have been installed in:
/opt/s3c2440/video/MPlayer-1.0rc2/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
mkdir -p -- . /opt/s3c2440/video/MPlayer-1.0rc2/include
/usr/bin/install -c -m 644 mad.h /opt/s3c2440/video/MPlayer-1.0rc2/include/mad.h
make[3]: Leaving directory `/home/fyyy/mplayer/libmad-0.15.1b'
make[2]: Leaving directory `/home/fyyy/mplayer/libmad-0.15.1b'
make[1]: Leaving directory `/home/fyyy/mplayer/libmad-0.15.1b'
[root@localhost libmad-0.15.1b]#
编译Mplay
[root@localhost MPlayer-1.0rc2]# ./configure --prefix=/opt/s3c2440/video/MPlayer-1.0rc2/mplayer --disable-mencoder --enable-linux-devfs --disable-iconv --enable-network --disable-live --disable-dvdnav --disable-dvdread --disable-dvdread-internal --disable-libdvdcss-internal --enable-ftp --enable-libavcodec_a --enable-libavcodec_mpegaudio_hp --enable-mad --disable-mp3lib --disable-ivtv --enable-fbdev --enable-ossaudio --enable-cross-compile --cc=arm-linux-gcc --host-cc=gcc --target=arm-linux --enable-static --with-extraincdir=/opt/s3c2440/video/MPlayer-1.0rc2/include --with-extralibdir=/opt/s3c2440/video/MPlayer-1.0rc2/lib 2>&1 |tee logfile
参数解释:
--prefix mplayer安装路径,make install 后就可以在本目录下找到可执行程序mplayer
--cc 交叉编译工具,如果没添加到环境变量,就要指定完整路径
--enable-static 设定静态连接
--disable-win32dll 禁用win32动态链接库支持。在pre版本中该参数为
--disable-dvdread 禁用libdvdread.
--enable-fbdev 支持fbdev,这个一定要选上。
--disable-mp3lib 和 --enable-mad
arm系列的cpu,一般都没浮点运算单元,而mplayer的mp3解码默认使用mp3lib,这个是浮点运算库,在arm上肯定跑不了,使用ffmp3或者libmad(需要外部库libmad支持)应该就没问题了。所以这里需要禁止掉mencoder和使能libmad。
--disable-mencoder 禁止编码功能
--disable-live 禁止live 555流媒体。
--enable-libavcodec_a 启用静态的libavcodec解码。在pre版本中该参数为--enable-libavcodec。
--disable-armv5te --disable-armv6 禁用armv5te、armv6指令扩展。
--with-extraincdir和-with-extralibdir 指定libmad和mad.h的路径
[root@localhost MPlayer-1.0rc2]# make
[root@localhost MPlayer-1.0rc2]# vi libavcodec/armv4l/dsputil_arm_s.S
打开后在文件开头处添加以下代码
#ifndef HAVE_PLD
.macro pld reg
.endm
#endif
(这段代码意思是定义一个空的ARM汇编宏 pld,这样当代码出现pld指令,就变成一条空指令)
[root@localhost MPlayer-1.0rc2]# vi libmpeg2/motion_comp_arm_s.S
打开后在文件开头处添加以下代码
#ifndef HAVE_PLD
.macro pld reg
.endm
#endif
(这段代码意思是定义一个空的ARM汇编宏 pld,这样当代码出现pld指令,就变成一条空指令)
[root@localhost MPlayer-1.0rc2]# make
[root@localhost MPlayer-1.0rc2]# make install
最后会报错,但是这个错不影响最终使用,这只是把可执行文件变小点失败了,没关系。
make[1]: Leaving directory `/home/fyyy/mplayer/MPlayer-1.0rc2/osdep'
install -m 755 -s mplayer /opt/s3c2440/video/MPlayer-1.0rc2/mplayer/bin
strip: Unable to recognise the format of the input file `/opt/s3c2440/video/MPlayer-1.0rc2/mplayer/bin/mplayer'
install: strip failed
make: *** [install-mplayer] 错误 1
如果要修改这个错误,进行如下操作
[root@localhost MPlayer-1.0rc2]# vi Makefile
--------------------
255 install-mplayer: mplayer$(EXESUF)
256 $(INSTALL) -m 755 $(INSTALLSTRIP) mplayer$(EXESUF) $(BINDIR)
257
修改为
255 install-mplayer: mplayer$(EXESUF)
256 $(INSTALL) -m 755 mplayer$(EXESUF) $(BINDIR)
[root@localhost MPlayer-1.0rc2]# make install
[root@localhost MPlayer-1.0rc2]#
把生成的可执行文件mplayer 复制到根文件系统中,在开发板终端运行以下命令,
mplayer 01.avi -framedrop -quiet -vf rotate -flip -x 240 -y 320
出现:
[AO OSS] audio_setup: Can't open audio device /dev/sound/dsp: No such file or directory
是因为找不到音频设备,查看根文件系统中有没有/dev/dsp这个文件,如果没有则是没有安装声卡驱动,如果有则作一个连接符,开发板终端输入以下命令:
mkdir /dev/sound/
ln -s /dev/dsp /dev/sound/dsp
再次运行:
mplayer 01.avi -framedrop -quiet -vf rotate -flip -x 240 -y 320 -ac mad
可发看到已经可以看到图像和声音了。
加上 -vf rotate=1,scale=240:320 就能横屏适应屏幕播放了。如下
横屏播放:
mplayer 01.avi -framedrop -quiet -vf rotate=1,scale=240:320 -ac mad
参数:
-ac mad 表示强制用libmad解码
-zoom -x 320 -y 240 全屏
-cache 4096 缓存设置为4M
-loop 循环播放,为0则无限循环播放,!0则有限播放
-playlist