摘要
本文描述了FFmpeg软件包中的ffprobe程序的用法。
ffprobe简介
ffprobe是FFmpeg软件包中的一个命令行程序,是一个简单的多媒体流分析器,它可以分析媒体文件的元数据和技术细节,例如编解码器信息、格式、分辨率、帧率、音频采样率等。ffprobe还支持多种输出格式和选项,包括JSON,XML,CSV等,方便数据处理和分析。
ffprobe命令用法
ffprobe [options] input_file
options是选项列表。
“-”开头的字符串是ffprobe内定的参数名,形如${value}的字符串是需要由用户指定的参数值。
ffprobe自描述信息
-L 显示许可协议
-h ${topic} 显示帮助
-? ${topic} 显示帮助
-help ${topic} 显示帮助
--help ${topic} 显示帮助
-version 显示版本
-buildconf 显示构建配置
-formats 显示可用的格式
-muxers 显示可用的复用器
-demuxers 显示可用的解复用器
-devices 显示可用的音视频输入输出设备
-codecs 显示可用的编解码器
-decoders 显示可用的解码器
-encoders 显示可用的编码器
-bsfs 显示可用的比特流滤镜
-protocols 显示可用的协议
-filters 显示可用的滤镜
-pix_fmts 显示可用的像素格式
-layouts 显示标准的音频输出声道布局
-sample_fmts 显示可用的音频采样格式
-dispositions 显示可用于控制媒体文件行为的标志
-colors 显示可用的颜色编码标准名称
ffprobe日志和报告
-loglevel loglevel 设置日志级别
-v loglevel 设置日志级别
-report 生成一个名为ffprobe-${date}-${time}.log的报告文件。
ffprobe主选项
-show_frames 显示帧信息
-show_frames是一个常用的命令参数,它用于显示输入媒体文件的每个视频或音频帧的详细信息,包括帧的类型、时间戳、持续时间、宽度、高度、编码器标识和许多其他数据。下面是一个使用ffprobe -show_frames命令的示例:
ffprobe -i input.mp4 -show_frames
检查MP4文件中是否包含B帧
ffprobe -i input.mp4 -show_frames | grep "pict_type=B"
-show_data show packets data
-show_data_hash show packets data hash
-show_error show probing error
-show_format show format/container info
-show_entries entry_list show a set of specified entries
-show_log show log
-show_packets show packets info
-show_programs show programs info
-show_streams 显示流信息
-show_chapters show chapters info
-count_frames count the number of frames per stream
-count_packets count the number of packets per stream
-show_program_version show ffprobe version
-show_library_versions show library versions
-show_versions show program and library versions
-show_pixel_formats show pixel format descriptions
-show_optional_fields show optional fields
-show_private_data show private data
-private same as show_private_data
ffprobe高级选项
-read_intervals ${read_intervals} 指定需要读取的时间区间
-read_intervals参数可以用来指定需要读取的时间区间。
该参数接受一个时间区间的列表,每个时间区间由两个时间戳组成,用逗号隔开。例如,-read_intervals 0:10,20:30 表示需要读取文件的第0秒到第10秒和第20秒到第30秒的内容。
使用-read_intervals参数可以有效减少ffprobe读取媒体文件时的时间和资源消耗,避免不必要的分析。它对于大型媒体文件尤其有用,可以提高处理速度和效率。
-select_streams ${stream_specifier} 选择指定的流
该参数可以接受多个参数选项,例如:
- 选项v:选择视频流
- 选项a:选择音频流
- 选项s:选择字幕流
例如,使用以下命令可以选择一个MP4文件中所有的视频和音频流:
ffprobe -i input.mp4 -select_streams v:a
选择第一个视频流和第二个音频流
ffprobe -i input.mp4 -select_streams v:0,a:1
-max_alloc ${bytes} 设置单个内存分配块的最大尺寸
-cpuflags ${flags} 强制特定的CPU标志(用逗号分隔的特性,如:mmx,sse,avx)
-cpucount ${count} 强制指定使用的CPU逻辑核心个数
-hide_banner 不显示程序广告
-sources device list sources of the input device
-sinks device list sinks of the output device
-f format 强制指定文件格式,不根据文件扩展名猜测。
-unit show unit of the displayed values
-prefix use SI prefixes for the displayed values
-byte_binary_prefix use binary prefixes for byte units
-sexagesimal use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units
-pretty prettify the format of displayed values, make it more human readable
-print_format format set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)
-of format alias for -print_format
-sections 打印节区结构和节区信息,然后退出
-bitexact force bitexact output
-i ${input_file} 读取指定文件
-o ${output_file} 写入到指定文件
-print_filename ${print_file} 重载打印的输入文件名
-find_stream_info 读取并解码流以用启发式方法填充缺失的信息