FFmpeg介绍、使用说明
FFmpeg使用简介
FFmpeg是一组用于处理多媒体内容(如音频、视频、字幕及相关元数据)的库和工具。
包container format括如下库:
- libavcodec 提供更广泛的编解码器实现
- libavformat 实现流媒体协议、格式化容器和基本的I/O访问
- libavutil 包括hashers,decompressors和各种使用函数
- libavfilter 提供通过连接滤波器的有向图来改变编解码音频和视频的方法
- libavdevice 提供一个访问捕获和回放设备的抽象
- libswresample 实现音频混音和重采样例程
- libswscale 实现色彩转换和缩放例程
包括如下工具:
- ffmpeg 一个命令行工具箱,用来操作转换和流媒体内容
- ffplay 一个极简的多媒体播放器
- ffprobe 一个简单的分析工具,用来检查多媒体内容
其他小工具如aviocat,ismindex和qt-faststart
构成ffmpeg的功能组件有:
- decoder 解码器
- encoder 编码器
- demuxer 解混合器
- muxer 混合器
- filter 过滤器
- bsf 比特流过滤器
- protocol 媒体协议
FFmpeg版本信息与构建配置
注:Windows FFmpeg命令工具
ffmpeg version 6.0-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developersbuilt with gcc 12.2.0 (Rev10, Built by MSYS2 project)configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
FFmpeg使用说明
ffmpeg命令使用基本格式:
ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Getting help
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 显示标准的通道布局
-sample_fmts show available audio sample formats 显示可用的音频采样格式
-dispositions show available stream dispositions 显示可用的流部署
-colors show available color names 显示颜色名字(颜色值和颜色名对照表)
-sources device list sources of the input device 列出输入设备的sources
-sinks device list sinks of the output device 列出输出设备的sinks
-hwaccels show available HW acceleration methods 显示可用的硬件加速方法
Global options(affect whole program instead of just one file)
-loglevel loglevel set logging level 设置日志级别
-v loglevel -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 tytes 忽略位置的流类型
-filter_threads number of non-complex filter threads 非复杂过滤器线程数
-filter_complex_threads number of threads for -filter_complex -filter_complex线程数
-stats print progress report during encoding 编码期间打印进度
-max_error_rate maximum error rate ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success. 解码错误的最大错误率(0.0:无错误,1.0:100%错误)超过该比率ffmpeg将返回错误而不是成功
Per-file main options
-f fmt force format 强制格式
-c codec codec name 编解码名
-codec codec codec name
-pre preset preset name 预设值名
-map_metadata outfile[,metadata]:infile[,metadata] set metadata information of outfile from infile
-t duration record or transcode "duration" seconds of audio/video
-to time_stop record or transcode stop time
-fs limit_size set the limit file size in bytes
-ss time_off set the start time offset
-sseof time_off set the start time offset relative to EOF
-seek_timestamp enable/disable seeking by timestamp with -ss
-timestamp time set the recording timestamp ('now' to set the current time)
-metadata string=string add metadata
-program title=string:st=number... add program with specified streams
-target type specify target file type ("vcd", "svcd", "dvd", "dv" or "dv50" with optional prefixes "pal-", "ntsc-" or "film-")
-apad audio pad
-frames number set the number of frames to output
-filter filter_graph set stream filtergraph
-filter_script filename read stream filtergraph description from a file
-reinit_filter reinit filtergraph on input parameter changes
-discard discard
-disposition disposition
Video options
-vframes number set the number of video frames to output 设置输出的视频帧数
-r rate set frame rate (Hz value, fraction or abbreviation)设置帧率
-fpsmax rate set max frame rate (Hz value, fraction or abbreviation)设置最大帧率
-s size set frame size (WxH or abbreviation) 设置帧尺寸
-aspect aspect set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)设置纵横比
-display_rotation angle set pure counter-clockwise rotation in degrees for stream(s)为流设置设置纯逆时针旋转度
-display_hflip set display horizontal flip for stream(s) (overrides any displayrotation if it is not set) 为流设置显示水平翻转
-display_vflip set display vertical flip for stream(s) (overrides any display rotation if it is not set) 为流设置显示垂直翻转
-vn disable video 禁用视频
-vcodec codec force video codec ('copy' to copy stream) 强制视频编解码器
-timecode hh:mm:ss[:;.]ff set initial TimeCode value. 设置初始时间码值
-pass n select the pass number (1 to 3) 选择通过哪个编码通道
-vf filter_graph set video filters 设置视频过滤
-b bitrate video bitrate (please use -b:v) 视频比特率
-dn disable data 禁用数据
Audio options
-aframes number set the number of audio frames to output 设置输出的音频帧数
-aq quality set audio quality (codec-specific) 设置音频质量(编解码-细节)
-ar rate set audio sampling rate (in Hz) 设置音频采样率(单位Hz)
-ac channels set number of audio channels 设置音频通道数
-an disable audio 禁用音频
-acodec codec force audio codec ('copy' to copy stream) 强制音频编解码器()
-ab bitrate audio bitrate (please use -b:a) 音频比特率(请用 -b:a)
-af filter_graph set audio filters 设置音频过滤器
Subtitle options
-s size set frame size (WxH or abbreviation) 设置帧大小(WxH)
-sn disable subtitle 禁用字幕
-scodec codec force subtitle codec ('copy' to copy stream) 强制字幕编解码
-stag fourcc/tag force subtitle tag/fourcc 强制字幕tag/fourcc
-fix_sub_duration fix subtitles duration 修正字幕饱和度
-canvas_size size set canvas size (WxH or abbreviation) 设置画布尺寸(WxH)
-spre preset set the subtitle options to the indicated preset将字幕选项设置为指定的预设