当前位置: 首页 > news >正文

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进行用户登录时出现的问题&#xff0c;因为jdk版本太高导致的 解决办法: 方法一: 降低jdk版本 检查JDK版本,如果你是JDK17版本,就降到JDK8版本 方案二:在meven中添加依赖 注意: 如果2.3.1的版本不生效,则使用2.3.0的版本 <…...

Python学习笔记-类

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

了解如何在linux使用podman管理容器

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

SQL命令---修改字段的数据类型

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

一键提取微信聊天记录,生成HTML、Word文档永久保存,还能生成微信年度聊天报告

不知道生活中你有没有遇到过这种情况&#xff0c;聊天记录不完整&#xff0c;有的在手机上&#xff0c;有的在电脑上&#xff0c;搜索起来很烦。那有没有一种办法可以把微信聊天记录统一呢&#xff1f;当然是有的。下面&#xff0c;就让我们一起来看一下怎么操作。 先看效果 操…...

docker使用详解

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

MidJourney笔记(7)-Seeds

我相信很多人在使用MidJourney的时候,都会遇到一个问题,就是如何保持生成图像的一致性,或者相对一致性,差异性不是很大。此时,我们就需要引入一个seed值,类似给这个提示词生成的图片做一个id标识。 那这个seed值怎么使用? 其实,在我们每次生成的图片,都有有一个seed值…...

pom配置文件重要标签探究

文章目录 dependencies标签dependencyManagement标签两者辨析repositories标签properties标签 dependencies标签 <dependencies>标签用于指定项目的依赖项列表。这些依赖项可以是应用程序代码所需的库&#xff0c;也可以是Spring Boot和其他第三方库。<dependencies&…...

如何在Ubuntu的Linux系统上搭建nacos集群

官方给出的集群部署架构图 集群部署说明 (nacos.io)3个或3个以上nacos节点才能构成集群当前示例中包含3个nacos节点&#xff0c;同时一个负载均衡器代理3个nacos&#xff0c;本示例中负载均衡器可使用的是nginx 准备并安装好正常运行的nginx&#xff0c;本示例略准备并安装好正…...

oracle中的PIVOT函数

在Oracle数据库中&#xff0c;PIVOT 是一个强大的功能&#xff0c;可以将行数据转换为列数据。这在报表和数据分析中非常有用。 基本的 PIVOT 语法如下&#xff1a; SELECT * FROM (SELECT <column1>, <column2>, ..., <pivot_column>, <aggregate_func…...

【网络】每天掌握一个Linux命令 - iftop

在Linux系统中&#xff0c;iftop是网络管理的得力助手&#xff0c;能实时监控网络流量、连接情况等&#xff0c;帮助排查网络异常。接下来从多方面详细介绍它。 目录 【网络】每天掌握一个Linux命令 - iftop工具概述安装方式核心功能基础用法进阶操作实战案例面试题场景生产场景…...

地震勘探——干扰波识别、井中地震时距曲线特点

目录 干扰波识别反射波地震勘探的干扰波 井中地震时距曲线特点 干扰波识别 有效波&#xff1a;可以用来解决所提出的地质任务的波&#xff1b;干扰波&#xff1a;所有妨碍辨认、追踪有效波的其他波。 地震勘探中&#xff0c;有效波和干扰波是相对的。例如&#xff0c;在反射波…...

Linux链表操作全解析

Linux C语言链表深度解析与实战技巧 一、链表基础概念与内核链表优势1.1 为什么使用链表&#xff1f;1.2 Linux 内核链表与用户态链表的区别 二、内核链表结构与宏解析常用宏/函数 三、内核链表的优点四、用户态链表示例五、双向循环链表在内核中的实现优势5.1 插入效率5.2 安全…...

相机Camera日志实例分析之二:相机Camx【专业模式开启直方图拍照】单帧流程日志详解

【关注我&#xff0c;后续持续新增专题博文&#xff0c;谢谢&#xff01;&#xff01;&#xff01;】 上一篇我们讲了&#xff1a; 这一篇我们开始讲&#xff1a; 目录 一、场景操作步骤 二、日志基础关键字分级如下 三、场景日志如下&#xff1a; 一、场景操作步骤 操作步…...

可靠性+灵活性:电力载波技术在楼宇自控中的核心价值

可靠性灵活性&#xff1a;电力载波技术在楼宇自控中的核心价值 在智能楼宇的自动化控制中&#xff0c;电力载波技术&#xff08;PLC&#xff09;凭借其独特的优势&#xff0c;正成为构建高效、稳定、灵活系统的核心解决方案。它利用现有电力线路传输数据&#xff0c;无需额外布…...

学校招生小程序源码介绍

基于ThinkPHPFastAdminUniApp开发的学校招生小程序源码&#xff0c;专为学校招生场景量身打造&#xff0c;功能实用且操作便捷。 从技术架构来看&#xff0c;ThinkPHP提供稳定可靠的后台服务&#xff0c;FastAdmin加速开发流程&#xff0c;UniApp则保障小程序在多端有良好的兼…...

新能源汽车智慧充电桩管理方案:新能源充电桩散热问题及消防安全监管方案

随着新能源汽车的快速普及&#xff0c;充电桩作为核心配套设施&#xff0c;其安全性与可靠性备受关注。然而&#xff0c;在高温、高负荷运行环境下&#xff0c;充电桩的散热问题与消防安全隐患日益凸显&#xff0c;成为制约行业发展的关键瓶颈。 如何通过智慧化管理手段优化散…...

C++中string流知识详解和示例

一、概览与类体系 C 提供三种基于内存字符串的流&#xff0c;定义在 <sstream> 中&#xff1a; std::istringstream&#xff1a;输入流&#xff0c;从已有字符串中读取并解析。std::ostringstream&#xff1a;输出流&#xff0c;向内部缓冲区写入内容&#xff0c;最终取…...

JUC笔记(上)-复习 涉及死锁 volatile synchronized CAS 原子操作

一、上下文切换 即使单核CPU也可以进行多线程执行代码&#xff0c;CPU会给每个线程分配CPU时间片来实现这个机制。时间片非常短&#xff0c;所以CPU会不断地切换线程执行&#xff0c;从而让我们感觉多个线程是同时执行的。时间片一般是十几毫秒(ms)。通过时间片分配算法执行。…...

【HarmonyOS 5 开发速记】如何获取用户信息(头像/昵称/手机号)

1.获取 authorizationCode&#xff1a; 2.利用 authorizationCode 获取 accessToken&#xff1a;文档中心 3.获取手机&#xff1a;文档中心 4.获取昵称头像&#xff1a;文档中心 首先创建 request 若要获取手机号&#xff0c;scope必填 phone&#xff0c;permissions 必填 …...