用ffmpeg中ffprobe以JSON格式获取音频信息

在外部程序调用并处理音频视频信息时,通过ffmpeg/ffprobe查看音频视频文件信息并输出为json格式是非常实用的功能,在终端输入以下命令:
ffprobe -v quiet -print_format json -show_format -show_streams #{source}
#{source}部分替换为mp3文件所在路径。输出如下:
{ "streams": [ { "index": 0, "codec_name": "mp3", "codec_long_name": "MP3
(MPEG audio layer 3)", "codec_type": "audio", "codec_time_base": "1/44100", "
codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "sample_fmt": "s16p",
"sample_rate": "44100", "channels": 2, "channel_layout": "stereo", "
bits_per_sample": 0, "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base
":"1/14112000", "start_pts": 353600, "start_time": "0.025057", "duration_ts":
3346145280, "duration": "237.113469", "bit_rate": "128000", "disposition": { "
default": 0, "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": { "encoder": "LAME3.99r" }, "
side_data_list": [ { "side_data_type": "Replay Gain" } ] }, { "index": 1, "
codec_name": "mjpeg", "codec_long_name": "Motion JPEG", "codec_type": "video", "
codec_time_base": "0/1", "codec_tag_string": "[0][0][0][0]", "codec_tag":
"0x0000", "width": 500, "height": 500, "coded_width": 500, "coded_height": 500,
"has_b_frames": 0, "sample_aspect_ratio": "0:1", "display_aspect_ratio": "0:1",
"pix_fmt": "yuvj444p", "level": -99, "color_range": "pc", "color_space":
"bt470bg", "chroma_location": "center", "refs": 1, "r_frame_rate": "90000/1", "
avg_frame_rate": "0/0", "time_base": "1/90000", "start_pts": 2255, "start_time":
"0.025056", "duration_ts": 21340212, "duration": "237.113467", "
bits_per_raw_sample": "8", "disposition": { "default": 0, "dub": 0, "original":
0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0,
"visual_impaired": 0, "clean_effects": 0, "attached_pic": 1, "timed_thumbnails":
0 }, "tags": { "comment": "Cover (front)" } } ], "format": { "filename":
"/Users/mac123/Desktop/music/张学友 - 吻别 (摇滚版).mp3", "nb_streams": 2, "nb_programs
":0, "format_name": "mp3", "format_long_name": "MP2/3 (MPEG audio layer 2/3)", "
start_time": "0.025056", "duration": "237.113469", "size": "3864162", "bit_rate
":"130373", "probe_score": 51, "tags": { "ID": "7063568", "title": "吻别 (摇滚版)", "
artist": "张学友", "album": "Jacky cheung 15", "genre": "Blues" } } }

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信