FFmpeg源代码简单分析-通用-结构体分析-AVPacket

参考链接

  • FFMPEG结构体分析:AVPacket_雷霄骅的博客-CSDN博客_avpacket 

AVPacket

  • AVPacket是存储压缩编码数据相关信息的结构体
  • 结构体的定义位于packet.h
  • 重要参数介绍
    • uint8_t *data:压缩编码的数据。
    • 例如对于H.264来说。1个AVPacket的data通常对应一个NAL。
    • 注意:在这里只是对应,而不是一模一样。他们之间有微小的差别:使用FFMPEG类库分离出多媒体文件中的H.264码流
    • 因此在使用FFMPEG进行视音频处理的时候,常常可以将得到的AVPacket的data数据直接写成文件,从而得到视音频的码流文件。
    • int   size:data的大小
    • int64_t pts:显示时间戳
    • int64_t dts:解码时间戳
    • int   stream_index:标识该AVPacket所属的视频/音频流。

代码

/*** This structure stores compressed data. It is typically exported by demuxers* and then passed as input to decoders, or received as output from encoders and* then passed to muxers.* 此结构存储压缩数据。它通常由解复用器导出,然后作为输入传递给解码器,或者作为输出从编码器接收,然后传递给复用器。* For video, it should typically contain one compressed frame. For audio it may* contain several compressed frames. Encoders are allowed to output empty* packets, with no compressed data, containing only side data* (e.g. to update some stream parameters at the end of encoding).* 对于视频,它通常应包含一个压缩帧。对于音频,它可能包含几个压缩帧。* 编码器被允许输出空包,没有压缩数据,只包含边数据(例如,在编码结束时更新一些流参数)** The semantics of data ownership depends on the buf field.* If it is set, the packet data is dynamically allocated and is* valid indefinitely until a call to av_packet_unref() reduces the* reference count to 0.* 数据所有权的语义取决于 buf 字段。* 如果已设置,则数据包数据是动态分配的,并且无限期有效,直到调用 av_packet_unref() 将引用计数减少到 0** If the buf field is not set av_packet_ref() would make a copy instead* of increasing the reference count.* 如果未设置 buf 字段,av_packet_ref() 将进行复制而不是增加引用计数** The side data is always allocated with av_malloc(), copied by* av_packet_ref() and freed by av_packet_unref().* 边数据总是用 av_malloc() 分配的,由av_packet_ref() 并由 av_packet_unref() 释放* * sizeof(AVPacket) being a part of the public ABI is deprecated. once* av_init_packet() is removed, new packets will only be able to be allocated* with av_packet_alloc(), and new fields may be added to the end of the struct* with a minor bump.* sizeof(AVPacket) 作为公共 ABI 的一部分已被弃用。一次av_init_packet() 被删除,* 新的数据包只能用 av_packet_alloc() 分配,新的字段可能会被添加到结构的末尾,但会有轻微的凸起。** @see av_packet_alloc* @see av_packet_ref* @see av_packet_unref*/
typedef struct AVPacket {/*** A reference to the reference-counted buffer where the packet data is* stored. //对存储数据包数据的引用计数缓冲区的引用* May be NULL, then the packet data is not reference-counted.* 可能为 NULL,则数据包数据不被引用计数*/AVBufferRef *buf;/*** Presentation timestamp in AVStream->time_base units; the time at which* the decompressed packet will be presented to the user.* 以 AVStream->time_base 单位表示的时间戳; 解压后的数据包将呈现给用户的时间* Can be AV_NOPTS_VALUE if it is not stored in the file.* 如果未存储在文件中,则可以是 AV_NOPTS_VALUE* pts MUST be larger or equal to dts as presentation cannot happen before* decompression, unless one wants to view hex dumps. Some formats misuse* the terms dts and pts/cts to mean something different. Such timestamps* must be converted to true pts/dts before they are stored in AVPacket.* pts 必须大于或等于 dts,因为在解压缩之前无法进行演示,除非想要查看十六进制转储* 某些格式滥用术语 dts 和 pts/cts 来表示不同的含义。 这样的时间戳必须转换为真正的 pts/dts 才能存储在 AVPacket 中*/int64_t pts;/*** Decompression timestamp in AVStream->time_base units; the time at which* the packet is decompressed. //AVStream->time_base 单位的解压时间戳; 数据包解压缩的时间* Can be AV_NOPTS_VALUE if it is not stored in the file. //如果没有存储在文件中,可以是 AV_NOPTS_VALUE*/int64_t dts;uint8_t *data;int   size;int   stream_index;/*** A combination of AV_PKT_FLAG values*/int   flags;/*** Additional packet data that can be provided by the container. //容器可以提供的附加数据包数据* Packet can contain several types of side information. //数据包可以包含多种类型的边信息*/AVPacketSideData *side_data;int side_data_elems;/*** Duration of this packet in AVStream->time_base units, 0 if unknown. //此数据包的持续时间以 AVStream->time_base 为单位,如果未知则为 0* Equals next_pts - this_pts in presentation order. //等于 next_pts - this_pts 按呈现顺序*/int64_t duration;int64_t pos;                            ///< byte position in stream, -1 if unknown/*** for some private data of the user //对于用户的一些私人数据*/void *opaque;/*** AVBufferRef for free use by the API user. FFmpeg will never check the* contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when* the packet is unreferenced. av_packet_copy_props() calls create a new* reference with av_buffer_ref() for the target packet's opaque_ref field.* AVBufferRef 供 API 用户免费使用。 FFmpeg 永远不会检查缓冲区引用的内容。* 当数据包未被引用时,FFmpeg 在其上调用 av_buffer_unref()* av_packet_copy_props() 调用使用 av_buffer_ref() 为目标数据包的 opaque_ref 字段创建一个新引用* This is unrelated to the opaque field, although it serves a similar purpose.* 这与不透明字段无关,尽管它具有类似的目的* */AVBufferRef *opaque_ref;
。/*** Time base of the packet's timestamps. //数据包时间戳的时基* In the future, this field may be set on packets output by encoders or* demuxers, but its value will be by default ignored on input to decoders* or muxers.* 将来,此字段可能会在编码器或解复用器输出的数据包上设置,但默认情况下,* 在解码器或复用器的输入上将忽略其值*/AVRational time_base;
} AVPacket;

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/445985.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

h5支付不能打开支付宝 ios_iOS WKWebview中无法调起支付宝/微信客户端支付问题的解决方法...

这两个的解决思路都是要在下面这个方法中先拦截相应的url&#xff0c;再单独处理- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler;支付宝…

解决Github图片加载失败

问题描述 浏览自己Github某仓库的README.md内时&#xff0c;发现文档的图片始终加载不出&#xff0c;打开浏览器后台&#xff0c;冒出一片红&#xff0c;Failed to load resource: net::ERR_CONNECTION_RESET&#xff0c;如下图所示&#xff1a; 问题分析 可能造成这问题的原…

FFmpeg源代码简单分析-通用-结构体分析-AVFrame

参考链接 FFMPEG结构体分析&#xff1a;AVFrame_雷霄骅的博客-CSDN博客 AVFrame AVFrame是包含码流参数较多的结构体结构体的定义位于frame.hAVFrame结构体一般用于存储原始数据&#xff08;即非压缩数据&#xff0c;例如对视频来说是YUV&#xff0c;RGB&#xff0c;对音频来…

python 求子字符串_(6)KMP算法(求子串的位置)______字符串的匹配

问题&#xff1a;已知字符串 B 是字符串 A 的一个子串,问字符串 B 在字符串 A 的第一次出现位置.暴力方法:从 A 字符串 的每个位置开始对字符串 B 进行匹配. 这种方法根据数据的不同 复杂度不同最高可以达到O( m*n ). (m,n分别为两个字符串的长度)KMP算法&#xff1a;我们先来看…

用Python将多张图片合并成一PDF文件

先前条件 需要安装两模块&#xff1a;fpdf、PIL pip install fpdfpip install PIL 放码过来 from fpdf import FPDF from PIL import Image import osdef makePdf(pdfFileName, listPages):cover Image.open(listPages[0])width, height cover.sizepdf FPDF(unit "…

FFmpeg源代码简单分析-通用-结构体分析-关键结构体之间的关系

参考链接 FFMPEG中最关键的结构体之间的关系_雷霄骅的博客-CSDN博客_ffmpeg 结构体关系 最关键的结构体可以分成以下几类&#xff1a; 解协议&#xff08;http,rtsp,rtmp,mms&#xff09; AVIOContext&#xff0c;URLProtocol&#xff0c;URLContext主要存储视音频使用的协…

用Python下载文件

前提条件 需要事先安装requests模块&#xff1a; pip install requests 放码过来 import requestsurl XXX #文件下载来源URL filename #下载到本地后新文件名 r requests.get(url) with open(filename, "wb") as code:code.write(r.content)实战演习 从目标…

distenct oracle_Oracle的distinct关键字

distinct关键字用于从查询的结果集中筛选出唯一值的记录。我们通过示例来介绍distinct关键字的用法。一、生成测试数据用以下SQL创建超女基本信息表(T_GIRL)&#xff0c;插入一些测试数据。create table T_GIRL(id char(4) not null, -- 编号name varchar2(30) not null, -- 姓…

FFmpeg源代码简单分析-通用-常见结构体的初始化和销毁(AVFormatContext,AVFrame等)

参考链接 FFmpeg源代码简单分析&#xff1a;常见结构体的初始化和销毁&#xff08;AVFormatContext&#xff0c;AVFrame等&#xff09;_雷霄骅的博客-CSDN博客 结构体 AVFormatContext&#xff1a;统领全局的基本结构体。主要用于处理封装格式&#xff08;FLV/MKV/RMVB等&…

python中object转为float_object格式怎样无损转换成float64格式

这次给大家带来object格式怎样无损转换成float64格式&#xff0c;object格式无损转换成float64格式的注意事项有哪些&#xff0c;下面就是实战案例&#xff0c;一起来看一下。在数据处理过程中比如从CSV文件中导入数据data_df pd.read_csv("names.csv")在处理之前一…

FFmpeg源代码简单分析-通用-avio_open2()

参考链接 FFmpeg源代码简单分析&#xff1a;avio_open2()_雷霄骅的博客-CSDN博客_avio_open avio_open2() 该函数用于打开FFmpeg的输入输出文件avio_open2()的声明位于libavformat\avio.h文件中&#xff0c;如下所示。 /*** Create and initialize a AVIOContext for accessi…

用Tomcat构建一个简单图片服务器

前提条件 Tomcat 7.0.90 方法一&#xff1a;修改配置文件 在TOMCAT_HOME/conf/server.xml配置文件内的<Host>内添加一子标签&#xff1a; <Context docBase"C:\exambase\" path"/img"/>方法二&#xff1a;添加Servlet 新建一应用&#xf…

flash静态的农夫走路_健身神动作——你不知道的“农夫行走”

原标题&#xff1a;健身神动作——你不知道的“农夫行走”本期导读握力是训练中及其重要的一环&#xff0c;强大的握力会使你的训练效果MAX&#xff0c;就像开了加速器一样&#xff01;很多人把握力和前臂力量混为一谈&#xff0c;主要使用腕弯举提高握力。实际上&#xff0c;握…

FFmpeg源代码简单分析-通用-av_find_decoder()和av_find_encoder()

参考链接 FFmpeg源代码简单分析&#xff1a;av_find_decoder()和av_find_encoder()_雷霄骅的博客-CSDN博客_avcodec_find_encoder avcodec_find_encoder avcodec_find_encoder()用于查找FFmpeg的编码器avcodec_find_encoder()的声明位于libavcodec\codec.h 版本差异avcode…

用Java的Set实现交并差等集合运算

放码过来 package com.lun.util;import java.util.HashSet; import java.util.Set;public class SetUtils {public static <T> Set<T> union(Set<T> setA, Set<T> setB) {Set<T> tmp new HashSet<T>(setA);tmp.addAll(setB);return tmp;…

post方法就反回了一个string字符串前台怎么接_Golang Web入门(2):如何实现一个RESTful风格的路由...

摘要在上一篇文章中&#xff0c;我们聊了聊在Golang中怎么实现一个Http服务器。但是在最后我们可以发现&#xff0c;固然DefaultServeMux可以做路由分发的功能&#xff0c;但是他的功能同样是不完善的。由DefaultServeMux做路由分发&#xff0c;是不能实现RESTful风格的API的&a…

FFmpeg源代码简单分析-通用-avcodec_open2()

参考链接 FFmpeg源代码简单分析&#xff1a;avcodec_open2()_雷霄骅的博客-CSDN博客 avcodec_open2() 该函数用于初始化一个音视频编解码器的AVCodecContextavcodec_open2()的声明位于libavcodec\avcodec.h&#xff0c;如下所示。 /*** Initialize the AVCodecContext to use…

统计MySQL中某数据库硬盘占用量大小

放码过来 select TABLE_NAME, concat(truncate(data_length/1024/1024,2), MB) as data_size, concat(truncate(index_length/1024/1024,2), MB) as index_size from information_schema.tables where TABLE_SCHEMA your_db_name order by data_length desc;运行结果 参考…

halcon 相似度_Halcon分类函数,shape模型

《zw版Halcon-delphi系列原创教程》 Halcon分类函数013,shape模型为方便阅读&#xff0c;在不影响说明的前提下&#xff0c;笔者对函数进行了简化&#xff1a;:: 用符号“**”&#xff0c;替换&#xff1a;“procedure”:: 用大写字母“X”&#xff0c;替换&#xff1a;“IHUnt…

用Python将文件夹打包成Zip并备份至U盘

需求概要 将maven工程打包并备份至U盘。为了简单起见&#xff0c;只需备份工程中的src文件夹和pom.xml文件即可。 放码过来 import os import zipfile import datetime import shutilnowTimeStr datetime.datetime.now().strftime("%Y%m%d%H%M") newZipFileName …