[FFmpeg笔记]Flutter HDR兼容

845 阅读2分钟

名词解释

参考:h264和h265区别

FFmpeg Guide

准备环境

  • 下载视频

下载:drive.google.com/file/d/12pl…

来源:github.com/flutter/flu…

  • 安装FFmpeg
    • macOS:brew install ffmpeg
    • Windows:choco install ffmpeg
  • 安装MediaInfo
    • macOS:TODO
    • Windows:choco install mediainfo-cli

获取初步信息

$ ffprobe -hide_banner -loglevel error -select_streams v -print_format json -show_streams hdr_video.MOV
{
    "streams": [
        {
            "index": 0,
            "codec_name": "hevc",
            "codec_long_name": "H.265 / HEVC (High Efficiency Video Coding)",
            "profile": "Main 10",
            "codec_type": "video",
            "codec_tag_string": "hvc1",
            "codec_tag": "0x31637668",
            "width": 1920,
            "height": 1080,
            "coded_width": 1920,
            "coded_height": 1088,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 2,
            "pix_fmt": "yuv420p10le",
            "level": 120,
            "color_range": "tv",
            "color_space": "bt2020nc",
            "color_transfer": "arib-std-b67",
            "color_primaries": "bt2020",
            "chroma_location": "left",
            "refs": 1,
            "id": "0x1",
            "r_frame_rate": "30/1",
            "avg_frame_rate": "30/1",
            "time_base": "1/600",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 7460,
            "duration": "12.433333",
            "bit_rate": "8510054",
            "nb_frames": "373",
            "extradata_size": 125,
            "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,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2021-09-30T14:03:33.000000Z",
                "language": "und",
                "handler_name": "Core Media Video",
                "vendor_id": "[0][0][0][0]",
                "encoder": "HEVC"
            },
            "side_data_list": [
                {
                    "side_data_type": "DOVI configuration record",
                    "dv_version_major": 1,
                    "dv_version_minor": 0,
                    "dv_profile": 8,
                    "dv_level": 4,
                    "rpu_present_flag": 1,
                    "el_present_flag": 0,
                    "bl_present_flag": 1,
                    "dv_bl_signal_compatibility_id": 4
                },
                {
                    "side_data_type": "Display Matrix",
                    "displaymatrix": "\n00000000:            0      -65536           0\n00000001:        65536           0           0\n00000002:            0   125829120  1073741824\n",
                    "rotation": 90
                }
            ]
        }
    ]
}
$ mediainfo hdr_video.MOV
General
Complete name                            : hdr_video.MOV
Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   0000.00 (qt  )
File size                                : 13.0 MiB
Duration                                 : 12 s 433 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 8 770 kb/s
Encoded date                             : UTC 2021-09-30 14:03:33
Tagged date                              : UTC 2021-09-30 14:03:47
Writing library                          : Apple QuickTime
com.apple.quicktime.location.accuracy.ho : 4.772172
com.apple.quicktime.location.ISO6709     : +37.7383+029.0918+507.727/
com.apple.quicktime.make                 : Apple
com.apple.quicktime.model                : iPhone 12 Pro Max
com.apple.quicktime.software             : 15.0
com.apple.quicktime.creationdate         : 2021-09-30T17:03:33+0300

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L4@Main
HDR format                               : Dolby Vision, Version 1.0, dvhe.08.04, BL+RPU, HLG compatible
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 12 s 433 ms
Bit rate                                 : 8 510 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Rotation                                 : 270°
Frame rate mode                          : Constant
Frame rate                               : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.137
Stream size                              : 12.6 MiB (97%)
Title                                    : Core Media Video
Encoded date                             : UTC 2021-09-30 14:03:33
Tagged date                              : UTC 2021-09-30 14:03:47
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : HLG
Matrix coefficients                      : BT.2020 non-constant
Metas                                    : 3,4,5
Codec configuration box                  : hvcC+dvvC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 12 s 433 ms
Source duration                          : 12 s 492 ms
Bit rate mode                            : Variable
Bit rate                                 : 175 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 265 KiB (2%)
Source stream size                       : 266 KiB (2%)
Title                                    : Core Media Audio
Encoded date                             : UTC 2021-09-30 14:03:33
Tagged date                              : UTC 2021-09-30 14:03:47

初步信息详解

codec/profile

            "codec_name": "hevc",
            "codec_long_name": "H.265 / HEVC (High Efficiency Video Coding)",
            "profile": "Main 10",
            "codec_type": "video",
            "codec_tag_string": "hvc1",
            "codec_tag": "0x31637668",
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L4@Main
...
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding

codec_name:H.265/HEVC编码格式

profile:Main 10配置

codec_tag_string:hvc1标签

参考:

pix_fmt

参考:详解 YUV 格式(I420/YUV420/NV12/NV12/YUV422)

"pix_fmt": "yuv420p10le",
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits

pix_fmt:YUV像素格式,4:2:0采样(每四个 Y 分量共享一组 UV 分量),planar平面格式,10bit位深,little endian排列

疑问:yuv420p10le和p010le一样么?

stackoverflow.com/questions/6…

superuser.com/questions/1…

疑问:H264能支持10bit位深?

video.stackexchange.com/questions/1…

superuser.com/questions/1…

color_space

"color_range": "tv",
"color_space": "bt2020nc",
"color_transfer": "arib-std-b67",
"color_primaries": "bt2020",
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : HLG
Matrix coefficients                      : BT.2020 non-constant

color_range:TV levels取值范围

color_space:YUV色彩空间上,采用BT.2020 non-constant矩阵系数

color_transfer:HLG/ARIB STD-B67转换函数

color_primaries:BT.2020

参考:

Dolby Vision

"side_data_type": "DOVI configuration record",
"dv_version_major": 1,
"dv_version_minor": 0,
"dv_profile": 8,
"dv_level": 4,
"rpu_present_flag": 1,
"el_present_flag": 0,
"bl_present_flag": 1,
"dv_bl_signal_compatibility_id": 4
HDR format                               : Dolby Vision, Version 1.0, dvhe.08.04, BL+RPU, HLG compatible

dv_version_major/dv_version_minor:Dobly Vision版本1.0

dv_profile/dv_level:Dobly Vision配置8.4

rpu_present_flag/el_present_flag/bl_present_flag:有Base Layer,没有Enhancement Layer,采用Reference Picture Unit放置元信息

参考: