0
点赞
收藏
分享

微信扫一扫

u盘为什么一插上电脑就蓝屏,u盘一插电脑就蓝屏

ffprobe 是 FFmpeg 套件中的一个工具,用于分析多媒体内容,如视频、音频和图像。它能够显示各种信息,包括格式、流详情、标签、包信息等。当 ffprobe 输出 JSON 格式时,它会以 JSON 对象的形式提供结构化的数据,这使得数据易于解析和处理。

要让 ffprobe 输出 JSON 格式的数据,你可以使用 -print_format 选项,然后指定 json 作为输出格式。以下是一个基本的 ffprobe 命令示例,它输出 JSON 格式的媒体信息:

ffprobe -v error -show_format -show_streams -print_format json=compact=1 input_video.mp4

在这个命令中:

  • -v error:设置日志级别为错误,以避免输出无关的信息。
  • -show_format:显示多媒体内容的格式信息。
  • -show_streams:显示所有的流信息。
  • -print_format json=compact=1:设置输出格式为 JSON,并且使用紧凑格式(没有多余的空格和缩进)。
  • input_video.mp4:指定要分析的输入文件。

输出的 JSON 对象可能看起来像这样:

{
  "format": {
    "filename": "input_video.mp4",
    "nb_streams": 2,
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "format_long_name": "QuickTime / MOV",
    "start_time": "0.000000",
    "duration": "28.769000",
    "size": "31457336",
    "bit_rate": "884437",
    "probe_score": 100,
    "tags": {
      "major_brand": "mp42",
      "minor_version": "0",
      "compatible_brands": "mp42avc1",
      "creation_time": "2021-09-01T00:00:00.000000Z"
    },
    "format_tags": {
      "major_brand": "mp42",
      "minor_version": "0",
      "compatible_brands": "mp42avc1"
    }
  },
  "streams": [
    {
      "index": 0,
      "codec_name": "avc1",
      "codec_long_name": "AAC (Advanced Audio Coding)",
      "profile": "LC (Low Complexity)",
      "codec_type": "audio",
      "codec_time_base": "1/44100",
      "codec_tag_string": "[0][0][0][0]",
      "codec_tag": "0x[0][0][0][0]",
      "sample_fmt": "fltp",
      "sample_rate": "44100",
      "channels": 2,
      "channel_layout": "stereo",
      "bits_per_sample": 0,
      "r_frame_rate": "25/1",
      "avg_frame_rate": "25/1",
      "time_base": "1/44100",
      "start_pts": 0,
      "start_time": "0.000000",
      "duration_ts": 1264800,
      "duration": "28.700000",
      "bit_rate": "93696",
      "max_bit_rate": "93696",
      "buf_size": "6144",
      "nb_frames": 1168,
      "disposition": {
        "default": 0,
        "dub": 0,
        "original": 0,
        "comment": 0
      },
      "tags": {
        "language": "eng",
        "title": "Soundtrack"
      }
    },
    {
      "index": 1,
      "codec_name": "avc1",
      "codec_long_name": "AVC (H.264, MPEG-4 AVC, MPEG-4 part 10)",
      "profile": "High",
      "codec_type": "video",
      "codec_time_base": "1/50",
      "codec_tag_string": "[0][0][0][0]",
      "codec_tag": "0x[0][0][0][0]",
      "width": 1920,
      "height": 1080,
      "has_b_frames": 2,
      "sample_fmt": "yuv420p",
      "pix_fmt": "yuv420p",
      "time_base": "1/50",
      "start_pts": 4,
      "start_time": "0.080000",
      "duration_ts": 631800,
      "duration": "14.200000",
      "bit_rate": "826336",
      "max_bit_rate": "826336",
      "buf_size": "4096",
      "nb_frames": 2256,
      "disposition": {
        "default": 1,
        "dub": 0,
        "original": 0,
        "comment": 0
      },
      "tags": {
        "language": "eng",
        "title": "Video"
      }
    }
  ]
}

这个 JSON 对象包含了输入视频文件的格式信息和流信息。format 部分包含了文件级别的信息,如文件名、格式名称、时长、大小等。streams 数组包含了每个流的详细信息,如编解码器名称、分辨率、帧率、比特率等。

你可以根据需要调整 ffprobe 命令的选项来获取不同的信息。例如,如果你只对视频流感兴趣,可以使用 -show_streams 选项,并且可能不需要 -show_format 选项。

JSON 输出的格式是紧凑的,没有多余的空格和缩进,这使得它更容易被程序读取和解析。如果你更喜欢易读的格式,可以省略 compact=1 选项,ffprobe 将会输出带有缩进的 JSON 数据。

举报

相关推荐

0 条评论