Linux下自动安装mplayer v2011.11.16

2011年11月16日 由 kethinc 留言 »

Linux下自动安装mplayer,虽然有些不完美(只能检测是否曾用本脚本安装yasm)。支持红帽系列x86/x86_64 系统(需要yum安装一些包),因为对大便系列没有研究所有暂不支持,估计以后也可能不会支持。测试环境scientific linux 6 x86_64。我在测试的时候有时安装完没有声音或播放时很卡,请通过“首选项”修改一下配置。

更新内容:
1. 能检测是否曾用本脚本安装yasm
2. 去除了codecs
3. 在yum安装上添加了一些依赖包
4. 提高了编译效率
5. 使用最新版mplayer快照
6. 分离了源码安装的信赖包,并使用tar.lzma压缩。体积更小在线下载速度快。

使用方法:

wget -c http://mplayer-install.googlecode.com/files/mplayer-install-v2011-11-16.tar.lzma
tar xvf mplayer-install-v2011-11-16.tar.lzma
# 用root执行
./mplayer-linux-install.sh

粘贴一下 mplayer-linux-install.sh 的代码

#!/bin/bash
# description: This shell script takes care of install mplayer
# created by kethinc: http://blog.kethinc.com

# codecs:   http://www.mplayerhq.hu/MPlayer/releases/codecs/
# skins:    http://www.mplayerhq.hu/MPlayer/skins/
# fonts:    http://www.mplayerhq.hu/MPlayer/contrib/fonts/chinesefonts/gb2312-ming.tar.lzma
# version:   v2011-11-16

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

cur_dir=$(pwd)

#if [ "$1" = "--help" ]; then
#
#fi

# 检查是否为root用户
if [ $(id -u) != "0" ]; then
    echo "执行此脚本必须为root用户"
    echo "You must be root to run this script"
    exit 1
fi

# 安装编译工具及一些可能用到的包
yum -y install gcc gcc-c++ autoconf make git libjpeg libjpeg-devel libpng libpng-devel libXpm libXpm-devel freetype freetype-devel pulseaudio* alsa-plugins-oss alsa-lib-devel xz-lzma-compat

# 探测cpu核心数
j="-j$(grep 'model name' /proc/cpuinfo | wc -l)"

# check and download mplayer-export-snapshot
if [ ! -s mplayer-export-snapshot.tar.bz2 ]; then
    echo "mplayer-export-snapshot.tar.bz2 not found..."
    echo "download mplayer-export-snapshot now!"
    wget -c http://www.mplayerhq.hu/MPlayer/releases/mplayer-export-snapshot.tar.bz2
fi

# check and download ffmpeg
if [ ! -s ffmpeg.tar.lzma ]; then
    echo "ffmpeg.tar.lzma not found..."
    echo "download ffmpeg now!"
    wget -c http://mplayer-install.googlecode.com/files/ffmpeg.tar.lzma
fi

# check and download yasm
if [ ! -s yasm-1.1.0.tar.lzma ]; then
    echo "yasm not found..."
    echo "download yasm now!"
    wget -c http://mplayer-install.googlecode.com/files/yasm-1.1.0.tar.lzma
fi

# check and download default skins
if [ ! -s skins-default.tar.lzma ]; then
    echo "default skin not found..."
    echo "download default skin now!"
    wget -c http://mplayer-install.googlecode.com/files/skins-default.tar.lzma
fi

# check and download yasm-1.1.0
if [ ! -s subfont.tar.lzma ]; then
    echo "subfont not found..."
    echo "download subfont now!"
    wget -c http://mplayer-install.googlecode.com/files/subfont.tar.lzma
fi

# 安装yasm
if [ "$(ls /usr/local/bin/ | grep yasm)" = "" ]; then
    tar xvf yasm-1.1.0.tar.lzma
    cd yasm-1.1.0
    ./configure
    make $j
    make install
fi

cd $cur_dir

# 安装解码库
#tar xvf codecs-20110131.tar.lzma -C /usr/lib
#
#if [ $(uname -i) = 'x86_64' ] ; then
#    tar xvf codecs-20071007-amd64.tar.lzma -C /usr/lib
#fi

# 解压源码包
tar jxvf mplayer-export-snapshot.tar.bz2
tar xvf ffmpeg.tar.lzma -C mplayer-export-20*
    # 解压ffmpeg到源码文件目录
cd mplayer-export-20*
./configure --enable-gui --enable-x11 --enable-freetype --enable-menu --language=zh_CN
    # --disable-mencoder 关闭mencoder。mplayer自带的多媒体格式转换工具
   # --enable-gui 安装图形化用户界面
   # --enable-freetype 调节字体
   # --codecsdir=/usr/lib/codecs/ 解码器目录
   # --enable-debug 编译时加入调试信息
make $j
make install

# install default skin
cd ${cur_dir}
tar xvf skins-default.tar.lzma -C /usr/local/share/mplayer/skins/
# install subfont
tar xvf subfont.tar.lzma -C /usr/local/share/mplayer/
chmod 666 /usr/local/share/mplayer/subfont.ttf

#cd /usr/lib/codecs/ chcon -t textrel_shlib_t /usr/lib/codecs/drvc.so
   # 在Redhat Enterprise server 5中SELinux显示出错误的解决方案

/usr/local/bin/gmplayer
广告位

发表评论