在网上搜了很久才发现这篇才是(ffmpeg视频加水印)有用的文章
原帖地址:
http://hi.baidu.com/73jianbing/blog/item/82b96decdb289dc62e2e21fa.html
安装依赖包
参考
http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat
到
http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm 下载 rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm安装(rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm)
yum install SDL-devel a52dec a52dec-devel alsa-lib-devel faac faac-devel faad2 faad2-devel
yum install freetype-devel giflib gsm gsm-devel imlib2 imlib2-devel lame lame-devel libICE-devel libSM-devel libX11-devel
yum install libXau-devel libXdmcp-devel libXext-devel libXrandr-devel libXrender-devel libXt-devel
yum install libid3tag libogg-devel libvorbis-devel mesa-libGL-devel mesa-libGLU-devel xorg-x11-proto-devel xvidcore xvidcore-devel zlib-devel
yum install amrnb-devel amrwb-devel
yum install libtheora libtheora-devel
yum install glibc gcc gcc-c++ autoconf automake libtool
yum install subversion
yum install ncurses-devel
yum install libdc1394 libdc1394-devel
yum install yasm nasm
获得libavfilter
如果要支持水印,首先要获得libavfilter
路径:svn checkout svn://svn.mplayerhq.hu/soc/libavfilter
源代码牵下来以后执行checkout.sh脚本。脚本很简单,就是从svn上把ffmpeg最新的代码下载下来,然后打补丁。从svn上下载下来的ffmpeg是libavfilter的下级目录。
下载X264
要支持高清MP4,需要现在X264
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
在上面的FTP上现在最新的last_x264.tar.bz2、last_stable_x264.tar.bz2
然后分别解压缩编译安装。
tar -xjvf last_stable_x264.tar.bz2
tar xvf x264-snapshot-20110517-2245-stable.tar (x264-snapshot-20110517-2245-stable.tar是last_stable_x264.tar.bz2解压出来的,版本不同名称可能不同。)
cd x264-snapshot-20110517-2245-stable (进入目录)
编译安装
./configure --enable-shared
make
make install
安装完成
安装last_x264.tar.bz2采用相同的办法即可。
准备工作做完了编译安装ffmpeg
进入从svn上下载下来的ffmpeg文件夹下编译安装。
./configure --enable-version3 --enable-libmp3lame --enable-libvorbis --disable-ffplay --enable-shared --enable-gpl --enable-pthreads --enable-postproc --enable-x11grab --enable-libx264 --enable-swscale --enable-nonfree --disable-mmx --enable-avfilter
执行上述代码的时候提示
ERROR: libmp3lame >= 3.98.3 not found
所以需要安装最新的lame-3.98.4.tar.gz
tar zvxf lame-3.98.4.tar.gz
cd lame-3.98.4
./configure --enable-shared
make
make install
然后在进入ffmpeg文件夹执行
./configure --enable-version3 --enable-libvorbis --enable-libx264 --enable-libxvid --disable-ffplay --enable-shared --enable-libmp3lame --enable-gpl --enable-pthreads --enable-postproc --enable-x11grab --enable-libgsm --enable-swscale --enable-nonfree --disable-mmx --enable-avfilter
make
make install
安装完成。
编辑 ld.so.conf
vi /etc/ld.so.conf
添加一行
/usr/local/lib
激活
ldconfig
输入 ffmpeg出现以下类似信息,则安装完成
FFmpeg version SVN-r26400, Copyright (c) 2000-2011 the FFmpeg developers
built on May 18 2011 19:14:05 with gcc 4.1.2 20080704 (Red Hat 4.1.2-44)
configuration: --enable-version3 --enable-libmp3lame --enable-libvorbis --disable-ffplay --enable-shared --enable-gpl --enable-pthreads --enable-postproc --enable-x11grab --enable-libx264 --enable-swscale --enable-nonfree --disable-mmx --enable-avfilter
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0
libpostproc 51. 2. 0 / 51. 2. 0
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
========================分割线==========================
安装完成之后执行一下加水印以及转MP4的功能
ffmpeg -y -i 23.avi -vf "movie=0:gif:actlet_icon.gif [wm];[in][wm] overlay=0:0:1 [out]" -f mp4 -acodec libmp3lame -vcodec libx264 -vpre slow -ac 1 aaaa.mp4
成功则表示OK