FFmpegd的AVBSF
本章主要介绍AVBSF
文章目录
- 结构体定义
- 对外函数
- 常见的过滤器
从名字我们可以知道这是个码流过滤器,我们最常用的是一个叫做h264_mp4toannexb_bsf的东东
这个过滤器的作用是把h264以MP4格式的NALU转换为annexb(0x000001)
const AVBitStreamFilter ff_h264_mp4toannexb_bsf = {.name = "h264_mp4toannexb",.priv_data_size = sizeof(H264BSFContext),.init = h264_mp4toannexb_init,.filter = h264_mp4toannexb_filter,.flush = h264_mp4toannexb_flush,.codec_ids = codec_ids,
};
结构体定义
/*** @addtogroup lavc_core* @{*//*** The bitstream filter state.** This struct must be allocated with av_bsf_alloc() and freed with* av_bsf_free().** The fields in the struct will only be changed (by the caller or by the* filter) as described in their documentation, and are to be considered* immutable otherwise.*/
typedef struct AVBSFContext {/*** A class for logging and AVOptions*/const AVClass *av_class;/*** The bitstream filter this context is an instance of.*/const struct AVBitStreamFilter *filter;/*** Opaque filter-specific private data. If filter->priv_class is non-NULL,* this is an AVOptions-enabled struct.*/void *priv_data;/*** Parameters of the input stream. This field is allocated in* av_bsf_alloc(), it needs to be filled by the caller before* av_bsf_init().*/AVCodecParameters *par_in;/*** Parameters of the output stream. This field is allocated in* av_bsf_alloc(), it is set by the filter in av_bsf_init().*/AVCodecParameters *par_out;/*** The timebase used for the timestamps of the input packets. Set by the* caller before av_bsf_init().*/AVRational time_base_in;/*** The timebase used for the timestamps of the output packets. Set by the* filter in av_bsf_init().*/AVRational time_base_out;
} AVBSFContext;
上面是bsf的上下文,下面的是它的插件回调函数
typedef struct AVBitStreamFilter {const char *name;/*** A list of codec ids supported by the filter, terminated by* AV_CODEC_ID_NONE.* May be NULL, in that case the bitstream filter works with any codec id.*/const enum AVCodecID *codec_ids;/*** A class for the private data, used to declare bitstream filter private* AVOptions. This field is NULL for bitstream filters that do not declare* any options.** If this field is non-NULL, the first member of the filter private data* must be a pointer to AVClass, which will be set by libavcodec generic* code to this class.*/const AVClass *priv_class;/****************************************************************** No fields below this line are part of the public API. They* may not be used outside of libavcodec and can be changed and* removed at will.* New public fields should be added right above.******************************************************************/int priv_data_size;int (*init)(AVBSFContext *ctx);int (*filter)(AVBSFContext *ctx, AVPacket *pkt);void (*close)(AVBSFContext *ctx);void (*flush)(AVBSFContext *ctx);
} AVBitStreamFilter;
看多了就会发现非常相似,基本就一个套路,一个上下文结构体,一个回调插件结构体,上下文中一个私有的指针,大小为priv_data_size,所以如果想要实现插件,简单的实现这几个回调函数就可以了。
对外函数
核心对外函数
/*** @return a bitstream filter with the specified name or NULL if no such* bitstream filter exists.*/
const AVBitStreamFilter *av_bsf_get_by_name(const char *name);/*** Iterate over all registered bitstream filters.** @param opaque a pointer where libavcodec will store the iteration state. Must* point to NULL to start the iteration.** @return the next registered bitstream filter or NULL when the iteration is* finished*/
const AVBitStreamFilter *av_bsf_iterate(void **opaque);/*** Allocate a context for a given bitstream filter. The caller must fill in the* context parameters as described in the documentation and then call* av_bsf_init() before sending any data to the filter.** @param filter the filter for which to allocate an instance.* @param ctx a pointer into which the pointer to the newly-allocated context* will be written. It must be freed with av_bsf_free() after the* filtering is done.** @return 0 on success, a negative AVERROR code on failure*/
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx);/*** Prepare the filter for use, after all the parameters and options have been* set.*/
int av_bsf_init(AVBSFContext *ctx);/*** Submit a packet for filtering.** After sending each packet, the filter must be completely drained by calling* av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or* AVERROR_EOF.** @param pkt the packet to filter. The bitstream filter will take ownership of* the packet and reset the contents of pkt. pkt is not touched if an error occurs.* If pkt is empty (i.e. NULL, or pkt->data is NULL and pkt->side_data_elems zero),* it signals the end of the stream (i.e. no more non-empty packets will be sent;* sending more empty packets does nothing) and will cause the filter to output* any packets it may have buffered internally.** @return 0 on success. AVERROR(EAGAIN) if packets need to be retrieved from the* filter (using av_bsf_receive_packet()) before new input can be consumed. Another* negative AVERROR value if an error occurs.*/
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);/*** Retrieve a filtered packet.** @param[out] pkt this struct will be filled with the contents of the filtered* packet. It is owned by the caller and must be freed using* av_packet_unref() when it is no longer needed.* This parameter should be "clean" (i.e. freshly allocated* with av_packet_alloc() or unreffed with av_packet_unref())* when this function is called. If this function returns* successfully, the contents of pkt will be completely* overwritten by the returned data. On failure, pkt is not* touched.** @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the* filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there* will be no further output from the filter. Another negative AVERROR value if* an error occurs.** @note one input packet may result in several output packets, so after sending* a packet with av_bsf_send_packet(), this function needs to be called* repeatedly until it stops returning 0. It is also possible for a filter to* output fewer packets than were sent to it, so this function may return* AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call.*/
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt);/*** Reset the internal bitstream filter state. Should be called e.g. when seeking.*/
void av_bsf_flush(AVBSFContext *ctx);/*** Free a bitstream filter context and everything associated with it; write NULL* into the supplied pointer.*/
void av_bsf_free(AVBSFContext **ctx);
其实这些函数内部也很简单,主要就是对回调函数的封装。
常见的过滤器
extern const AVBitStreamFilter ff_aac_adtstoasc_bsf;
extern const AVBitStreamFilter ff_av1_frame_merge_bsf;
extern const AVBitStreamFilter ff_av1_frame_split_bsf;
extern const AVBitStreamFilter ff_av1_metadata_bsf;
extern const AVBitStreamFilter ff_chomp_bsf;
extern const AVBitStreamFilter ff_dump_extradata_bsf;
extern const AVBitStreamFilter ff_dca_core_bsf;
extern const AVBitStreamFilter ff_eac3_core_bsf;
extern const AVBitStreamFilter ff_extract_extradata_bsf;
extern const AVBitStreamFilter ff_filter_units_bsf;
extern const AVBitStreamFilter ff_h264_metadata_bsf;
extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf;
extern const AVBitStreamFilter ff_h264_redundant_pps_bsf;
extern const AVBitStreamFilter ff_hapqa_extract_bsf;
extern const AVBitStreamFilter ff_hevc_metadata_bsf;
extern const AVBitStreamFilter ff_hevc_mp4toannexb_bsf;
extern const AVBitStreamFilter ff_imx_dump_header_bsf;
extern const AVBitStreamFilter ff_mjpeg2jpeg_bsf;
extern const AVBitStreamFilter ff_mjpega_dump_header_bsf;
extern const AVBitStreamFilter ff_mp3_header_decompress_bsf;
extern const AVBitStreamFilter ff_mpeg2_metadata_bsf;
extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf;
extern const AVBitStreamFilter ff_mov2textsub_bsf;
extern const AVBitStreamFilter ff_noise_bsf;
extern const AVBitStreamFilter ff_null_bsf;
extern const AVBitStreamFilter ff_opus_metadata_bsf;
extern const AVBitStreamFilter ff_pcm_rechunk_bsf;
extern const AVBitStreamFilter ff_prores_metadata_bsf;
extern const AVBitStreamFilter ff_remove_extradata_bsf;
extern const AVBitStreamFilter ff_setts_bsf;
extern const AVBitStreamFilter ff_text2movsub_bsf;
extern const AVBitStreamFilter ff_trace_headers_bsf;
extern const AVBitStreamFilter ff_truehd_core_bsf;
extern const AVBitStreamFilter ff_vp9_metadata_bsf;
extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf;
extern const AVBitStreamFilter ff_vp9_superframe_bsf;
extern const AVBitStreamFilter ff_vp9_superframe_split_bsf;
相关文章:
FFmpegd的AVBSF
本章主要介绍AVBSF 文章目录 结构体定义对外函数常见的过滤器 从名字我们可以知道这是个码流过滤器,我们最常用的是一个叫做h264_mp4toannexb_bsf的东东 这个过滤器的作用是把h264以MP4格式的NALU转换为annexb(0x000001) const AVBitStreamF…...

深圳三男子写字楼内吸烟被罚,快用富维AI神器,实时监控防火灾
最近,在深圳,一专项控烟督查组在福田区新华保险大厦发现三名男子在写字楼内楼道违法吸烟,并对其进行了现场处罚。根据《控烟条例》,这类室内区域严禁吸烟,但人们往往忽视这一规定,从而引发潜在的安全风险。…...

有哪些已经上线的vue商城项目?
前言 下面是一些商城的项目,需要练手的同学可以挑选一些来练,废话少说,让我们直接开始正题~~ 1、newbee-mall-vue3-app 是一个基于 Vue 3 和 TypeScript 的电商前端项目,它是 newbee-mall 项目的升级版。该项目包含了商品列表、…...

Nginx服务器配置SSL证书
本文将全面介绍如何在Nginx或Tengine服务器配置SSL证书,具体包括下载和上传证书文件,在Nginx上配置证书文件、证书链和证书密钥等参数,以及安装证书后结果的验证。成功配置SSL证书后,您将能够通过HTTPS加密通道安全访问Nginx服务器…...

【JVM从入门到实战】(六)类加载器的双亲委派机制
一、双亲委派机制 在Java中如何使用代码的方式去主动加载一个类呢? 方式1:使用Class.forName方法,使用当前类的类加载器去加载指定的类。 方式2:获取到类加载器,通过类加载器的loadClass方法指定某个类加载器加载。 …...

SpringCloud面试题及答案(最新50道大厂版,持续更新)
在Java开发中,Spring Cloud作为微服务架构的关键组成部分,为了帮助广大Java技术爱好者和专业开发人员深入理解Spring Cloud,本文《SpringCloud面试题及答案(最新50道大厂版,持续更新)》提供了最前沿、最实用…...
Next.js 的设计理念
Next.js 的设计理念:简洁、强大与高效 Next.js 是一个流行的 React 框架,由 Vercel 公司开发。它的设计理念是简洁、强大和高效,这种理念贯穿于 Next.js 的所有功能中。下面我们将深入探讨这三个设计理念。 简洁 Next.js 的一个核心设计理…...

26、文件包含
文章目录 一、文件包含1.1 概念1.2 PHP文件包含原理1.3 文件包含重要函数1.4 文件包含利用条件 二、文件包含漏洞利用2.1 文件包含分类2.2 常见敏感文件2.3 包含Apache日志文件2.4 常见中间件的日志路径2.5 包含其他日志文件2.5.1 SSH日志文件2.5.2 Session文件 三、PHP封装伪协…...

飞天使-linux操作的一些技巧与知识点4-ansible常用的技巧,配置等
文章目录 ansible配置文件的优先级尝试开始进行操作ansible常用模块ansible 的playbook示例安装phpplaybook中变量的引用 ansible yum install -y ansible 测试是否可用 ansible localhost -m ping /etc/ansible/ansible.cfg :主配置文件,配置 ansible…...

Stable Diffusion 源码解析(1)
参考1:https://blog.csdn.net/Eric_1993/article/details/129393890 参考2:https://zhuanlan.zhihu.com/p/613337342 1.StableDiffusion基本原理1.1 UNetModel、FrozenCLIP 模型1.2 DDPM、DDIM、PLMS算法 2. Runwayml SD 源码2.1 Img2Img Pipeline2.2 DD…...
java.lang.ClassNotFoundException:javax.xml.bind.DatatypeConverter 报错解决
问题原因: 这有可能是因为SpringBoot项目结合jwt进行用户登录时出现的问题,因为jdk版本太高导致的 解决办法: 方法一: 降低jdk版本 检查JDK版本,如果你是JDK17版本,就降到JDK8版本 方案二:在meven中添加依赖 注意: 如果2.3.1的版本不生效,则使用2.3.0的版本 <…...

Python学习笔记-类
1 定义类 类是函数的集合,class来定义类 pass并没有实际含义,只是为了代码能执行通过,不报错而已,相当于在代码种占一个位置,后续完善 类是对象的加工厂 2.创建对象 carCar()即是创建对象的过程 3、类的成员 3.1 实例…...

了解如何在linux使用podman管理容器
本章主要介绍使用 podman 管理容器。 了解什么是容器,容器和镜像的关系 安装和配置podman 拉取和删除镜像 给镜像打标签 导出和导入镜像 创建和删除镜像 数据卷的使用 管理容器的命令 使用普通用户管理容器 使用普通用户管理容器 对于初学者来说,不太容…...

SQL命令---修改字段的数据类型
介绍 使用sql语句修改字段的数据类型。 命令 alter table 表明 modify 字段名 数据类型;例子 有一张a表,表里有一个id字段,长度为11。使用命令将长度修改为12 下面使用命令进行修改: alter table a modify id int(12) NOT NULL;下面使修…...

一键提取微信聊天记录,生成HTML、Word文档永久保存,还能生成微信年度聊天报告
不知道生活中你有没有遇到过这种情况,聊天记录不完整,有的在手机上,有的在电脑上,搜索起来很烦。那有没有一种办法可以把微信聊天记录统一呢?当然是有的。下面,就让我们一起来看一下怎么操作。 先看效果 操…...

docker使用详解
介绍 Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的Linux或Windows操作系统的机器上,也可以实现虚拟化。 Docker基于轻量级虚拟化技术,整个项目基于Go语言开…...

MidJourney笔记(7)-Seeds
我相信很多人在使用MidJourney的时候,都会遇到一个问题,就是如何保持生成图像的一致性,或者相对一致性,差异性不是很大。此时,我们就需要引入一个seed值,类似给这个提示词生成的图片做一个id标识。 那这个seed值怎么使用? 其实,在我们每次生成的图片,都有有一个seed值…...
pom配置文件重要标签探究
文章目录 dependencies标签dependencyManagement标签两者辨析repositories标签properties标签 dependencies标签 <dependencies>标签用于指定项目的依赖项列表。这些依赖项可以是应用程序代码所需的库,也可以是Spring Boot和其他第三方库。<dependencies&…...

如何在Ubuntu的Linux系统上搭建nacos集群
官方给出的集群部署架构图 集群部署说明 (nacos.io)3个或3个以上nacos节点才能构成集群当前示例中包含3个nacos节点,同时一个负载均衡器代理3个nacos,本示例中负载均衡器可使用的是nginx 准备并安装好正常运行的nginx,本示例略准备并安装好正…...
oracle中的PIVOT函数
在Oracle数据库中,PIVOT 是一个强大的功能,可以将行数据转换为列数据。这在报表和数据分析中非常有用。 基本的 PIVOT 语法如下: SELECT * FROM (SELECT <column1>, <column2>, ..., <pivot_column>, <aggregate_func…...

装饰模式(Decorator Pattern)重构java邮件发奖系统实战
前言 现在我们有个如下的需求,设计一个邮件发奖的小系统, 需求 1.数据验证 → 2. 敏感信息加密 → 3. 日志记录 → 4. 实际发送邮件 装饰器模式(Decorator Pattern)允许向一个现有的对象添加新的功能,同时又不改变其…...

C++初阶-list的底层
目录 1.std::list实现的所有代码 2.list的简单介绍 2.1实现list的类 2.2_list_iterator的实现 2.2.1_list_iterator实现的原因和好处 2.2.2_list_iterator实现 2.3_list_node的实现 2.3.1. 避免递归的模板依赖 2.3.2. 内存布局一致性 2.3.3. 类型安全的替代方案 2.3.…...
大语言模型如何处理长文本?常用文本分割技术详解
为什么需要文本分割? 引言:为什么需要文本分割?一、基础文本分割方法1. 按段落分割(Paragraph Splitting)2. 按句子分割(Sentence Splitting)二、高级文本分割策略3. 重叠分割(Sliding Window)4. 递归分割(Recursive Splitting)三、生产级工具推荐5. 使用LangChain的…...
spring:实例工厂方法获取bean
spring处理使用静态工厂方法获取bean实例,也可以通过实例工厂方法获取bean实例。 实例工厂方法步骤如下: 定义实例工厂类(Java代码),定义实例工厂(xml),定义调用实例工厂ÿ…...
OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别
OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别 直接训练提示词嵌入向量的核心区别 您提到的代码: prompt_embedding = initial_embedding.clone().requires_grad_(True) optimizer = torch.optim.Adam([prompt_embedding...

mysql已经安装,但是通过rpm -q 没有找mysql相关的已安装包
文章目录 现象:mysql已经安装,但是通过rpm -q 没有找mysql相关的已安装包遇到 rpm 命令找不到已经安装的 MySQL 包时,可能是因为以下几个原因:1.MySQL 不是通过 RPM 包安装的2.RPM 数据库损坏3.使用了不同的包名或路径4.使用其他包…...

【Linux手册】探秘系统世界:从用户交互到硬件底层的全链路工作之旅
目录 前言 操作系统与驱动程序 是什么,为什么 怎么做 system call 用户操作接口 总结 前言 日常生活中,我们在使用电子设备时,我们所输入执行的每一条指令最终大多都会作用到硬件上,比如下载一款软件最终会下载到硬盘上&am…...
React从基础入门到高级实战:React 实战项目 - 项目五:微前端与模块化架构
React 实战项目:微前端与模块化架构 欢迎来到 React 开发教程专栏 的第 30 篇!在前 29 篇文章中,我们从 React 的基础概念逐步深入到高级技巧,涵盖了组件设计、状态管理、路由配置、性能优化和企业级应用等核心内容。这一次&…...
土建施工员考试:建筑施工技术重点知识有哪些?
《管理实务》是土建施工员考试中侧重实操应用与管理能力的科目,核心考查施工组织、质量安全、进度成本等现场管理要点。以下是结合考试大纲与高频考点整理的重点内容,附学习方向和应试技巧: 一、施工组织与进度管理 核心目标: 规…...

高效的后台管理系统——可进行二次开发
随着互联网技术的迅猛发展,企业的数字化管理变得愈加重要。后台管理系统作为数据存储与业务管理的核心,成为了现代企业不可或缺的一部分。今天我们要介绍的是一款名为 若依后台管理框架 的系统,它不仅支持跨平台应用,还能提供丰富…...