ffmpeg7.0 flv支持hdr
ffmpeg7.0 flv支持hdr
自从ffmpeg6.0应用enhance rtmp支持h265/av1的flv格式后,7.0迎来了flv的hdr能力。本文介绍ffmpeg7.0如何支持hdr in flv。
如果对enhance rtmp如何支持h265不了解,推荐详解Enhanced-RTMP支持H.265
1. enhance rtmp关于hdr
文档enhance-rtmp-v2.md中,metadata-frame章节规定相关支持HDR部分。
定义一个新的VideoPacketType.Metadata,其内容为AMF格式的metadata(AMF是一种简便的描述格式,非常节省内存),具体内部有HDR相关的colorInfo数据(每次hdr参数更新的时候,就发送该metadata)。
type ColorInfo = {colorConfig: {// number of bits used to record the color channels for each pixelbitDepth: number, // SHOULD be 8, 10 or 12//// colorPrimaries, transferCharacteristics and matrixCoefficients are defined // in ISO/IEC 23091-4/ITU-T H.273. The values are an index into // respective tables which are described in “Colour primaries”, // "Transfer characteristics" and "Matrix coefficients" sections. // It is RECOMMENDED to provide these values.//// indicates the chromaticity coordinates of the source color primariescolorPrimaries: number, // enumeration [0-255]// opto-electronic transfer characteristic function (ex. PQ, HLG)transferCharacteristics: number, // enumeration [0-255]// matrix coefficients used in deriving luma and chroma signalsmatrixCoefficients: number, // enumeration [0-255]},hdrCll: {//// maximum value of the frame average light level// (in 1 cd/m2) of the entire playback sequence//maxFall: number, // [0.0001-10000]//// maximum light level of any single pixel (in 1 cd/m2)// of the entire playback sequence//maxCLL: number, // [0.0001-10000]},//// The hdrMdcv object defines mastering display (i.e., where// creative work is done during the mastering process) color volume (a.k.a., mdcv)// metadata which describes primaries, white point and min/max luminance. The// hdrMdcv object SHOULD be provided.//// Specification of the metadata along with its ranges adhere to the// ST 2086:2018 - SMPTE Standard (except for minLuminance see// comments below)//hdrMdcv: {//// Mastering display color volume (mdcv) xy Chromaticity Coordinates within CIE// 1931 color space.//// Values SHALL be specified with four decimal places. The x coordinate SHALL// be in the range [0.0001, 0.7400]. The y coordinate SHALL be // in the range [0.0001, 0.8400].//redX: number,redY: number,greenX: number,greenY: number,blueX: number,blueY: number,whitePointX: number,whitePointY: number,//// max/min display luminance of the mastering display (in 1 cd/m2 ie. nits)//// note: ST 2086:2018 - SMPTE Standard specifies minimum display mastering// luminance in multiples of 0.0001 cd/m2.// // For consistency we specify all values// in 1 cd/m2. Given that a hypothetical perfect screen has a peak brightness// of 10,000 nits and a black level of .0005 nits we do not need to// switch units to 0.0001 cd/m2 to increase resolution on the lower end of the// minLuminance property. The ranges (in nits) mentioned below suffice// the theoretical limit for Mastering Reference Displays and adhere to the// SMPTE ST 2084 standard (a.k.a., PQ) which is capable of representing full gamut// of luminance level.//maxLuminance: number, // [5-10000]minLuminance: number, // [0.0001-5]},
}
2. flv mux
在libavformat/flvenc.c中,新增flv_write_metadata_packet函数,用于添加metadata。
flv的数据结构:
typedef struct FLVContext {.....int metadata_pkt_written;//0: 还未写过,需要写;1: 写过了,不需要写。
} FLVContext;
在函数flv_write_metadata_packet中实现,见注释:
static void flv_write_metadata_packet(AVFormatContext *s, AVCodecParameters *par, unsigned int ts) {FLVContext *flv = s->priv_data;//不需要写入,就返回;可以通过设置这个标志变量来使能/去使能更新写metadataif (flv->metadata_pkt_written)return;//支持h265, av1, vp9if (par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) {......//写入tag头,标识其为视频avio_w8(pb, FLV_TAG_TYPE_VIDEO); //write video tag typemetadata_size_pos = avio_tell(pb);avio_wb24(pb, 0 + flags_size);put_timestamp(pb, ts); //ts = pkt->dts, genavio_wb24(pb, flv->reserved);//根据enhance rtmp标志,写入FLV_IS_EX_HEADER标识,和fourCC的字段(hvc1 or av01 or vp09)if (par->codec_id == AV_CODEC_ID_HEVC) {avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeMetadata| FLV_FRAME_VIDEO_INFO_CMD); // ExVideoTagHeader mode with PacketTypeMetadataavio_write(pb, "hvc1", 4);} else if (par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) {avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeMetadata| FLV_FRAME_VIDEO_INFO_CMD);avio_write(pb, par->codec_id == AV_CODEC_ID_AV1 ? "av01" : "vp09", 4);}//下面为写入AMF格式的hdr相关的colorInfo数据avio_w8(pb, AMF_DATA_TYPE_STRING);put_amf_string(pb, "colorInfo");avio_w8(pb, AMF_DATA_TYPE_OBJECT);put_amf_string(pb, "colorConfig"); // colorConfigavio_w8(pb, AMF_DATA_TYPE_OBJECT);if (par->color_trc != AVCOL_TRC_UNSPECIFIED &&par->color_trc < AVCOL_TRC_NB) {put_amf_string(pb, "transferCharacteristics"); // color_trcput_amf_double(pb, par->color_trc);}if (par->color_space != AVCOL_SPC_UNSPECIFIED &&par->color_space < AVCOL_SPC_NB) {put_amf_string(pb, "matrixCoefficients"); // colorspaceput_amf_double(pb, par->color_space);}if (par->color_primaries != AVCOL_PRI_UNSPECIFIED &&par->color_primaries < AVCOL_PRI_NB) {put_amf_string(pb, "colorPrimaries"); // color_primariesput_amf_double(pb, par->color_primaries);}put_amf_string(pb, "");avio_w8(pb, AMF_END_OF_OBJECT);if (lightMetadata) {put_amf_string(pb, "hdrCll");avio_w8(pb, AMF_DATA_TYPE_OBJECT);put_amf_string(pb, "maxFall");put_amf_double(pb, lightMetadata->MaxFALL);put_amf_string(pb, "maxCLL");put_amf_double(pb, lightMetadata->MaxCLL);put_amf_string(pb, "");avio_w8(pb, AMF_END_OF_OBJECT);}if (displayMetadata && (displayMetadata->has_primaries || displayMetadata->has_luminance)) {put_amf_string(pb, "hdrMdcv");avio_w8(pb, AMF_DATA_TYPE_OBJECT);if (displayMetadata->has_primaries) {put_amf_string(pb, "redX");put_amf_double(pb, av_q2d(displayMetadata->display_primaries[0][0]));put_amf_string(pb, "redY");put_amf_double(pb, av_q2d(displayMetadata->display_primaries[0][1]));put_amf_string(pb, "greenX");put_amf_double(pb, av_q2d(displayMetadata->display_primaries[1][0]));put_amf_string(pb, "greenY");put_amf_double(pb, av_q2d(displayMetadata->display_primaries[1][1]));put_amf_string(pb, "blueX");put_amf_double(pb, av_q2d(displayMetadata->display_primaries[2][0]));put_amf_string(pb, "blueY");put_amf_double(pb, av_q2d(displayMetadata->display_primaries[2][1]));put_amf_string(pb, "whitePointX");put_amf_double(pb, av_q2d(displayMetadata->white_point[0]));put_amf_string(pb, "whitePointY");put_amf_double(pb, av_q2d(displayMetadata->white_point[1]));}if (displayMetadata->has_luminance) {put_amf_string(pb, "maxLuminance");put_amf_double(pb, av_q2d(displayMetadata->max_luminance));put_amf_string(pb, "minLuminance");put_amf_double(pb, av_q2d(displayMetadata->min_luminance));}put_amf_string(pb, "");avio_w8(pb, AMF_END_OF_OBJECT);}put_amf_string(pb, "");avio_w8(pb, AMF_END_OF_OBJECT);flv->metadata_pkt_written = 1;//标识写过了}
}
其中HDR的数据来源为AVCodecParameters *par数据结构中的内容:
typedef struct AVCodecParameters {..../*** Video only. Additional colorspace characteristics.*/enum AVColorRange color_range;enum AVColorPrimaries color_primaries;enum AVColorTransferCharacteristic color_trc;enum AVColorSpace color_space;enum AVChromaLocation chroma_location;/** 类型: AV_PKT_DATA_CONTENT_LIGHT_LEVEL, 数据: AVContentLightMetadata* lightMetadata* 类型: AV_PKT_DATA_MASTERING_DISPLAY_METADATA, 数据: AVMasteringDisplayMetadata *displayMetadata*/AVPacketSideData *coded_side_data;....
}
3. flv demux
解析函数在libavformat/flvdec.c文件中,函数amf_parse_object中。
static int amf_parse_object(AVFormatContext *s, AVStream *astream,AVStream *vstream, const char *key,int64_t max_pos, int depth)
{FLVMetaVideoColor *meta_video_color = flv->metaVideoColor;......if (meta_video_color) {if (amf_type == AMF_DATA_TYPE_NUMBER ||amf_type == AMF_DATA_TYPE_BOOL) {if (!strcmp(key, "colorPrimaries")) {meta_video_color->primaries = num_val;} else if (!strcmp(key, "transferCharacteristics")) {meta_video_color->transfer_characteristics = num_val;} else if (!strcmp(key, "matrixCoefficients")) {meta_video_color->matrix_coefficients = num_val;} else if (!strcmp(key, "maxFall")) {meta_video_color->max_fall = num_val;} else if (!strcmp(key, "maxCLL")) {meta_video_color->max_cll = num_val;} else if (!strcmp(key, "redX")) {meta_video_color->mastering_meta.r_x = num_val;} else if (!strcmp(key, "redY")) {meta_video_color->mastering_meta.r_y = num_val;} else if (!strcmp(key, "greenX")) {meta_video_color->mastering_meta.g_x = num_val;} else if (!strcmp(key, "greenY")) {meta_video_color->mastering_meta.g_y = num_val;} else if (!strcmp(key, "blueX")) {meta_video_color->mastering_meta.b_x = num_val;} else if (!strcmp(key, "blueY")) {meta_video_color->mastering_meta.b_y = num_val;} else if (!strcmp(key, "whitePointX")) {meta_video_color->mastering_meta.white_x = num_val;} else if (!strcmp(key, "whitePointY")) {meta_video_color->mastering_meta.white_y = num_val;} else if (!strcmp(key, "maxLuminance")) {meta_video_color->mastering_meta.max_luminance = num_val;} else if (!strcmp(key, "minLuminance")) {meta_video_color->mastering_meta.min_luminance = num_val;}}}......
}
4. 感谢Zhu Pengfei的提交
Author: Zhu Pengfei <411294962@qq.com>
Date: Mon Mar 4 21:52:04 2024 +0800avformat/flvenc: support enhanced flv PacketTypeMetadataSigned-off-by: Zhu Pengfei <411294962@qq.com>Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
``
相关文章:
ffmpeg7.0 flv支持hdr
ffmpeg7.0 flv支持hdr 自从ffmpeg6.0应用enhance rtmp支持h265/av1的flv格式后,7.0迎来了flv的hdr能力。本文介绍ffmpeg7.0如何支持hdr in flv。 如果对enhance rtmp如何支持h265不了解,推荐详解Enhanced-RTMP支持H.265 1. enhance rtmp关于hdr 文档…...
【教程】极简Python接入免费语音识别API
转载请注明出处:小锋学长生活大爆炸[xfxuezhagn.cn] 如果本文帮助到了你,请不吝给个[点赞、收藏、关注]哦~ 安装库: pip install SpeechRecognition 使用方法: import speech_recognition as srr sr.Recognizer() harvard sr…...
详解typora配置亚马逊云科技Amazon S3图床
欢迎免费试用亚马逊云科技产品:https://mic.anruicloud.com/url/1333 当前有很多不同的博客社区,不同的博客社区使用的编辑器也不尽相同,大概可以分为两种,一种是markdown格式,另外一种是富文本格式。例如华为云开发者…...
Python sqlite3库 实现 数据库基础及应用 输入地点,可输出该地点的爱国主义教育基地名称和批次的查询结果。
目录 【第11次课】实验十数据库基础及应用1-查询 要求: 提示: 运行结果: 【第11次课】实验十数据库基础及应用1-查询 声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 1.简答题 数据库文件Edu_Base.db&#…...
iOS-SSL固定证书
文章目录 1. SSL简介2. 证书锁定原理1.1 证书锁定1.2 公钥锁定1.3 客户端获取公钥1.4 客户端使用SSL锁定选择1.5 项目支持SSL证书锁定1.6 问题记录1. SSL简介 证书锁定(SSL/TLS Pinning)顾名思义,将服务器提供的SSL/TLS证书内置到移动端开发的APP客户端中,当客户端发起请求…...
docker 开启 tcp 端口
前言:查了很多网上资料 都说要修改daemons,json 完全不管用,而且还导致添加 {“host”:["tcp://0.0.0.0:2375","unix:///var/lib/docker.sock"]} 后,docker restart 失败,浪费了不少时间 !&am…...
zookeeper之分布式环境搭建
ZooKeeper的分布式环境搭建是一个涉及多个步骤的过程,主要包括准备工作、安装ZooKeeper、配置集群、启动服务以及验证集群状态。以下是搭建ZooKeeper分布式环境的基本步骤: 1. 准备工作 确保所有节点的系统时间同步。确保所有节点之间网络互通…...
java设计模式三
工厂模式是一种创建型设计模式,它提供了一个创建对象的接口,但允许子类决定实例化哪一个类。工厂模式有几种变体,包括简单工厂模式、工厂方法模式和抽象工厂模式。下面通过一个简化的案例和对Java标准库中使用工厂模式的源码分析来说明这一模…...
##12 深入了解正则化与超参数调优:提升神经网络性能的关键策略
文章目录 前言1. 正则化技术的重要性1.1 L1和L2正则化1.2 Dropout1.3 批量归一化 2. 超参数调优技术2.1 网格搜索2.2 随机搜索2.3 贝叶斯优化 3. 实践案例3.1 设置实验3.2 训练和测试 4. 结论 前言 在深度学习中,构建一个高性能的模型不仅需要一个好的架构…...
TODESK怎么查看有人在远程访问
odesk怎么查看有人在远程访问 Todesk作为一款远程桌面控制软件,为用户提供了便捷的远程访问与控制功能。但在享受这种便利的同时,许多用户也关心如何确保自己设备的安全,特别是如何知道是否有人在未经授权的情况下远程访问自己的电脑。本文将…...
【Web漏洞指南】服务器端 XSS(动态 PDF)
【Web漏洞指南】服务器端 XSS(动态 PDF) 概述流行的 PDF 生成工具常见攻击载荷 概述 如果一个网页使用用户控制的输入创建 PDF,您可以尝试欺骗创建 PDF 的机器人以执行任意的 JS 代码。 因此,如果PDF 创建机器人发现某种HTML标签…...
Qt中的对象树
一. QT对象树的概念 QObject 的构造函数中会传入一个 Parent 父对象指针,children() 函数返回 QObjectList。即每一个 QObject 对象有且仅有一个父对象,但可以有很多个子对象。 那么Qt这样设计的好处是什么呢?很简单,就是为了方…...
QT-day1
1、 自由发挥应用场景,实现登录界面。 要求:尽量每行代码都有注释。 #ifndef MYWIDGET_H #define MYWIDGET_H #include <QWidget> #include <QIcon>//窗口 #include <QLabel>//标签库 #include <QMovie>//动态图片库 #include…...
安装oh-my-zsh(命令行工具)
文章目录 一、安装zsh、git、wget二、安装运行脚本1、curl/wget下载2、手动下载 三、切换主题1、编辑配置文件2、切换主题 四、安装插件1、zsh-syntax-highlighting(高亮语法错误)2、zsh-autosuggestions(自动补全) 五、更多优化配…...
解决方案:‘Series‘ object has no attribute ‘xxxx‘
文章目录 一、现象二、解决方案 一、现象 ...... model.fit(X_train, y_train) y_pred model.predict(X_test) recall recall_score(y_test, y_pred) precision precision_score(y_test. y_pred) ......执行语句到**“precision precision_score(y_test. y_pred)”**这里发…...
智慧手术室手麻系统源码,C#手术麻醉临床信息系统源码,符合三级甲等医院评审要求
手麻系统全套源码,C#手术麻醉系统源码,支持二次开发,授权后可商用。 手术麻醉临床信息系统功能符合三级甲等医院评审要求,实现与医院现有信息系统如HIS、LIS、PACS、EMR等系统全面对接,全面覆盖从患者入院,…...
项目公共组件代码
弹出框标题 <Textstyle{{marginTop: 20,marginBottom: 5,fontSize: 20,textAlign: center,fontWeight: bold,color: black,}}>{data.language.CROUPLIST_CLASS_MEMBERS}</Text>可以复用的公共体 import React, {useContext, useEffect, useState} from react; imp…...
深入解析MySQL中的事务(上)
MySQL事务管理 一、事务的基本概念为什么需要事务?1. 数据完整性2. 并发控制3. 错误恢复4. 复杂业务逻辑的支持5. 安全性 为什么会出现事务查看引擎是否支持事务事务提交方式自动提交(Automatic Commit)手动提交(Manual Commit&am…...
Springboot项目使用redis实现session共享
1.安装redis,并配置密码 这里就不针对于redis的安装约配置进行说明了,直接在项目中使用。 redis在windows环境下安装:Window下Redis的安装和部署详细图文教程(Redis的安装和可视化工具的使用)_redis安装-CSDN博客 2…...
【Linux】Centos7安装部署unimrcp,搭建MRCP服务器
yum install libtool yum install libtool-ltdl-devel yum install libsofia-sip-ua find / -name libsofia-sip-ua.so.0 2>/dev/null # 设置环境变量:如果库文件存在但不在默认搜索路径中,你可以通过设置 LD_LIBRARY_PATH 环境变量来告诉系统在哪…...
docker详细操作--未完待续
docker介绍 docker官网: Docker:加速容器应用程序开发 harbor官网:Harbor - Harbor 中文 使用docker加速器: Docker镜像极速下载服务 - 毫秒镜像 是什么 Docker 是一种开源的容器化平台,用于将应用程序及其依赖项(如库、运行时环…...
Admin.Net中的消息通信SignalR解释
定义集线器接口 IOnlineUserHub public interface IOnlineUserHub {/// 在线用户列表Task OnlineUserList(OnlineUserList context);/// 强制下线Task ForceOffline(object context);/// 发布站内消息Task PublicNotice(SysNotice context);/// 接收消息Task ReceiveMessage(…...
STM32F4基本定时器使用和原理详解
STM32F4基本定时器使用和原理详解 前言如何确定定时器挂载在哪条时钟线上配置及使用方法参数配置PrescalerCounter ModeCounter Periodauto-reload preloadTrigger Event Selection 中断配置生成的代码及使用方法初始化代码基本定时器触发DCA或者ADC的代码讲解中断代码定时启动…...
蓝牙 BLE 扫描面试题大全(2):进阶面试题与实战演练
前文覆盖了 BLE 扫描的基础概念与经典问题蓝牙 BLE 扫描面试题大全(1):从基础到实战的深度解析-CSDN博客,但实际面试中,企业更关注候选人对复杂场景的应对能力(如多设备并发扫描、低功耗与高发现率的平衡)和前沿技术的…...
Python爬虫(一):爬虫伪装
一、网站防爬机制概述 在当今互联网环境中,具有一定规模或盈利性质的网站几乎都实施了各种防爬措施。这些措施主要分为两大类: 身份验证机制:直接将未经授权的爬虫阻挡在外反爬技术体系:通过各种技术手段增加爬虫获取数据的难度…...
[Java恶补day16] 238.除自身以外数组的乘积
给你一个整数数组 nums,返回 数组 answer ,其中 answer[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积 。 题目数据 保证 数组 nums之中任意元素的全部前缀元素和后缀的乘积都在 32 位 整数范围内。 请 不要使用除法,且在 O(n) 时间复杂度…...
pikachu靶场通关笔记22-1 SQL注入05-1-insert注入(报错法)
目录 一、SQL注入 二、insert注入 三、报错型注入 四、updatexml函数 五、源码审计 六、insert渗透实战 1、渗透准备 2、获取数据库名database 3、获取表名table 4、获取列名column 5、获取字段 本系列为通过《pikachu靶场通关笔记》的SQL注入关卡(共10关࿰…...
九天毕昇深度学习平台 | 如何安装库?
pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple --user 举个例子: 报错 ModuleNotFoundError: No module named torch 那么我需要安装 torch pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple --user pip install 库名&#x…...
HashMap中的put方法执行流程(流程图)
1 put操作整体流程 HashMap 的 put 操作是其最核心的功能之一。在 JDK 1.8 及以后版本中,其主要逻辑封装在 putVal 这个内部方法中。整个过程大致如下: 初始判断与哈希计算: 首先,putVal 方法会检查当前的 table(也就…...
sipsak:SIP瑞士军刀!全参数详细教程!Kali Linux教程!
简介 sipsak 是一个面向会话初始协议 (SIP) 应用程序开发人员和管理员的小型命令行工具。它可以用于对 SIP 应用程序和设备进行一些简单的测试。 sipsak 是一款 SIP 压力和诊断实用程序。它通过 sip-uri 向服务器发送 SIP 请求,并检查收到的响应。它以以下模式之一…...
