`
bzhang
  • 浏览: 250628 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

how to install ffmpeg

阅读更多
A little while back, I posted a basic install of ffmpeg for CentOS 5. After working with that build over the last month, I found I needed to expand it to include many different video codecs. Because of licensing restrictions, binaries of the build cannot be distributed. However, instructions for a similar build can! I spent several days (or more) researching the packages I would need and I must have combed dozens of blogs to find this information. The build I made strips sound from videos [See update at the end of this post for more information on this subject], this decreases the final file size. If you need sound, you will not want to follow these steps exactly. I also stripped ffserver and ffplay from my build.

These packages were executed in the following order. I cannot say for certain this exact order must be followed, it was the order in which ffmpeg threw the errors. This tutorial assumes you have wget, bzip2, tar and subversion installed on your system. If you do not, please find and install the lastest versions of these utilities for CentOS 5. Additionally, I have allowed all packages to install into their default directories, typically this is /usr/local/[bin | lib]. If at any point during the process of a ‘make’ you run into errors, be sure and run ‘make clean’ before running ‘make’ again. You will either need root access of su access to install ffmpeg. The marker ‘codec:$’ is my prompt, it is merely to indicate separate commands.

    * Package a52
    * Package FAAD2
    * Package FAAC
    * Package LAME
    * Package yasm
    * Package X264
    * Package Xvid
    * Package libraw1394
    * Package libdc1394

Getting Started


codec:$
codec:$ mkdir -p ./tmp/ffmpeg-packages
codec:$ cd ./tmp/ffmpeg-packages

Installing a52


codec:$ wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz
codec:$ tar -zxf a52dec-0.7.4.tar.gz
codec:$ cd a52dec-0.7.4
codec:$ ./configure --enable-shared=PKGS
codec:$ make && make install
codec:$ cd ..

Installing FAAD2


codec:$ wget http://downloads.sourceforge.net/faac/faad2-2.6.1.tar.gz
codec:$ tar zxf faad2-2.6.1.tar.gz
codec:$ cd faad2
codec:$ autoreconf -vif
codec:$ ./configure --disable-drm --disable-mpeg4ip
codec:$ make && make install
codec:$ cd ..

Installing FAAC


codec:$ wget http://downloads.sourceforge.net/faac/faac-1.26.tar.gz
codec:$ tar zxfv faac-1.26.tar.gz
codec:$ cd faac
codec:$ ./bootstrap
codec:$ ./configure --disable-mp4v2
codec:$ make && make install
codec:$ cd ..

Installing LAME


codec:$ wget \
http://superb-east.dl.sourceforge.net/sourceforge/lame/\
lame-3.98b8.tar.gz
codec:$ tar zxfv lame-3.98b8.tar.gz
codec:$ cd lame-3.98b8
codec:$ ./configure
codec:$ make && make install
codec:$ cd ..

Installing yasm

YASM is a modular assembler, it is required by the x264 package.


codec:$ wget \
http://www.tortall.net/projects/yasm/releases/yasm-0.7.0.tar.gz
codec:$ tar zfvx yasm-0.7.0.tar.gz
codec:$ cd yasm-0.7.0
codec:$ ./configure
codec:$ make && make install
codec:$ cd ..

Installing x264
The x264 package is under git revision control, which is much like CVS or SVN. Thankfully, they provide daily tarballs. I grabbed this one:


codec:$ wget \
ftp://ftp.videolan.org:21//pub/videolan/x264/snapshots/\
x264-snapshot-20080513-2245.tar.bz2

I just did a little exploring via an FTP program to find the snapshot I was after. If you are feeling adventurous, download git and try checking out the latest version from their repository.


codec:$ bzip2 -d x264-snapshot-20080513-2245.tar.bz2
codec:$ tar xfv x264-snapshot-20080513-2245.tar
codec:$ cd x264-snapshot-20080513-2245
codec:$ ./configure --enable-mp4-output --enable-shared --enable-pthread
codec:$ make && make install
codec:$ cd ..

Installing Xvid


codec:$ wget http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz
codec:$ tar zxfv xvidcore-1.1.3.tar.gz
codec:$ cd xvidcore-1.1.3/build/generic
codec:$ ./configure
codec:$ make && make install
codec:$ cd ../../..

Installing libraw1394


codec:$ wget http://www.linux1394.org/dl/libraw1394-1.3.0.tar.gz
codec:$ tar zxfv libraw1394-1.3.0.tar.gz
codec:$ cd libraw1394-1.3.0
codec:$ ./configure
codec:$ make dev
codec:$ make && make install
codec:$ cd ..

Installing libdc1394

This project requires libraw1394, you must build it first. This project is a little confusing there is both a libdc1394 and a libdc1394-2. I have only installed the former. Visit Sourceforge here. I grabbed the tarball here:


codec:$ wget \
http://superb-west.dl.sourceforge.net/sourceforge/libdc1394/\
libdc1394-1.2.2.tar.gz
codec:$ tar zxfv libdc1394-1.2.2.tar.gz
codec:$ cd libdc1394-1.2.2
codec:$ ./configure
codec:$ make && make install
codec:$ cd ..

Installing ffmpeg

For FFMPEG, you will need to get the latest out of SVN. FFMPEG doesn’t ever make releases. To do so, run:


codec:$ svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
codec:$ cd ffmpeg


codec:$ ./configure --enable-gpl --enable-postproc --enable-nonfree --enable-postproc --enable-libfaad --enable-swscale --enable-avfilter --enable-pthreads --enable-libxvid --enable-libx264 --enable-libmp3lame --enable-libdc1394 --enable-liba52 --enable-libfaac --disable-ffserver --disable-ffplay
codec:$ make
codec:$ make install

It usually takes at least 5 mins for ‘make’ to run, be sure you have a good file before attempting to install. You will need to be sure and run the ldconfig setting if you have to re-compile, otherwise ffmpeg will throw an error that it cannot find library files. Here is a good resource for using ffmpeg.

Post-Installation Actions

After the install in complete, you may need to add the /usr/local/lib directory to your ld.so.config file. Do the following:


codec:$ cd /etc/
codec:$ cd ld.so.conf.d
codec:$ vi ffmpeg.conf

You need to add ‘/usr/local/lib’ [sans-quotes] to this file and save it. Press Esc, :, x to do so in vi. Afterwords you need to run the following from the commandline


codec:$ ldconfig

That’s it, you now have a fairly robust build of ffmpeg that can take almost anything you can throw at it. Sadly, licensing restrictions prevent binaries from being made of the above steps. Happy (video) encoding!

Update: This build doesn’t actually strip sound from videos, I am doing that with a flag when I run ffmpeg, however, it should be noted that all the audio codecs you may find in many common video formats may not be supported in this build of ffmpeg, which is why I am choosing to strip audio entirely from videos.


-------------------------------------------------------------------------------

下边是另一篇

1. 所需的 RPM 包
引用:

    gcc, gcc-c++, gcc-g77, glibc, glibc-devel, autoconf, automake, libtool, libtool-libs, freetype freetype-devel, libvorbis, libvorbis-devel, libogg, libogg-devel

上述 RPM 包可以通过 yum (仅限 CentOS Linux)自动安装,如果是 Red Hat Linux,请从安装光盘中提取这些 RPM 包手动安装。

2. 以 root 身份登录服务器

3. 创建软件包存放处理目录
复制内容到剪贴板
代码:
# mkdir /usr/local/src/video
二、安装播客视频/音频环境
1. 下载并解压 FFmpeg 集合包
复制内容到剪贴板
代码:
# cd /usr/local/src/video
# wget http://download.discuz.net/env/video/FFmpeg.tar.bz2
# tar xjvf FFmpeg.tar.bz2
2. 安装 MP3 编码器
复制内容到剪贴板
代码:
# cd /usr/local/src/video/FFmpeg/lame-3.97
# ./configure   --prefix=/usr --enable-shared
# make
# make install
3. 安装 XVid 编码器
复制内容到剪贴板
代码:
# cd /usr/local/src/video
# wget http://download.discuz.net/env/video/xvidcore-1.1.0.tar.gz
# tar xzvf xvidcore-1.1.0.tar.gz
# cd xvidcore-1.1.0/build/generic
# ./configure --prefix=/usr
# make
# make install
4. 安装 yasm 汇编器
复制内容到剪贴板
代码:
# cd /usr/local/src/video
# wget http://download.discuz.net/env/video/yasm-0.6.0.tar.gz
# tar xzvf yasm-0.6.0.tar.gz
# cd yasm-0.6.0
# ./configure --prefix=/usr/local/yasm
# make
# make install
将 yasm 加入系统环境变量
复制内容到剪贴板
代码:
# export PATH="$PATH:/usr/local/yasm/bin"
5. 安装 x264 编码器
*注:截至本文档发布日期止,x264 官方最新版存在问题,无法在 2 路以上 CPU 的 Intel 系统架构(如:双至强 CPU,四至强 CPU 服务器)中正常编译安装。Comsenz 为此特别对软件进行了修正,请下载 Comsenz 修正版的 x264 软件包!
复制内容到剪贴板
代码:
# cd /usr/local/src/video
# wget http://download.discuz.net/env/video/x264-linux-Comsenz.tar.bz2
# tar xjvf x264-linux-Comsenz.tar.bz2
# cd x264-linux-Comsenz
# ./configure --prefix=/usr --enable-shared
# make
# make install
6. 安装 LibDTS 编码器
复制内容到剪贴板
代码:
# cd /usr/local/src/video/FFmpeg/libdts
# ./configure --prefix=/usr
# make
# make install
7. 安装 MPEG-4 AAC 编码器
*注:截至本文档发布日期止,MPEG-4 AAC 编码支持所需的 faad 和 faac 最新软件代码存在问题,无法正常编译安装成功。Comsenz 为此特别对软件进行了修正,请下载 Comsenz 修正版的 faad 和 faac!
复制内容到剪贴板
代码:
# cd /usr/local/src/video
# wget http://download.discuz.net/env/video/faac-1.25-Comsenz.tar.bz2
# wget http://download.discuz.net/env/video/faad2-2.5-Comsenz.tar.bz2
(1) 安装 faad
复制内容到剪贴板
代码:
# tar xjvf faad2-2.5-Comsenz.tar.bz2
# cd faad2-Comsenz
# autoreconf -vif
# ./configure --prefix=/usr --with-mp4v2 --enable-shared
# make
# make install
(2) 安装 faac
复制内容到剪贴板
代码:
# cd /usr/local/video/
# tar xjvf faac-1.25-Comsenz.tar.bz2
# cd faac-Comsenz
# autoreconf -vif
# ./configure --prefix=/usr --with-mp4v2 --enable-shared
# make
# make install
8. 安装 FFmpeg 编码器
复制内容到剪贴板
代码:
# cd /usr/local/src/video/FFmpeg/FFmpeg
# ./configure \
   '--prefix=/usr' \
   '--enable-gpl' \
   '--enable-shared' \
   '--enable-mp3lame' \
   '--enable-amr_nb' \
   '--enable-amr_wb' \
   '--enable-amr_if2' \
   '--enable-libogg' \
   '--enable-vorbis' \
   '--enable-xvid' \
   '--enable-a52' \
   '--enable-a52bin' \
   '--enable-faadbin' \
   '--enable-dts' \
   '--enable-pp' \
   '--enable-faad' \
   '--enable-faac' \
   '--enable-x264' \
   '--enable-pthreads' \
   '--disable-ffserver' \
   '--disable-ffplay'
# make
# make install
至此,博客视频/音频转码支持安装完毕!


三、设定视频转换计划任务
1. 下载视频文件转换脚本程序
复制内容到剪贴板
代码:
# cd /usr/local/src/video
# wget http://download.discuz.net/env/video/convert-linux.zip
2. 准备脚本程序
复制内容到剪贴板
代码:

# unzip convert-linux.zip
# cp convert /usr/local/sbin/convert_av.sh
# chmod 777 /usr/local/sbin/convert_av.sh

mencoder安装篇

1、下载主程序: MPlayer-1.0rc1.tar.bz2

2、下载essential-20061022.tar.bz2,安装:
tar vjxf essential-20061022.tar.bz2
mv essential-20061022 /usr/lib/codes
chmod 644 /usr/lib/codes/*
chown root.root /usr/lib/codes/*

3、下载windows-essential-20061022.zip,安装:
unzip windows-essential-20061022.zip
mv windows-essential-20061022 /usr/lib/wincodes
chmod 644 /usr/lib/wincodes/*
chown root.root /usr/lib/wincodes/*

4、安装mplayer

tar vjxf MPlayer-1.0rc1.tar.bz2
cd MPlayer-1.0rc1
./configure --prefix=/usr/local/mplayer/ --enable-freetype --with-codecsdir=/usr/lib/codes/ --with-win32libdir=/usr/lib/wincodes/ --disable-gcc-check --language=zh_CN

make

make install

如果你需要使用mplayer在linux下播放视频,还需要加上--enable-gui(图形界面),不过这样就要安装多很多东西了,这里我们只使用它的mencoder,所以--enable-gui可以省略
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics