ffprobe 是ffmpeg的一个工具包,主要用于探测音视频文件的各种信息,这篇文章主要是总结记录下ffprobe常用的一些功能
一、 查看视频文件的信息:
1、查看一个音视频文件的基本信息:
ffprobe SampleVideo_1280x720_1mb.mp4

2、查看封装格式
ffprobe -show_format SampleVideo_1280x720_1mb.mp4

3、查看流信息
ffprobe -show_streams SampleVideo_1280x720_1mb.mp4
视频流信息:

音频流信息:

4、查看数据包信息
查看视频流的数据包信息:
ffprobe -show_packets -select_streams video SampleVideo_1280x720_1mb.mp4
最后两个数据包:

查看音频流的数据包信息:
ffprobe -show_packets -select_streams audio SampleVideo_1280x720_1mb.mp4
最后两个数据包:

5、查看音视频文件解码后的帧信息
视频流解码后的帧信息
ffprobe -show_frames -select_streams video SampleVideo_1280x720_1mb.mp4

音频流解码后的帧信息
ffprobe -show_frames -select_streams audio SampleVideo_1280x720_1mb.mp4

二、设置参数定制化输出结果
- -v 参数是日志输出级别,设置为error 则略去了 build 和 generic 信息
- -print_format 是输出结果格式,设置json,则以 json 格式输出,可用of替代
- -show_entries可以裁剪输出结果
应用举例:
1、以json格式输出指定项
ffprobe -show_streams -show_entries format=bit_rate,filename,start_time:stream=duration,width,height,display_aspect_ratio,r_frame_rate,bit_rate -of json -v quiet -i SampleVideo_1280x720_1mb.mp4

2、只输出视频帧计数:
ffprobe -v error -count_frames -select_streams v:0 \ -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 SampleVideo_1280x720_1mb.mp4

-count_frames计算每个流的帧数,并在相应的流部分中报告。
-select_streams v:0仅选择视频流。
-show_entries stream = nb_read_frames只显示读取的帧数。
-of default = nokey = 1:noprint_wrappers = 1将输出格式(也称为“writer”)设置为默认值,不打印每个字段的键(nokey = 1),不打印节头和页脚(noprint_wrappers = 1)
网友评论