Mplayer的移植

 

日期: 2013.8.4  作者:杨正 QQ:1209758756  Email:yz2012ww@gmail.com

前言

MPlayer最初的名字叫做"MPlayer - The Movie Player for Linux",不过后来开发者们简称其为"MPlayer - The Movie Player"原因是MPlayer已经不仅可以用于Linux而可以在所有平台上运行.MPlayer是一款开源多媒体播放器,以GNU通用公共许可证发布。此款软件可在各主流作业系统使用,例如Linux和其他类Unix系统、微软的视窗系统及苹果电脑的Mac OS X系统。MPlayer是建基于命令行界面,在各作业系统可选择安装不同的图形界面。mplayer的另一个大的特色是广泛的输出设备支持。它可以在X11XvDGAOpenGLSVGAlibfbdevAAlibDirectFB下工作。

开发环境:linux

目标环境:fl2440

移植步骤:

         移植libmad
      
移植
libid3tag
       移植
madplay
       移植
mplayer
       测试

一、移植libmad库

1)、下载源代码包,并解压缩:

[lingyun@localhost mplayer]$ wget ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz

[lingyun@localhost mplayer]$ tar -zxf libmad-0.15.1b.tar.gz

[lingyun@localhost mplayer]$ ls

libmad-0.15.1b  libmad-0.15.1b.tar.gz

[lingyun@localhost mplayer]$ mkdir -p install/libmad

[lingyun@localhost mplayer]$ pwd

/home/lingyun/yangzheng/mplayer

[lingyun@localhost mplayer]$ cd libmad-0.15.1b

 

2)、配置生产Makefile(--prefix=/home/lingyun/yangzheng/mplayer/install/libmad/:指定最终库文件的安装路径; CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc指定交叉编译器)

[lingyun@localhost libmad-0.15.1b]$  ./configure --enable-fpm=arm --host=arm-linux --disable-shared \

> --disable-debugging --prefix=/home/lingyun/yangzheng/mplayer/install/libmad/ \

>CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc

注:sed -i -e 's/-fforce-mem//' Makefile    //makefile中的-fforce-mem删除掉

3)、使用make和make install进行编译,安装:

[lingyun@localhost libmad-0.15.1b]$ make

[lingyun@localhost libmad-0.15.1b]$ make install

[lingyun@localhost libmad]$ tree

.

|-- include

|   `-- mad.h

`-- lib

    |-- libmad.a

    `-- libmad.la

 

2 directories, 3 files

 

 

 

 

二、移植libid3tag

1)、下载源代码包:

[lingyun@localhost mplayer]$ wget ftp://ftp.mars.org/pub/mpeg/libid3tag-0.15.1b.tar.gz

[lingyun@localhost mplayer]$ tar -zxf libid3tag-0.15.1b.tar.gz
[lingyun@localhost mplayer]$ mkdir –p install/madid3

2)、配置生产Makefile(CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc:指定交叉编译器):

[lingyun@localhost libid3tag-0.15.1b]$ ./configure --host=arm-linux --prefix=/home/lingyun/yangzheng/mplayer/install/madid3/ \
disable-shared --disable-debugging  \
CC=
/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc

再修改一下makefile,当然也可以把CFLAGSLDFLAGS一次加到上面的那条命令里面:

[lingyun@localhost libid3tag-0.15.1b]$ vim Makefile

INST_PATH = /home/lingyun/yangzheng/mplayer/install

#CFLAGS = -Wall -O2 -fomit-frame-pointer

CFLAGS = -I${INST_PATH}/libmad/include

#LDFLAGS =

LDFLAGS=-L${INST_PATH}/libmad/lib

[lingyun@localhost libid3tag-0.15.1b]$ make

[lingyun@localhost libid3tag-0.15.1b]$ make install

[lingyun@localhost madid3]$ tree

.

|-- include

|   `-- id3tag.h

`-- lib

    |-- libid3tag.a

    `-- libid3tag.la

 

2 directories, 3 files

 

 

 

三、移植madplay

1)、下载源代码包,并解压缩:

[lingyun@localhost mplayer]$ wget ftp://ftp.mars.org/pub/mpeg/madplay-0.15.2b.tar.gz
[lingyun@localhost mplayer]$ tar –zxf madplay-0.15.2b.tar.gz

[lingyun@localhost mplayer]$ mkdir -p install/madplay

2)、配置生产Makefile(--prefix=/home/lingyun/yangzheng/mplayer/install/madplay/:指定安装路径;CFLAGSLDFLAGS指定编译时所用到的库文件;CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc指定交叉编译器):

[lingyun@localhost madplay-0.15.2b]$ ./configure --host=arm-linux  \
--prefix=
/home/lingyun/yangzheng/mplayer/install/madplay/ \
--disable-shared --disable-debugging \
CFLAGS=”-I/home/lingyun/yangzheng/mplayer/install/libmad/include \
-I/home/lingyun/yangzheng/mplayer/install/madid3/include "
LDFLAGS="-L/home/lingyun/yangzheng/mplayer/install/libmad/lib \
-L/home/lingyun/yangzheng/mplayer/install/madid3/lib"
CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc

 

3)、使用makemake install进行安装:

[lingyun@localhost madplay-0.15.2b]$ make

[lingyun@localhost madplay-0.15.2b]$ make install

[lingyun@localhost madplay]$ tree

.

|-- bin

|   |-- abxtest

|   `-- madplay

|-- man

|   `-- man1

|       |-- abxtest.1

|       `-- madplay.1

`-- share

    `-- locale

        |-- en

        |   `-- LC_MESSAGES

        |       `-- madplay.mo

        |-- es

        |   `-- LC_MESSAGES

        |       `-- madplay.mo

        |-- fr

        |   `-- LC_MESSAGES

        |       `-- madplay.mo

        |-- hr

        |   `-- LC_MESSAGES

        |       `-- madplay.mo

        |-- locale.alias

        `-- no

            `-- LC_MESSAGES

                `-- madplay.mo

 

15 directories, 10 files

 

四、移植mplayer

1)、下载源代码包,并解压缩:

[lingyun@localhost mplayer]$ wget http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc3.tar.bz2

[lingyun@localhost mplayer]$ tar -jxf MPlayer-1.0rc3.tar.bz2

[lingyun@localhost mplayer]$ mkdir -p install/mplayer

 

2)、修改motion_comp_arm_s.S文件

[lingyun@localhost libmpeg2]$ pwd

/home/lingyun/yangzheng/mplayer/MPlayer-1.0rc3/libmpeg2

[lingyun@localhost libmpeg2]$ ls

alloc.c       cpu_state.c   idct_altivec.c         mmx.h                  motion_comp_arm_s.S  mpeg2.h           vlc.h

alpha_asm.h   decode.c      idct.c                 motion_comp_alpha.c    motion_comp.c        mpeg2_internal.h

attributes.h  header.c      idct_mmx.c             motion_comp_altivec.c  motion_comp_mmx.c    slice.c

cpu_accel.c   idct_alpha.c  libmpeg2_changes.diff  motion_comp_arm.c      motion_comp_vis.c    vis.h

 

[lingyun@localhost libmpeg2]$ vim motion_comp_arm_s.S

    .text

 

#ifndef HAVE_PLD

    .macro pld reg

    .endm

#endif

 

3)、配置生产Makefile(prefix=/home/lingyun/yangzheng/mplayer/install/mplayer/:
指定安装路径;--cc=arm-linux-gcc --ar=arm-linux-ar --ranlib=arm-linux-ranlib --disable-gui:指定交叉编译器):

[lingyun@localhost MPlayer-1.0rc3]$ ./configure --prefix=/home/lingyun/yangzheng/mplayer/install/mplayer/ \

> --cc=arm-linux-gcc  --ar=arm-linux-ar --ranlib=arm-linux-ranlib --disable-gui \

> --target=arm-armv4-linux --host-cc=gcc  --disable-freetype \

> --enable-fbdev --disable-mencoder --disable-sdl --disable-live  --disable-dvdread \

> --disable-libdvdcss-internal --disable-x11 --enable-cross-compile  --disable-mp3lib \

> --enable-ass \

> --disable-dvdnav  --disable-dvdread-internal    --disable-jpeg --disable-tga \

> --disable-dvbhead --disable-pnm --disable-tv --disable-ivtv \

> --disable-fontconfig --disable-xanim --disable-win32dll --disable-armv5te --disable-armv6

 

4)、使用makemake install进行编译,安装:

[lingyun@localhost MPlayer-1.0rc3]$ make

[lingyun@localhost MPlayer-1.0rc3]$ make install

 

[lingyun@localhost MPlayer-1.0rc3]$ /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip /home/lingyun/yangzheng/mplayer/install/mplayer/bin/mplayer

[lingyun@localhost install]$ cd mplayer/

[lingyun@localhost mplayer]$ ls

bin  etc  lib

[lingyun@localhost mplayer]$ tree

.

|-- bin

|   `-- mplayer

|-- etc

|   `-- mplayer

`-- lib

 

4 directories, 1 file

 

[lingyun@localhost MPlayer-1.0rc3]$ ls

******mplayer******

5)、把生成的mplayer下载到开发板的/bin目录下

 

五、测试:

>: ./bin/mplayer zhendeaini.mp3

Creating config file: //.mplayer/config

MPlayer 1.0rc3-4.5.4 (C) 2000-2009 MPlayer Team

 

Playing zhendeaini.mp3.

Audio only file format detected.

Clip info:

 Title: ?μ???

 Artist: Beyond(????

 Album: ?μMusicPalace

 Year:

 Comment:

 Genre: Unknown

==========================================================================

Requested audio codec family [mp3] (afm=mp3lib) not available.

Enable it at compilation.

Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders

AUDIO: 44100 Hz, 2 ch, s16le, 32.0 kbit/2.27% (ratio: 4000->176400)

Selected audio codec: [ffmp3] afm: ffmpeg (FFmpeg MPEG layer-3 audio)

==========================================================================

AO: [oss] 44100Hz 2ch s16le (2 bytes per sample)

Video: no video

Starting playback...

A:  42.7 (42.7) of 1097.0 (18:17.0) 12.1%                                      

 

MPlayer interrupted by signal 2 in module: play_audio

A:  42.8 (42.7) of 1097.0 (18:17.0) 12.1%                                      

Exiting... (Quit)

>: ./bin/mplayer zhendeaini.mp3

MPlayer 1.0rc3-4.5.4 (C) 2000-2009 MPlayer Team

 

Playing zhendeaini.mp3.

Audio only file format detected.

Clip info:

 Title: ?μ???

 Artist: Beyond(????

 Album: ?μMusicPalace

 Year:

 Comment:

 Genre: Unknown

==========================================================================

Requested audio codec family [mp3] (afm=mp3lib) not available.

Enable it at compilation.

Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders

AUDIO: 44100 Hz, 2 ch, s16le, 32.0 kbit/2.27% (ratio: 4000->176400)

Selected audio codec: [ffmp3] afm: ffmpeg (FFmpeg MPEG layer-3 audio)

==========================================================================

AO: [oss] 44100Hz 2ch s16le (2 bytes per sample)

Video: no video

Starting playback...

A:  19.3 (19.3) of 1097.0 (18:17.0) 12.0%                                      

 

MPlayer interrupted by signal 2 in module: play_audio

A:  19.4 (19.3) of 1097.0 (18:17.0) 12.0%                                      

Exiting... (Quit)

结束!!!!

 

 

 

参考文档:http://blog.youkuaiyun.com/qq419036154/article/details/6256011

              http://www.360doc.com/content/13/0804/20/13396188_304740347.shtml

                   http://www.360doc.com/content/13/0804/20/13396188_304740347.shtml

 

<think>我们正在将MPlayer移植到嵌入式开发板(如全志V3S)。根据引用[1]和引用[2],移植MPlayer的关键步骤包括交叉编译和优化。以下是详细步骤: ### 1. **准备工作** - **获取源码**:下载MPlayer源码(如MPlayer-1.5.tar.xz)[^1]: ```bash wget https://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.5.tar.xz tar xvf MPlayer-1.5.tar.xz cd MPlayer-1.5 ``` - **安装交叉编译工具链**:确保已安装ARM交叉编译器(如`arm-linux-gnueabihf-gcc`): ```bash sudo apt-get install gcc-arm-linux-gnueabihf ``` ### 2. **配置交叉编译环境** - 创建目标目录(用于存放编译结果): ```bash mkdir -p /path/to/target ``` - 配置MPlayer(指定交叉编译器、目标平台和安装路径)[^1]: ```bash ./configure \ --cc=arm-linux-gnueabihf-gcc \ --host-cc=gcc \ --target=arm-linux-gnueabihf \ --prefix=/path/to/target \ --disable-ossaudio \ --disable-sdl \ --disable-gui \ --disable-mencoder \ --disable-vf scale ``` **关键参数说明**: - `--cc`:指定交叉编译器。 - `--host-cc`:指定主机编译器(用于编译在主机上运行的工具)。 - `--target`:目标平台。 - `--prefix`:安装路径。 - `--disable-*`:禁用非必要功能以减少体积(如GUI、mencoder等)。 ### 3. **解决strip问题(引用[2])** - 默认情况下,`make install`会使用`-s`参数调用`strip`,但嵌入式环境需使用交叉编译的strip工具(`arm-linux-strip`)。 - **解决方法**:修改Makefile,将`INSTALLSTRIP`设置为空: ```bash sed -i 's/$(INSTALL) -s/$(INSTALL)/g' Makefile ``` 或手动移除Makefile中的`-s`参数(搜索`$(INSTALL) -s`并删除`-s`)[^2]。 ### 4. **编译与安装** ```bash make -j4 make install ``` - 编译后的可执行文件位于`/path/to/target/bin/mplayer`。 ### 5. **部署到开发板** - 将`mplayer`可执行文件复制到开发板的`/usr/bin`目录。 - 测试播放: ```bash mplayer -vo fbdev2 -zoom -x 480 -y 272 test.mp4 ``` **参数说明**: - `-vo fbdev2`:使用帧缓冲(Framebuffer)作为视频输出(适用于无X11的嵌入式环境)。 - `-zoom -x 480 -y 272`:适配屏幕分辨率(如V3S常见480x272)。 ### 6. **优化与问题解决** - **编解码器支持**:若需额外编解码器
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值