第一次接触ffmpeg这个软件,其实在我们的生活中他无处不在,由她制作的视频编辑播放软件有:QQ 影音 射手播放器 等等。可以解析绝大部分的视频格式,转化成你想要的格式。
和ffmpeg一起的有三个软件,除了她自己,还有 ffplay-播放器,ffprobe-输出视频文件格式大小码流等等一系列参数。
她的官方网址:http://www.ffmpeg.org/
文档页: http://www.ffmpeg.org/documentation.html
下载链接:http://ffmpeg.org/releases/ffmpeg-3.0.1.tar.bz2
下面介绍linux下的安装:
机器环境:
[root@Master /]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
[root@Master /]# uname -a
Linux Master.Hadoop 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
过程:
yum install yasm -y
cd /usr/local/src
wget http://ffmpeg.org/releases/ffmpeg-3.0.1.tar.bz2
tar -xvf ffmpeg-3.0.1.tar.bz2
cd ffmpeg-3.0.1
./configure --enable-shared --prefix=/usr/local/ffmpeg
make
make install
echo '/usr/local/ffmpeg/lib' >> /etc/ld.so.conf
ldconfig
/usr/local/ffmpeg/bin/ffmpeg -h
解释:
yum install yasm -y 加载汇编模块,加快编译;
echo '/usr/local/ffmpeg/lib' >> /etc/ld.so.conf
ldconfig
把ffmpeg的lib库加载到系统,不然会出现
ffmpeg: error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory
类似的错误;
Ldconfig 加载刚才的配置。
/usr/local/ffmpeg/bin/ffmpeg -h
如果有输出的话,那就是成功安装了。
输出:
[root@Master /]# /usr/local/ffmpeg/bin/ffmpeg -h
ffmpeg version 3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
configuration: --enable-shared --prefix=/usr/local/ffmpeg
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
………………………………
看了那么长的帮助信息,糊涂了。简单说下ffmpeg的参数:
首先明确的是:ffmepg 做的就是 把源文件x 转换成你想要的文件xx
来个安利:
ffmpeg -i 1.mov -ss 00:00:00 -t 00:00:10 -s 1920*1080 -bf mpeg4 -r 25 -aspect 16:9 -b 15000 -ab 256 -acodec aac out2.mp4
视频:
将1.mov 从 开始截取到10s的位置(截取后肯定总播放时长就是10s)
转换成1920*1080
mpeg4格式的
16:9的
码率:15M 也就是15000kbit/s
音频:
256kb
aac 格式
最后输出的视频是 out2.mp4
写篇说ffmpeg具体参数。