1. 程式人生 > >mplayer的移植

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是如下  
(INSTALL)m755(INSTALLSTRIP) mplayer(EXESUF)(BINDIR)  
  的INSTALLSTRIP設定的,它預設是-s,因此只要簡單在Makefile的install部分前面加入:  
INSTALLSTRIP := #將其置為空即可  

在Makefile 中增加INSTALLSTRIP :=
install-dirs:
(INSTALL)d(BINDIR) (CONFDIR)(LIBDIR)
INSTALLSTRIP :=
install-%: %(EXESUF)installdirs(INSTALL) -m 755 (INSTALLSTRIP)< $(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 &&