抖音点赞粉丝推广运营虚拟服务平台 - 亿抖网欧梦公司

抖音粉丝点赞服务
打通抖音运营之路

ffmpeg视频压缩参数(ffmpeg参数提高清晰度)

FFmpeg 是一个用于处理多媒体文件的开源工具集合。FFmpeg 包含一组共享的多媒体库,例如 libavcodec、libavutil 和 libavformat。允许你转换视频和音频文件、执行流和调整视频文件的大小。

如何安装FFmpeg

本文介绍如何在Centos8中安装ffmpeg,FFmpeg 在默认的CentOS 8 源仓库中没有提供,可以从第三方软件源中安装:

[root@localhost ~]# rpm -ivh https://mirrors.ustc.edu.cn/rpmfusion/free/el/rpmfusion-free-release-8.noarch.rpm
[root@localhost ~]# yum config-manager --enable PowerTools
[root@localhost ~]# yum -y install SDL2
[root@localhost ~]# yum -y install ffmpeg

安装完成之后可以查看一下ffmpeg的版本:

[root@localhost ~]# ffmpeg -version
[root@localhost ~]# ffmpeg -version
ffmpeg version 4.2.4 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100

 

FFmpeg基本用法

转换多媒体文件时,选择正确的编解码器、容器和格式可能非常具有挑战性。但是,使用 FFmpeg,可以坚持默认设置并期待出色的结果。要使用默认 FFmpeg 设置转换文件,请使用以下命令:

[root@localhost ~]# ffmpeg -i video.mp4 out_video.mp4

 


可以看到下图中,输出的视频变小了许多:

 


上面的命令会将文件从指定格式转换为输出格式。但是,要有效地压缩文件,我们需要使用编解码器、比特率、容器和 fps。

如何使用 FFmpeg 减少视频大小

没有通用的方法来减小视频文件的大小,因为各种文件类型的创建并不相同。在本教程中,我们将使用 x265 编解码器。x265 编解码器,它是一个免费的库,用于视频编码为 H.254/MPEG-H HEVC 的压缩格式。

CRF使用 0 到 51 之间的数字。恒定速率因子(CRF)是 x264 和 x265 编码的默认质量设置。值越高,压缩率越高,值越高这可能会导致质量损失。

下面我们将一个274M的视频文件进行压缩:

[root@localhost ~]# ffmpeg -i video.mp4 -vcodec libx265 -crf 25 compress_video.mp4

 

总结

虽然使用自定义压缩选项可以产生很好的结果,但在某些情况下使用默认的 FFmpeg 选项可能会更好。

我们的缺点麻烦您能提出,谢谢支持!

联系我们 网站地图