下载最新的4.1版本的Windows 64位FFprobe,FFprobe用于从多媒体流中获取相关信息或查看文件格式信息,并以可读的方式打印,FFprobe可以作为一个命令行程序单独使用。
通过执行以下命令将FFprobe信息重定位到ffprobe_help.txt文件中便于查看,FFprobe使用方法为:ffprobe.exe [options] [input_file]。
ffprobe.exe --help > ffprobe_help.txt
以下汇总FFprobe的常用操作:
1. 查看单幅图像信息如png或jpg,则执行以下命令,结果如下图所示:可以获取输入图像的宽、高;获取编码格式,对应FFmpeg源码中的枚举类型AVCodecID,如1.png的编码格式为png(AV_CODEC_ID_PNG),而1.jpg编码格式为mjpge(AV_CODEC_ID_MJPEG);获取像素格式,对应FFmpeg源码中的枚举类型AVPixelFormat,如1.png的像素格式为rgb24(AV_PIX_FMT_RGB24),而1.jpg的像素格式为yuvj444p(AV_PIX_FMT_YUVJ444P)
ffprobe.exe 1.png
ffprobe.exe 1.jpg
2. 查看avi文件信息,则执行以下命令,结果如下图所示:有两个流,一个视频流,一个音频流,视频流采用的是mpeg4(即对应枚举类型AVCodecID中的AV_CODEC_ID_MPEG4)编码方式,音频流采用的是ac3(即对应枚举类型AVCodecID中的AV_CODEC_ID_AC3)编码格式;此文件播放时长为11.26秒;帧率为24;视频帧的像素格式为yuv420p(对应枚举类型AVPixelFormat中的AV_PIX_FMT_YUV420P);视频尺寸为720x528
ffprobe.exe 1.avi
3. 对mp4文件以json格式打印输出(-print_format, 可用的打印格式包括:default, compact, csv, flat, ini, json, xml)、输出格式信息(-show_format)、输出流信息(-show_streams),则执行以下命令,结果如下图所示:有两个流,一个视频流,一个音频流,视频流采用的是h264(即对应枚举类型AVCodecID中的AV_CODEC_ID_H264)编码方式,音频流采用的是aac(即对应枚举类型AVCodecID中的AV_CODEC_ID_AAC)编码格式;此文件播放时长为16.64秒;帧率为30;视频帧的像素格式为yuv420p(对应枚举类型AVPixelFormat中的AV_PIX_FMT_YUV420P);视频尺寸为544x960;产生的1.mp4.info.txt的内容如下:
ffprobe.exe -print_format json -show_format -show_streams -i 1.mp4 > 1.mp4.info.txt
{
"streams": [
{
"index": 0,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 798720,
"duration": "16.640000",
"bit_rate": "96000",
"max_bit_rate": "94904",
"nb_frames": "780",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"creation_time": "2019-07-28T09:30:06.000000Z",
"language": "und"
}
},
{
"index": 1,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video",
"codec_time_base": "146669/8802000",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 544,
"height": 960,
"coded_width": 544,
"coded_height": 960,
"has_b_frames": 2,
"pix_fmt": "yuv420p",
"level": 31,
"chroma_location": "left",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"r_frame_rate": "30/1",
"avg_frame_rate": "4401000/146669",
"time_base": "1/90000",
"start_pts": 5998,
"start_time": "0.066644",
"duration_ts": 1466690,
"duration": "16.296556",
"bit_rate": "1157602",
"bits_per_raw_sample": "8",
"nb_frames": "489",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"creation_time": "2019-07-28T09:30:06.000000Z",
"language": "und",
"encoder": "JVT/AVC Coding"
}
}
],
"format": {
"filename": "1.mp4",
"nb_streams": 2,
"nb_programs": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.000000",
"duration": "16.640000",
"size": "2571206",
"bit_rate": "1236156",
"probe_score": 100,
"tags": {
"major_brand": "mp42",
"minor_version": "0",
"compatible_brands": "mp42isom",
"creation_time": "2019-07-28T09:30:06.000000Z"
}
}
}
4. 查看h264视频流文件信息:则执行以下命令,结果如下图所示:只有一个视频流,视频流采用的是h264(即对应枚举类型AVCodecID中的AV_CODEC_ID_H264)编码方式;帧率为25;视频帧的像素格式为yuv420p(对应枚举类型AVPixelFormat中的AV_PIX_FMT_YUV420P);视频尺寸为384x288
ffprobe.exe 1.264
5. 查看rtsp视频流信息:则执行以下命令,结果如下图所示:有两个流,一个视频流,一个音频流,视频流采用的是h264(即对应枚举类型AVCodecID中的AV_CODEC_ID_H264)编码方式,音频流采用的是aac(即对应枚举类型AVCodecID中的AV_CODEC_ID_AAC)编码格式;此文件播放时长为9分56.48秒;帧率为24;视频帧的像素格式为yuv420p(对应枚举类型AVPixelFormat中的AV_PIX_FMT_YUV420P);视频尺寸为240x160
ffprobe.exe rtsp://184.72.239.149/vod/mp4://BigBuckBunny_115k.mov