本文给大家分享ffmpeg命令汇总,包括ffmpeg工具、命令使用总结以及ffmpeg音视频处理流程。
ffmpeg命令汇总
1、ffmpeg工具
ffmpeg工具主要分三个,从官网我们可以看到:
- ffmpeg:(Hyper fast Autio and Video encoder)超快音视频编码器(类似于爱剪辑)。
- ffplay:(Simple media player)简单媒体播放器
- ffprobe:(Simple multimedia streams analyzer)简单多媒体流分析器
在上面官网图片里面中,如果大家要详细了解ffmpeg、ffplay、ffprobe三个工具的使用,可以点击进去,里面有非常详细的介绍!这里接下来我给大家总结一下这段时间我学习里面的一些常用命令,再加上一些视频播放演示,这样学习起来就不会太枯燥了.
2、ffmpeg命令使用总结
(1)ffmpeg命令查看帮助文档
- 基本信息:ffmpeg -h
Print help / information / capabilities:
-L show license
-h topic show help
-? topic show help
-help topic show help
--help topic show help
-version show version
-buildconf show build configuration
-formats show available formats
-muxers show available muxers
-demuxers show available demuxers
-devices show available devices
-codecs show available codecs
-decoders show available decoders
-encoders show available encoders
-bsfs show available bit stream filters
-protocols show available protocols
-filters show available filters
-pix_fmts show available pixel formats
-layouts show standard channel layouts
- 高级信息:ffmpeg -h long
Global options (affect whole program instead of just one file:
-loglevel loglevel set logging level
-v loglevel set logging level
-report generate a report
-max_alloc bytes set maximum size of a single allocated block
-y overwrite output files
-n never overwrite output files
-ignore_unknown Ignore unknown stream types
-filter_threads number of non-complex filter threads
-filter_complex_threads number of threads for -filter_complex
-stats print progress report during encoding
-max_error_rate maximum error rate ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-bits_per_raw_sample number set the number of bits per raw sample
-vol volume change audio volume (256=normal)
- 所有信息命令:ffmpeg -h full
magicyuv AVOptions:
-pred <int> E..V..... Prediction method (from 1 to 3) (default left)
left E..V.....
gradient E..V.....
median E..V.....
还有很多信息没有截取出来,这里只是一部分信息
注意:我们可以看到上面的命令查询帮助信息打印出来太多了,不方便阅读,所以我们把它们都放在单独的一个日志文件里面,这样就方便查看阅读:
E:音视频test-av>ffmpeg -h > ffmpeg_h.log
E:音视频test-av>ffmpeg -h long > ffmpeg_h_long.log
E:音视频test-av>ffmpeg -h full > ffmpeg_h_full.log
最终就会在当前目录下生成三个日志文件:
同时我们要注意,在ffplay和ffprobe里面,下面这两条命令就表示查看所有信息,这和ffmpeg有点差异:
ffplay -h
ffprobe -h
(2)ffmpeg命令分类查询:
- version:显示ffmpeg版本型号:
E:音视频test-av>ffmpeg -version
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190807
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
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
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
- buildconf:显示编译配置:
configuration:
--disable-static
--enable-shared
--enable-gpl
--enable-version3
--enable-sdl2
--enable-fontconfig
--enable-gnutls
--enable-iconv
--enable-libass
--enable-libdav1d
--enable-libbluray
--enable-libfreetype
--enable-libmp3lame
--enable-libopencore-amrnb
--enable-libopencore-amrwb
--enable-libopenjpeg
--enable-libopus
--enable-libshine
--enable-libsnappy
--enable-libsoxr
--enable-libtheora
--enable-libtwolame
--enable-libvpx
--enable-libwavpack
--enable-libwebp
--enable-libx264
--enable-libx265
--enable-libxml2
--enable-libzimg
--enable-lzma
--enable-zlib
--enable-gmp
--enable-libvidstab
--enable-libvorbis
--enable-libvo-amrwbenc
--enable-libmysofa
--enable-libspeex
--enable-libxvid
--enable-libaom
--enable-libmfx
--enable-amf
--enable-ffnvcodec
--enable-cuvid
--enable-d3d11va
--enable-nvenc
--enable-nvdec
--enable-dxva2
--enable-avisynth
--enable-libopenmpt
- formats:显示可用格式(muxers+demuxers),muxers表示显示可用复用器;demuxers表示显示可用解复用器:
File formats:
D. = Demuxing supported
.E = Muxing supported
当然我们可以专门查找flv格式的文件格式:
E:音视频test-av>ffmpeg -muxers | findstr flv
E flv FLV (Flash Video)
E:音视频test-av>ffmpeg -demuxers | findstr flv
D flv FLV (Flash Video)
D live_flv live RTMP FLV (Flash Video)
- codecs:显示可用编解码器(-decoders表示显示可用解码器;-encoders表示显示可用编码器),下面是打印查找的一部分信息
D.VI.S 012v Uncompressed 4:2:2 10-bit
D.V.L. 4xm 4X Movie
D.VI.S 8bps QuickTime 8BPS video
.EVIL. a64_multi Multicolor charset for Commodore 64 (encoders: a64multi )
.EVIL. a64_multi5 Multicolor charset for Commodore 64, extended with 5th color (colram) (encoders: a64multi5 )
D.V..S aasc Autodesk RLE
D.V.L. agm Amuse Graphics Movie
D.VIL. aic Apple Intermediate Codec
DEVI.S alias_pix Alias/Wavefront PIX image
DEVIL. amv AMV Video
D.V.L. anm Deluxe Paint Animation
D.V.L. ansi ASCII/ANSI art
- bsfs:显示可用比特流filter,打印信息比较多,截取了一部分,后期的命令打印都只截取一部分:
Bitstream filters:
aac_adtstoasc
av1_frame_split
av1_metadata
chomp
dump_extra
dca_core
eac3_core
extract_extradata
filter_units
h264_metadata
h264_mp4toannexb
h264_redundant_pps
hapqa_extract
hevc_metadata
hevc_mp4toannexb
imxdump
mjpeg2jpeg
mjpegadump
mp3decomp
mpeg2_metadata
mpeg4_unpack_bframes
mov2textsub
noise
null
prores_metadata
remove_extra
text2movsub
trace_headers
truehd_core
vp9_metadata
vp9_raw_reorder
vp9_superframe
vp9_superframe_split
- protocols:显示可用的协议:
Supported file protocols:
Input:
async
bluray
cache
concat
crypto
data
ffrtmpcrypt
ffrtmphttp
file
ftp
gopher
hls
http
httpproxy
https
mmsh
mmst
pipe
rtmp
rtmpe
rtmps
rtmpt
rtmpte
rtmpts
rtp
srtp
subfile
tcp
tls
udp
udplite
Output:
crypto
ffrtmpcrypt
ffrtmphttp
file
ftp
gopher
http
httpproxy
https
icecast
md5
pipe
prompeg
rtmp
rtmpe
rtmps
rtmpt
rtmpte
rtmpts
rtp
srtp
tee
tcp
tls
udp
udplite
- filters:显示可用的过滤器:
E:音视频test-av>ffmpeg -filters
Filters:
T.. = Timeline support
.S. = Slice threading
..C = Command support
A = Audio input/output
V = Video input/output
N = Dynamic number and/or type of input/output
| = Source or sink filter
- pix_fmts:显示可用的像素格式
E:音视频test-av>ffmpeg -pix_fmts
Pixel formats:
I.... = Supported Input format for conversion
.O... = Supported Output format for conversion
..H.. = Hardware accelerated format
...P. = Paletted format
....B = Bitstream format
FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL
-----
- layouts:显示标准声道名称
E:音视频test-av>ffmpeg -layouts
Individual channels:
NAME DESCRIPTION
FL front left
FR front right
FC front center
LFE low frequency
BL back left
BR back right
FLC front left-of-center
FRC front right-of-center
BC back center
SL side left
SR side right
TC top center
TFL top front left
TFC top front center
TFR top front right
TBL top back left
TBC top back center
TBR top back right
DL downmix left
DR downmix right
WL wide left
WR wide right
SDL surround direct left
SDR surround direct right
LFE2 low frequency 2
Standard channel layouts:
NAME DECOMPOSITION
mono FC
stereo FL+FR
2.1 FL+FR+LFE
3.0 FL+FR+FC
3.0(back) FL+FR+BC
4.0 FL+FR+FC+BC
quad FL+FR+BL+BR
quad(side) FL+FR+SL+SR
- sample_fmts:显示可用的音频采样格式:
E:音视频test-av>ffmpeg -sample_fmts
name depth
u8 8
s16 16
s32 32
flt 32
dbl 64
u8p 8
s16p 16
s32p 32
fltp 32
dblp 64
s64 64
s64p 64
- colors:显示可用的颜色名称:
E:音视频test-av>ffmpeg -colors
name #RRGGBB
AliceBlue #f0f8ff
AntiqueWhite #faebd7
Aqua #00ffff
Aquamarine #7fffd4
Azure #f0ffff
Beige #f5f5dc
Bisque #ffe4c4
Black #000000
BlanchedAlmond #ffebcd
Blue #0000ff
BlueViolet #8a2be2
Brown #a52a2a
BurlyWood #deb887
ffmpeg音视频处理流程
我们可以去ffmpeg官网介绍里面看到它的处理流程图:
为了说明这个处理过程,我们以下面一条命令来举例说明:
ffmpeg -i test_1920x1080.mp4 -acodec copy -vcodec libx264 -s 1280x720 test_1280x720.flv
说明:
- (input file)这里输入文件为test_1920x1080.mp4格式的视频文件格式
- demuxer:通过可用解复用器把输入文件,也就是音视频文件,分离出音频包和视频包
- 编码数据包;通过上面的demuxr,就得到了音频包和视频包
- decoder:然后通过解码器解码后,就生成了解码数据帧,这里要通过过滤处理,怎样过滤处理具体可以看官方的说明,这里暂时不说明,如果有时间,研究完官方说明,再来讲
- encoder:过滤处理完后的解码数据帧通过编码器处理后,会生成编码数据包
- muxer:编码数据包再次通过可用复用器处理,就生成了一个新格式的音视频文件,比如这里是test_1280x720.flv
暂时先分享总结这些命令,更多命令学习可以参考官网手册。
版权声明:本文内容转自互联网,本文观点仅代表作者本人。本站仅提供信息存储空间服务,所有权归原作者所有。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至1393616908@qq.com 举报,一经查实,本站将立刻删除。