通过ffprobe分析mp4 媒体信息

版权声明:本文为博主原创文章,未经博主允许不得转载。个人独立博客:https://ichenwin.github.io GitHub、知乎等网站用户名:iChenwin https://blog.csdn.net/u013993802/article/details/84850317
  1. 查看mp4的包信息:ffprobe -i 396025.MP4 -show_packets
    ···
    $ ffprobe -i ch01_00000000049000000.mp4 -show_packets
    [PACKET]
    codec_type=audio
    stream_index=1
    pts=7568010
    pts_time=84.089000
    dts=7568010
    dts_time=84.089000
    duration=5760
    duration_time=0.064000
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=519
    pos=235808
    flags=K_
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=7092000
    pts_time=78.800000
    dts=7092000
    dts_time=78.800000
    duration=6000
    duration_time=0.066667
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=235578
    pos=144
    flags=K_
    [/PACKET]
    [PACKET]
    codec_type=audio
    stream_index=1
    pts=7573770
    pts_time=84.153000
    dts=7573770
    dts_time=84.153000
    duration=5760
    duration_time=0.064000
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=519
    pos=262420
    flags=K_
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=7098000
    pts_time=78.866667
    dts=7098000
    dts_time=78.866667
    duration=6000
    duration_time=0.066667
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=26040
    pos=236364
    flags=__
    [/PACKET]
    [PACKET]
    codec_type=audio
    stream_index=1
    pts=7579530
    pts_time=84.217000
    dts=7579530
    dts_time=84.217000
    duration=5760
    duration_time=0.064000
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=519
    pos=287292
    flags=K_
    [/PACKET]

    [PACKET]
    codec_type=audio
    stream_index=1
    pts=13443210
    pts_time=149.369000
    dts=13443210
    dts_time=149.369000
    duration=5760
    duration_time=0.064000
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=519
    pos=19616064
    flags=K_
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=12960000
    pts_time=144.000000
    dts=12960000
    dts_time=144.000000
    duration=6000
    duration_time=0.066667
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=26135
    pos=19589912
    flags=__
    [/PACKET]
    [PACKET]
    codec_type=audio
    stream_index=1
    pts=13449060
    pts_time=149.434000
    dts=13449060
    dts_time=149.434000
    duration=5760
    duration_time=0.064000
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=519
    pos=19642984
    flags=K_
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=12966000
    pts_time=144.066667
    dts=12966000
    dts_time=144.066667
    duration=6000
    duration_time=0.066667
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=26346
    pos=19616620
    flags=__
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=12972000
    pts_time=144.133333
    dts=12972000
    dts_time=144.133333
    duration=6000
    duration_time=0.066667
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=197274
    pos=19643664
    flags=K_
    [/PACKET]
    ffprobe version N-87130-g2b9fd15 Copyright © 2007-2017 the FFmpeg developers
    built with gcc 7.1.0 (GCC)
    configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
    libavutil 55. 74.100 / 55. 74.100
    libavcodec 57.104.100 / 57.104.100
    libavformat 57. 79.100 / 57. 79.100
    libavdevice 57. 8.100 / 57. 8.100
    libavfilter 6.101.100 / 6.101.100
    libswscale 4. 7.103 / 4. 7.103
    libswresample 2. 8.100 / 2. 8.100
    libpostproc 54. 6.100 / 54. 6.100
    Input #0, mpeg, from ‘ch01_00000000049000000.mp4’:
    Duration: 00:01:10.70, start: 78.800000, bitrate: 2245 kb/s
    Stream #0:0[0x1e0]: Video: hevc (Main), yuvj420p(pc, bt709), 2560x1920, 15 fps, 15 tbr, 90k tbn, 15 tbc
    Stream #0:1[0x1c0]: Audio: aac (LC), 16000 Hz, mono, fltp, 64 kb/s
    [NULL @ 000000000060c1e0] missing picture in access unit
    ···
  2. 获取媒体文件或流的信息,比如封装格式、音视频编码格式、码率等信息:ffprobe -print_format json -show_format -show_streams -i EZVZ0053.MP4
    其中:

-print_format json(以json格式输出),

-show_format(输出封装格式信息),

-show_streams(输出流信息),

-i ./video/c.ts(输入文件)

$ ffprobe -print_format json -show_format -show_streams -i EZVZ0053.MP4
{
    "streams": [
        {
            "index": 0,
            "codec_name": "hevc",
            "codec_long_name": "H.265 / HEVC (High Efficiency Video Coding)",
            "profile": "Main",
            "codec_type": "video",
            "codec_time_base": "1/25",
            "codec_tag_string": "hvc1",
            "codec_tag": "0x31637668",
            "width": 3840,
            "height": 2160,
            "coded_width": 3840,
            "coded_height": 2160,
            "has_b_frames": 0,
            "sample_aspect_ratio": "0:1",
            "display_aspect_ratio": "0:1",
            "pix_fmt": "yuvj420p",
            "level": 150,
            "color_range": "pc",
            "color_space": "bt709",
            "color_transfer": "bt709",
            "color_primaries": "bt709",
            "refs": 1,
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/60000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 276000,
            "duration": "4.600000",
            "bit_rate": "17173754",
            "nb_frames": "115",
            "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": "2000-01-01T06:39:43.000000Z",
                "language": "eng",
                "handler_name": "\u000bDataHandler"
            }
        },
        {
            "index": 1,
            "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": 223232,
            "duration": "4.650667",
            "bit_rate": "159854",
            "nb_frames": "218",
            "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": "2000-01-01T06:39:43.000000Z",
                "language": "eng",
                "handler_name": "\u000bDataHandler"
            }
        }
    ],
    "format": {
        "filename": "EZVZ0053.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": "4.600000",
        "size": "10787461",
        "bit_rate": "18760801",
        "probe_score": 100,
        "tags": {
            "major_brand": "mp42",
            "minor_version": "0",
            "compatible_brands": "isomavc1mp42",
            "creation_time": "2000-01-01T06:39:43.000000Z"
        }
    }
}
ffprobe version N-87130-g2b9fd15 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 7.1.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 74.100 / 55. 74.100
  libavcodec     57.104.100 / 57.104.100
  libavformat    57. 79.100 / 57. 79.100
  libavdevice    57.  8.100 / 57.  8.100
  libavfilter     6.101.100 /  6.101.100
  libswscale      4.  7.103 /  4.  7.103
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'EZVZ0053.MP4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isomavc1mp42
    creation_time   : 2000-01-01T06:39:43.000000Z
  Duration: 00:00:04.60, start: 0.000000, bitrate: 18760 kb/s
    Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 3840x2160, 17173 kb/s, 25 fps, 25 tbr, 60k tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2000-01-01T06:39:43.000000Z
      handler_name    : DataHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)
    Metadata:
      creation_time   : 2000-01-01T06:39:43.000000Z
      handler_name    : DataHandler

猜你喜欢

转载自blog.csdn.net/u013993802/article/details/84850317