ffmpeg 安装bzlib_Centos7环境安装ffmpeg

ffmpeg是一个视频转换工具,可以把图片转换成视频,也可以把视频进行分割,或者把视频进行转码都可以。但是一般很少用,不过一般视频相关关的公司都会使用得到,废话就不多少了,先把环境搭建起来吧,然后测试一下效果。说再多都不入做点实在的,我这里选择yum安装。

yum安装ffmpeg

我的系统是最小安装的,直接使用yum安装ffmpeg

安装EPEL Release,因为安装需要使用其他的repo源,所以需要EPEL支持:

[root@wulaoer.org ~]# yum install -y epel-release

如果出现缺少Code提示,可以:

[root@wulaoer.org ~]# sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

安装Nux-Dextop源

导入一个Code

[root@wulaoer.org ~]# sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro

安装nux-dextop 源

[root@wulaoer.org ~]# sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm

Retrieving http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm

Preparing... ################################# [100%]

Updating / installing...

1:nux-dextop-release-0-1.el7.nux ################################# [100%]

yum安装ffmpeg:

[root@wulaoer.org ~]# yum install -y ffmpeg

安装完成后检查ffmpeg 版本:

[root@wulaoer.org ~]# ffmpeg -version

ffmpeg version 2.8.15 Copyright (c) 2000-2018 the FFmpeg developers

built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)

configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect

libavutil 54. 31.100 / 54. 31.100

libavcodec 56. 60.100 / 56. 60.100

libavformat 56. 40.101 / 56. 40.101

libavdevice 56. 4.100 / 56. 4.100

libavfilter 5. 40.101 / 5. 40.101

libavresample 2. 1. 0 / 2. 1. 0

libswscale 3. 1.101 / 3. 1.101

libswresample 1. 2.101 / 1. 2.101

libpostproc 53. 3.100 / 53. 3.100

ffmpeg使用

上面已经知道了安装ffmpeg,下面我们就学习一下如何使用ffmpeg吧,光说不练王八单,下面学习一下使用ffmpeg。

1、视频转换格式----将wulaoer.avi格式的软件转换为wolf.mp4

[root@wulaoer.org ~]# ffmpeg -i wulaoer.avi wolf.mp4

2、视频截图保存为图片

[root@wulaoer.org ~]# ffmpeg -i inputfile.avi -r 1 -q:v 2 -f image2 image-%05d.jpg

参数注释:

-r:指定抽取的帧 即从视频中每秒抽取图片的数量 1代表每秒抽取一帧

-f:保存图片使用的格式 可省略

Image-%05d.jpg:指定文件的输出名字

3、截取与合并视频

截取:

[root@wulaoer.org ~]# ffmpeg -i 0005.mp4 -vcodec copy -acodec copy -ss 00:00:00 -to 00:00:100 d:/cutout1.mp4 -y -ss:指定从什么时候开始

-t:指定需要截取多长时间

-i:指定输入文件

合成:

[root@wulaoer.org ~]# ffmpeg -ss 00:00:00 -t 00:00:20 -i input.mp4 -vcodec copy output.mp4

[root@wulaoer.org ~]# ffmpeg -f concat -i list.txt -c copy concat.mp4

list.txt文件中的书写方式:

file video1.mp4

file video2.mp4

4、给视频添加水印

[root@wulaoer.org ~]# ffmpeg -i wulaoer.mp4 -i mark.png -filter_complex overlay wolf.mp4

给视频添加文字水印:

[root@wulaoer.org ~]# ffmpeg -i wulaoer.mp4 -vf "drawtext=fontfile=simsunb.ttf: text='wulaoer':x=100:y=10:fontsize=24:fontcolor=yellow:shadowy=2" drawtext.mp4

文字水印filter是drawtext simsunb.ttf:text=’wulaoer’

x:y是显示位置

fontsize:文字大小

fontcolor:文字颜色

给视频添加图片水印:

[root@wulaoer.org ~]# ffmpeg -i input.mp4 -vf "movie=mark.png[watermark];[in][watermark] overlay=10:10[out]" output.mp4

总结:

我使用yum安装的ffmpeg出现一个问题,就是原本我的环境是跑一个java项目处理视频和音频合并的,但是因为用户很多,一台服务处理不完,所以我就在服务器上启了多个服务,就会出现跑有几分钟服务就不处理的情况,然后不断的重启不断的服务停止,后来写了一个定时脚本来监控我的服务,也不行,导致消息队列一会总结了几十万,所以没办法,要么优化一下ffmpeg,要不就只跑一个服务,然后增加多个机器。我尝试了一下,在增加多个机器的情况下,单跑服务,不会出现停止的情况。这个应该是ffmpeg不能承担大的负载,所以需要独立使用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值