mplayer的移植

  1. 安装音频解码库 libmad库(因mplayer自带的音频解码效果不佳,编译Mplayter时–disable Mp3xx)
    ./configure CC=arm-linux-gnueabihf-gcc –host=arm-linux-gnueabihf –disable-shared –disable-debugging –prefix=$PWD/install
    Makefile 里找到里面的“–fforce-mem”,然后删除保存退出即可 
    make出错 :
    /tmp/ccnDaqrw.s: Assembler messages:
    /tmp/ccnDaqrw.s:1301: Error: selected processor does not support Thumb mode rsc r5,r5,#0'
    /tmp/ccnDaqrw.s:1467: Error: selected processor does not support Thumb mode
    rsc sl,sl,#0’
    /tmp/ccnDaqrw.s:1914: Error: selected processor does not support Thumb mode rsc r2,r2,#0'
    /tmp/ccnDaqrw.s:2064: Error: selected processor does not support Thumb mode
    rsc r7,r7,#0’

修改fixed.h
将#  define MAD_F_MLN(hi, lo)  \
    asm (“rsbs  %0, %2, #0\n\t”  \
         “rsc   %1, %3, #0”  \
         : “=r” (lo), “=r” (hi)  \
         : “0” (lo), “1” (hi)  \
         : “cc”)
改为

ifdef thumb

/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero
operand. If needed this code can also support Thumb-1 
(simply append “s” to the end of the second two instructions). */

define MAD_F_MLN(hi, lo) \

asm (“rsbs %0, %0, #0\n\t” \
“sbc %1, %1, %1\n\t” \
        “sub %1, %1, %2” \
        : “+&r” (lo), “=&r” (hi) \
        : “r” (hi) \
        : “cc”)

else /* ! thumb */

define MAD_F_MLN(hi, lo) \

        asm (“rsbs %0, %2, #0\n\t” \
        “rsc %1, %3, #0” \
         : “=r” (lo), “=r” (hi) \
          : “=&r” (lo), “=r” (hi) \
          : “0” (lo), “1” (hi) \
          : “cc”)

endif /* thumb */

make
Make install
2.Mplayer的安装
网上的参考配置:
./configure –host-cc=gcc –cc=arm-linux-gnueabihf-gcc –target=arm-linux-gnueabihf –enable-fbdev –enable-static –disable-dvdread –disable-live –disable-mp3lib –enable-mad –disable-win32dll –disable-mencoder –disable-ivtv –disable-dvdnav –disable-dvdread-internal –disable-libdvdcss-internal –enable-libavcodec_a –prefix=$PWD/install

提示: (因网上的版本较老)
Unknown parameter: –disable-mp3lib 更改为 –disable-mp3lame –disable-mp3lame-lavc
Unknown parameter: –disable-dvdread-internal
Unknown parameter: –disable-dvdread-internal
Unknown parameter: –disable-libdvdcss-internal 更改为–disable-dvdread
Unknown parameter: –enable-libavcodec_a
配置项解析:
–enable-fbdev                           //打开framebuffer支持.ARM开发板必须的 
–enable-static                           //静态编译,编译成功后只需要将exe文件拷走即可以使用 
–disable-dvdread –disable-dvdnav –disable-dvdread-internal //全部与DVD相关,无视即可 
–disable-libdvdcss-internal        //这个不加低版本mplayer也会出错 
–disable-live                              //禁止流媒体,我们用不到 
–disable-mp3lib –enable-mad  //关闭默认的MP3解码库,使用我们刚才编译的libmad 
–disable-win32dll                      //禁用win32动态链接库支持 
–disable-mencoder                   //交叉编译mencoder会有问题,而且arm上不需要这个功能 
–disable-ivtv                             //如果不加会出现ivtv文件产生的错误   
–enable-libavcodec_a               //启用静态的libavcodec解码 
–prefix=/usr/local/Mplayer/mplayer 2>&1 | tee logfile  //不解释 

./configure –host-cc=gcc –cc=arm-linux-gnueabihf-gcc –target=arm-linux-gnueabihf –enable-fbdev –enable-static –disable-dvdread –disable-live –enable-mad –disable-win32dll –disable-mencoder –disable-ivtv –prefix=$PWD/install

出现如下错误:
libmpcodecs/ad_libmad.c:37:17: fatal error: mad.h: No such file or directory,原因如下:
这时因为没有找到libmad的头文件和库,如果不用–extra-cflags=-I/usr/arm-linux-gnueabihf/include –extra-libs=-L/usr/arm-linux-gnueabihf/lib 选项,需手动添加libmad库的支持。
解决方法是将 libmad 的include下文件直接拷贝到mplayer源代码中,而对于其下面的库libmad.a,则先执行上面的“运行configure”一步,会生成config.mak文件,然后修改config.mak中在-lmad更改为 -lmad -L/usr/arm-linux-gnueabihf/lib,然后执行make. 

  1. 配置项为
    ./configure –host-cc=gcc –cc=arm-linux-gnueabihf-gcc –target=arm-linux-gnueabihf –enable-fbdev –enable-static –disable-dvdread –disable-live –enable-mad –disable-win32dll –disable-mencoder –disable-ivtv –disable-libavcodec_mpegaudio_hp –disable-mp3lame –disable-mp3lame-lavc –prefix=$PWD/install

修改config.mak中在-lmad更改为 -lmad -L/usr/arm-linux-gnueabihf/lib

make

出现如下错误:
ffmpeg/libavcodec/libavcodec.a(pngdec.o): In function decode_text_chunk':
pngdec.c:(.text+0x164): undefined reference to
inflateInit_’
pngdec.c:(.text+0x1dc): undefined reference to inflate'
pngdec.c:(.text+0x208): undefined reference to
inflateEnd’
pngdec.c:(.text+0x2cc): undefined reference to inflateEnd'
ffmpeg/libavcodec/libavcodec.a(pngdec.o): In function
decode_frame_common’:
pngdec.c:(.text+0xfb4): undefined reference to inflate'
ffmpeg/libavcodec/libavcodec.a(pngdec.o): In function
decode_frame_apng’:
pngdec.c:(.text+0x3028): undefined reference to inflateInit_'
pngdec.c:(.text+0x30a0): undefined reference to
inflateEnd’
ffmpeg/libavcodec/libavcodec.a(rscc.o): In function rscc_decode_frame':
rscc.c:(.text+0x2fc): undefined reference to
uncompress’
rscc.c:(.text+0x4f4): undefined reference to uncompress'
ffmpeg/libavcodec/libavcodec.a(screenpresso.o): In function
screenpresso_decode_frame’:
screenpresso.c:(.text+0x7c): undefined reference to uncompress'
ffmpeg/libavcodec/libavcodec.a(tdsc.o): In function
tdsc_decode_frame’:
tdsc.c:(.text+0x64): undefined reference to `uncompress’
collect2: ld returned 1 exit status
make: * [mplayer] Error 1

2.
./configure –host-cc=gcc –cc=arm-linux-gnueabihf-gcc –target=arm-linux-gnueabihf –enable-fbdev –enable-static –disable-dvdread –disable-live –enable-mad –disable-win32dll –disable-mencoder –disable-ivtv –disable-mp3lame –disable-mp3lame-lavc –prefix=$PWD/install

还是上述错误

/home/book/work/install_software/MPlayer-1.3.0/ffmpeg/libavcodec/pngdec.c
将TI 开发板带的libpng*.h 和libpng*.so复制到工具链中/usr/arm-linux-gnueabihf-gcc/inlude /usr/arm-linux-gnueabihf-gcc/lib 中再次编译
还是出错。

Try2:
1.
下载Mplayter1.2.0版本:
./configure –host-cc=gcc –cc=arm-linux-gnueabihf-gcc –target=arm-linux-gnueabihf –enable-fbdev –enable-static –disable-dvdread –disable-live –enable-mad –disable-win32dll –disable-mencoder –disable-ivtv –disable-mp3lame –disable-mp3lame-lavc –prefix=$PWD/install

将 libmad 的include下文件直接拷贝到mplayer源代码中.
对于其下面的库libmad.a,则先执行上面的“运行configure”一步,会生成config.mak文件,然后修改config.mak中在-lmad更改为 -lmad -L/usr/arm-linux-gnueabihf/lib,然后执行make. 
Make
还是出现ffmpeg/libavcodec/libavcodec.a(pngdec.o): In function decode_text_chunk':
pngdec.c:(.text+0x164): undefined reference to
inflateInit_’
pngdec.c:(.text+0x1dc): undefined reference to `inflate’

2.
增加外部库和头文件链接 去掉静态编译
./configure –host-cc=gcc –cc=arm-linux-gnueabihf-gcc –target=arm-linux-gnueabihf –enable-fbdev –disable-dvdread –disable-live –enable-mad –disable-win32dll –disable-mencoder –disable-ivtv –disable-mp3lame –disable-mp3lame-lavc –extra-cflags=-I/usr/arm-linux-gnueabihf/include –extra-libs=-L/usr/arm-linux-gnueabihf/lib –prefix=$PWD/install
(新版支持 –extra的配置
–extra-cflags=-I/home/liuyan/kangyuan/MPlayer/libmad-build/include –extra-libs=-L/home/liuyan/kangyuan/MPlayer/libmad-build/lib)

make
make install 出错,出现如下提示:
install -d
/home/book/work/install_software/MPlayer-1.2/instal/bin
/home/book/work/install_software/MPlayer-1.2/instal/etc/mplayer
/home/book/work/install_software/MPlayer-1.2/instal/lib
install -m 755 -s mplayer /home/book/work/install_software/MPlayer-1.2/instal/bin
strip: Unable to recognise the format of the input file `/home/book/work/install_software/MPlayer-1.2/instal/bin/mplayer’
install: strip process terminated abnormally
make: * [install-mplayer] Error 1

解决方法:   
查资料看install带-s 参数时会自动调用strip来strip应用程序。但是arm编译时要调用arm-linux-strip才有正确处理。解决办法是取消-s参数,查看Makefile可以发现-s是如下  
( I N S T A L L ) m 755 (INSTALLSTRIP) mplayer ( E X E S U F ) (BINDIR)  
  的INSTALLSTRIP设置的,它默认是-s,因此只要简单在Makefile的install部分前面加入:  
INSTALLSTRIP := #将其置为空即可  

在Makefile 中增加INSTALLSTRIP :=
install-dirs:
( I N S T A L L ) d (BINDIR) ( C O N F D I R ) (LIBDIR)
INSTALLSTRIP :=
install-%: % ( E X E S U F ) i n s t a l l d i r s (INSTALL) -m 755 ( I N S T A L L S T R I P ) < $(BINDIR)

Make install
生成如下目录 bin etc lib
cp mplayer /home/book/work/rootfs_min/usr/bin/
cp mplayer /home/book/work/rootfs_min/etc/ -nR

发现lib目录是空的, 把文件copy到开发板后
/ # mplayer –help
mplayer: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

  1. 使能静态编译,使能png
    ./configure –host-cc=gcc –cc=arm-linux-gnueabihf-gcc –target=arm-linux-gnueabihf –enable-fbdev –disable-dvdread –disable-live –enable-mad –disable-win32dll –disable-mencoder –disable-ivtv –disable-mp3lame –disable-mp3lame-lavc –extra-cflags=-I/usr/arm-linux-gnueabihf/include –extra-libs=-L/usr/arm-linux-gnueabihf/lib –prefix=$PWD/install –enable-png –enable-static

编译通过:
/ # mplayer –help
mplayer: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

将work/software/linux-devkit/sysroots/cortexa8hf-vfp-neon-linux-gnueabi/lib 中的lib.so.1 lib.so.1.2.8 文件copy到开发板的库目录中.
运行MP3 正常,但没有声音
提示一下信息:
[AO OSS] audio_setup: Can’t open audio device /dev/dsp: No such file or directory
DVB card number must be between 1 and 4
AO: [null] 44100Hz 2ch floatle (4 bytes per sample)
Video: no video
Starting playback…
A: 10.1 (10.1) of 285.0 (04:45.0) 11.6%

解决方法:
使用mplayer播放音乐时警告“[AO OSS] audio_setup: Can’t open audio device /dev/dsp: No such file or directory”
这个问题主要是缺少了OSS PCM (digital audio) API模块。
在内核源代码里面执行“make menuconfig”,进入Deivce Drivers——>
Sound card support ——>
Advanced Linux Sound Architecture——>
选中OSS PCM(digital audiop) API和OSS PCM (Digital audio) API – Include plugin system

运行MP4 失败:
[AO OSS] audio_setup: Can’t open audio device /dev/dsp: No such file or directory
DVB card number must be between 1 and 4
AO: [null] 48000Hz 2ch floatle (4 bytes per sample)
Starting playback…
Could not find matching colorspace - retrying with -vf scale…
Opening video filter: [scale]
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
[swscaler @ 0xcb71d0]bicubic scaler, from yuv420p to bgra using C
[swscaler @ 0xcb71d0]No accelerated colorspace conversion found from yuv420p to bgra.
[swscaler @ 0xcb71d0]using unscaled yuv420p -> bgra special converter
VO: [fbdev] 1280x720 => 1280x720 BGRA

在uboot中设置参数为1280x720的分辨率,视频正常输出,但CPU占用率太高

声卡驱动测试
ls -l /dev/dsp /dev/mixer
播放:
在WINDOWS PC里找一个wav文件,放到开发板根文件系统里
cat Windows.wav > /dev/dsp
录音:
cat /dev/dsp > sound.bin //sound.bin为生成的录音文件
然后对着麦克风说话
ctrl+c退出
cat sound.bin > /dev/dsp // 就可以听到录下的声音

./mplayer -fs -zoom x 320 y240 1.mp4

Can 应用程序将编译的mplayer放置开发板上运行:
   ./mplayer –fs –zoom –x 320 –y 240 -ac mad –nosound –cache 4096 output.avi  –loop 0
    参数解释:
   -zoom -x 320 -y 240 全屏
         -ac mad 是必须,表示强制用libmad解码.
   -nosound 取消音频
   -cache 4096 缓存设置为4M
   -loop 循环播放,为0则无限循环播放,!0则有限播放
-vo help 显示支持的视频驱动 ( fbdev Framebuffer Device fbdev2 Framebuffer Device)
./mplayer –fs –zoom –x 320 –y 240 -ac mad –nosound –cache 4096 output.avi  –loop 0 -vo fbdev2

如果搞不清自己分辩率的,可在MPlayer用 -fullscreen参数 .或者执行busybox shell命令fbset查看自n己板的分辩率
有人测试发现在有一些开发板下.Mplayer播放后,输出会干扰后续shell的执行行.用下面比较长的参数一般没事
         ./mplayer -ac mad 2.mpg -quiet \ -vf scale=320:240 2>&1 1>/dev/null &&

猜你喜欢

转载自blog.csdn.net/tiger15605353603/article/details/81296442
今日推荐