ffmpeg/ffprobe查看音频视频文件信息并输出为json格式
ffprobe -i 输入视频路径 -v quiet -print_format json -show_format -show_streams
如:
$ ffprobe -i tt.mp4 -v quiet -print_format json -show_format -show_streams
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video", // 视频
"codec_time_base": "1/20",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 640,
"height": 240,
"coded_width": 640,
"coded_height": 240,
"closed_captions": 0,
"has_b_frames": 2,
"pix_fmt": "yuv420p",
"level": 31,
"chroma_location": "left",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"r_frame_rate": "10/1",
"avg_frame_rate": "10/1",
"time_base": "1/10240",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 2192384,
"duration": "214.100000", // 时长
"bit_rate": "214395",
"bits_per_raw_sample": "8",
"nb_frames": "2141",
"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": {
"language": "und",
"handler_name": "VideoHandler"
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio", // 音频
"codec_time_base": "1/16000",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "fltp",
"sample_rate": "16000", // 采样率
"channels": 2,// 双轨
"channel_layout": "stereo",
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/16000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 3436544,
"duration": "214.784000",
"bit_rate": "48392",
"max_bit_rate": "48392",
"nb_frames": "3357",
"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": {
"language": "und",
"handler_name": "SoundHandler"
}
}
],
"format": {
"filename": "tt.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": "214.848000", // 时长 单位秒
"size": "7114680", // 文件大小
"bit_rate": "264919",
"probe_score": 100,
"tags": {
"major_brand": "isom",
"minor_version": "512",
"compatible_brands": "isomiso2avc1mp41",
"encoder": "Lavf57.58.101"
}
}
}
如果本篇文章对您有所帮助,请支持作者喝杯咖啡哦