Summary
This article describes the use of the ffprobe program in the FFmpeg package.
Introduction to ffprobe
ffprobe, a command-line program in the FFmpeg package, is a simple multimedia stream analyzer that can analyze media files for metadata and technical details such as codec information, format, resolution, frame rate, audio sample rate wait. ffprobe also supports a variety of output formats and options, including JSON, XML, CSV, etc., to facilitate data processing and analysis.
ffprobe command usage
ffprobe [options] input_file
options is a list of options.
The string starting with "-" is the default parameter name of ffprobe, and the string in the form of ${value} is the parameter value that needs to be specified by the user.
ffprobe self-describing information
-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 logs and reports
-loglevel loglevel 设置日志级别
-v loglevel 设置日志级别
-report 生成一个名为ffprobe-${date}-${time}.log的报告文件。
ffprobe main options
-show_frames displays frame information
-show_frames is a commonly used command parameter, which is used to display detailed information of each video or audio frame of the input media file, including the type of frame, timestamp, duration, width, height, encoder identification and many other data. Here is an example using the ffprobe -show_frames command:
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 advanced options
-read_intervals ${read_intervals} specifies the time interval to be read
The -read_intervals parameter can be used to specify the time interval to be read.
This parameter accepts a list of time intervals, each time interval consists of two timestamps separated by commas. For example, -read_intervals 0:10,20:30 means that the content from second to 10th second and second to 20th second to 30th second of the file needs to be read.
Using the -read_intervals parameter can effectively reduce the time and resource consumption of ffprobe when reading media files and avoid unnecessary analysis. It is especially useful for large media files, improving processing speed and efficiency.
-select_streams ${stream_specifier} selects the specified stream
This parameter can accept multiple parameter options, for example:
- Option v: Select video stream
- Option a: Select audio stream
- Option s: Select subtitle stream
For example, use the following command to select all video and audio streams in an MP4 file:
ffprobe -i input.mp4 -select_streams v:a
Select the first video stream and the second audio stream
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 读取并解码流以用启发式方法填充缺失的信息