使用ffprobe获取音频信息(JSON格式)
发布日期:2021-06-29 11:52:48 浏览次数:2 分类:技术文章

本文共 3623 字,大约阅读时间需要 12 分钟。

用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"        }    }}

转载地址:https://blog.csdn.net/zzl819954692/article/details/80832936 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:MacOS应用中调用NSTask执行终端命令(调用ffprobe命令获取音频详细信息)
下一篇:Mac系统下基于Anaconda3安装Python集成开发环境

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月20日 12时59分13秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章