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…...

【经验分享】gemini-pro和gemini-pro-vision使用体验
Gemini Gemini已经对开发者开放了Gemini Pro的使用权限,目前对大家都是免费的,每分钟限制60条,至少这比起CloseAI的每个账户5刀限速1min3条要香的多,目前已于第一时间进行了体验 一句话总结,google很大方,但…...

JS冒泡排序
想必大家都多多少少了解过一点排序,让我为大家介绍一下冒泡排序吧! 假设我们现在有一个数组[2,4,3,5,1] 我们来分析一下: 1.一共需要的趟数 我们用外层for循环 5个数据我们一共需要走4躺 长度就…...

面向遥感图像的道路区域提取及优化
一、论文2017 (1)DeepRoadMapper (2)Topology Loss2018 (1)RoadTracer (2)iterative-deep-learning2019 (1)Leveraging Crowdsourced GPS Data for Road Extraction from Aerial Imagery (2)RoadNet (3)RoadTagger (4)Generative Graph Transformer (5)road_…...

mysql中NULL值
mysql中NULL值表示“没有值”,它跟空字符串""是不同的 例如,执行下面两个插入记录的语句: insert into test_table (description) values (null); insert into test_table (description) values ();执行以后,查看表的…...

[c++] 意识需要转变的一个例子,全局变量的构造函数先于main执行
最近还遇到一个例子是关于:从C转C开发需要注意的一个意识问题。本人遇到的这个问题是,带着C的意识来看C的代码,然后根据代码看,有一个全局变量的值在main函数进入之后才会更改,所以百思不得其解,这个变量怎…...

VSCode 配置自动生成头文件
相关文章 VSCode 开发C/C实用插件分享——codegeex VSCode 开发C/C实用插件分享——koroFileHeader VSCode 配置自动生成头文件 一、snippets二、配置步骤三、效果展示 一、snippets 相信大家对C、C都头文件都不陌生,都会发现每个头文件都会包括下面的这些格式&…...

【大数据】Hudi 核心知识点详解(一)
😊 如果您觉得这篇文章有用 ✔️ 的话,请给博主一个一键三连 🚀🚀🚀 吧 (点赞 🧡、关注 💛、收藏 💚)!!!您的支持 &#x…...

windows上抓包出现大包未分片以及关闭tso方法
wireshark抓包中会有大数据包(未分片包)和ip校验和不对的包,问题根因在目前很多电脑网卡支持TSO和将校验和计算到网卡上,导致抓出数据包未分片 详细文章看: https://www.cnblogs.com/charlieroro/p/11363336.html 目前很多网卡已…...

Leetcode 2454. 下一个更大元素 IV
Leetcode 2454. 下一个更大元素 IV题目 给你一个下标从 0 开始的非负整数数组 nums 。对于 nums 中每一个整数,你必须找到对应元素的 第二大 整数。如果 nums[j] 满足以下条件,那么我们称它为 nums[i] 的 第二大 整数: j >nums[j] > nu…...

浏览器全屏按键同f11效果
模拟键f11 // for IE,这里和fullScreen相同,模拟按下F11键退出全屏 let wscript new ActiveXObject(WScript.Shell) if (wscript ! null) {wscript.SendKeys({F11}) }同f11键效果生效全屏函数 //判断是否是全屏状态 var isFull Math.abs(window.scree…...