FMPEG结构体分析:AVStream
注:写了一系列的结构体的分析的文章,在这里列一个列表:
FFMPEG结构体分析:AVStream
FFMPEG结构体分析:AVPacket
FFMPEG有几个最重要的结构体,包含了解协议,解封装,解码操作,此前已经进行过分析:
在此不再详述,其中AVStream是存储每一个视频/音频流信息的结构体。本文将会分析一下该结构体里重要变量的含义和作用。
首先看一下结构体的定义(位于avformat.h文件中):
- /* 雷霄骅
- * 中国传媒大学/数字电视技术
- * leixiaohua1020@126.com
- *
- */
- /**
- * Stream structure.
- * New fields can be added to the end with minor version bumps.
- * Removal, reordering and changes to existing fields require a major
- * version bump.
- * sizeof(AVStream) must not be used outside libav*.
- */
- typedef struct AVStream {
- int index; /**< stream index in AVFormatContext */
- /**
- * Format-specific stream ID.
- * decoding: set by libavformat
- * encoding: set by the user
- */
- int id;
- AVCodecContext *codec; /**< codec context */
- /**
- * Real base framerate of the stream.
- * This is the lowest framerate with which all timestamps can be
- * represented accurately (it is the least common multiple of all
- * framerates in the stream). Note, this value is just a guess!
- * For example, if the time base is 1/90000 and all frames have either
- * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
- */
- AVRational r_frame_rate;
- void *priv_data;
- /**
- * encoding: pts generation when outputting stream
- */
- struct AVFrac pts;
- /**
- * This is the fundamental unit of time (in seconds) in terms
- * of which frame timestamps are represented. For fixed-fps content,
- * time base should be 1/framerate and timestamp increments should be 1.
- * decoding: set by libavformat
- * encoding: set by libavformat in av_write_header
- */
- AVRational time_base;
- /**
- * Decoding: pts of the first frame of the stream in presentation order, in stream time base.
- * Only set this if you are absolutely 100% sure that the value you set
- * it to really is the pts of the first frame.
- * This may be undefined (AV_NOPTS_VALUE).
- * @note The ASF header does NOT contain a correct start_time the ASF
- * demuxer must NOT set this.
- */
- int64_t start_time;
- /**
- * Decoding: duration of the stream, in stream time base.
- * If a source file does not specify a duration, but does specify
- * a bitrate, this value will be estimated from bitrate and file size.
- */
- int64_t duration;
- int64_t nb_frames; ///< number of frames in this stream if known or 0
- int disposition; /**< AV_DISPOSITION_* bit field */
- enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
- /**
- * sample aspect ratio (0 if unknown)
- * - encoding: Set by user.
- * - decoding: Set by libavformat.
- */
- AVRational sample_aspect_ratio;
- AVDictionary *metadata;
- /**
- * Average framerate
- */
- AVRational avg_frame_rate;
- /**
- * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet
- * will contain the attached picture.
- *
- * decoding: set by libavformat, must not be modified by the caller.
- * encoding: unused
- */
- AVPacket attached_pic;
- /*****************************************************************
- * All fields below this line are not part of the public API. They
- * may not be used outside of libavformat and can be changed and
- * removed at will.
- * New public fields should be added right above.
- *****************************************************************
- */
- /**
- * Stream information used internally by av_find_stream_info()
- */
- #define MAX_STD_TIMEBASES (60*12+5)
- struct {
- int64_t last_dts;
- int64_t duration_gcd;
- int duration_count;
- double duration_error[2][2][MAX_STD_TIMEBASES];
- int64_t codec_info_duration;
- int nb_decoded_frames;
- int found_decoder;
- } *info;
- int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
- // Timestamp generation support:
- /**
- * Timestamp corresponding to the last dts sync point.
- *
- * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
- * a DTS is received from the underlying container. Otherwise set to
- * AV_NOPTS_VALUE by default.
- */
- int64_t reference_dts;
- int64_t first_dts;
- int64_t cur_dts;
- int64_t last_IP_pts;
- int last_IP_duration;
- /**
- * Number of packets to buffer for codec probing
- */
- #define MAX_PROBE_PACKETS 2500
- int probe_packets;
- /**
- * Number of frames that have been demuxed during av_find_stream_info()
- */
- int codec_info_nb_frames;
- /**
- * Stream Identifier
- * This is the MPEG-TS stream identifier +1
- * 0 means unknown
- */
- int stream_identifier;
- int64_t interleaver_chunk_size;
- int64_t interleaver_chunk_duration;
- /* av_read_frame() support */
- enum AVStreamParseType need_parsing;
- struct AVCodecParserContext *parser;
- /**
- * last packet in packet_buffer for this stream when muxing.
- */
- struct AVPacketList *last_in_packet_buffer;
- AVProbeData probe_data;
- #define MAX_REORDER_DELAY 16
- int64_t pts_buffer[MAX_REORDER_DELAY+1];
- AVIndexEntry *index_entries; /**< Only used if the format does not
- support seeking natively. */
- int nb_index_entries;
- unsigned int index_entries_allocated_size;
- /**
- * flag to indicate that probing is requested
- * NOT PART OF PUBLIC API
- */
- int request_probe;
- } AVStream;
AVStream重要的变量如下所示:
int index:标识该视频/音频流
AVCodecContext *codec:指向该视频/音频流的AVCodecContext(它们是一一对应的关系)
AVRational time_base:时基。通过该值可以把PTS,DTS转化为真正的时间。FFMPEG其他结构体中也有这个字段,但是根据我的经验,只有AVStream中的time_base是可用的。PTS*time_base=真正的时间
int64_t duration:该视频/音频流长度
AVDictionary *metadata:元数据信息
AVRational avg_frame_rate:帧率(注:对视频来说,这个挺重要的)
AVPacket attached_pic:附带的图片。比如说一些MP3,AAC音频文件附带的专辑封面。
该结构体其他字段的作用目前还有待于探索。
FMPEG结构体分析:AVStream的更多相关文章
- FFMPEG结构体分析:AVStream
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...
- FFMPEG结构体分析:AVPacket
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...
- FFMPEG结构体分析:AVCodec
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...
- FFMPEG结构体分析:AVIOContext
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...
- FFMPEG结构体分析:AVCodecContext
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...
- FFMPEG结构体分析:AVFormatContext
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrameFFMPEG结构体分析:AVFormatContextFFMPEG结构体分析:AVCodecContext ...
- FFMPEG结构体分析:AVFrame
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrameFFMPEG结构体分析:AVFormatContextFFMPEG结构体分析:AVCodecContext ...
- FFmpeg: AVFormatContext 结构体分析
AVFormatContext 结构体分析这个结构体描述了一个媒体文件或媒体流的构成和基本信息.这是FFMpeg中最为基本的一个结构,是其他所有结构的根,是一个多媒体文件或流的根本抽象.主要成员释义: ...
- FFMPEG结构体分析:AVCodecContext(转)
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrameFFMPEG结构体分析:AVFormatContextFFMPEG结构体分析:AVCodecContext ...
随机推荐
- 你好,babel
写在前面 其实学babel是本人2019年Q3的一个计划,因为当时自己做的一个项目需要自己去配babel,也遇到了一些困难,发现自己对babel的了解还是很少的,所以决定好好看下babel:可是后来解 ...
- Ceph14.2.5 RBD块存储的实战配置和详细介绍,不看后悔! -- <3>
Ceph RBD介绍与使用 RBD介绍 RBD即RADOS Block Device的简称,RBD块存储是最稳定且最常用的存储类型.RBD块设备类似磁盘可以被挂载. RBD块设备具有快照.多副本.克隆 ...
- CSRF绕过后端Referer校验
CSRF绕过后端Referer校验分正常情况和不正常的情况,我们这里主要讨论开发在写校验referer程序时,不正常的情况下怎么进行绕过. 正常情况 正常的情况指服务器端校验Referer的代码没毛病 ...
- C#录制视频
这是一个使用C#语言制作的录制框架,支持录制桌面,多屏,声音,摄像头,某个应用程序的界面 1.安装 使用此框架需要安装扩展包Kogel.Record,可以Nuget上搜索 或者使用Nuget命令 In ...
- Django之models字段属性
目录 常用字段 AutoField IntegerField CharField 自定义及使用char DateField DateTimeField 字段合集 字段参数 null unique db ...
- [转载] Windows系统批处理延迟方法
小贴士:方法四 亲测有效,因为当时对于精确度要求不是很高,所以没有具体测试它的精确度.其他方法没有测过,用到的时候再测吧! 批处理延时启动的几个方法 方法一:ping 缺点:时间精度为1秒,不够精确 ...
- shell学习-常用语句
为什么使用shell 可以快速.简单的完成编程,实现自己的想法.Shell非常适合编写小的工具,因为小工具更强调的是易于配置.维护.移植等,而不是执行效率. 当自己的想法确实有必要进行优化,有必要让它 ...
- 读取配置文件,appsettings.json和注入ICO
https://www.cnblogs.com/knowledgesea/p/7079880.html 引入Nuget的两个类库 Microsoft.Extensions.Configuration ...
- vue学习笔记3: 动态绑定
一.知识点 动态绑定: vue-class: 三目写法 对象写法 数组写法 vue-style: 三目写法 对象写法 数组写法 二.代码示例 1. vue-class vue-class三目写法 &l ...
- 洛谷 P1463 [POI2002][HAOI2007]反素数
题目链接 题目描述 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4. 如果某个正整数x满足:g(x)>g(i) 0<i<x,则称x为反质数.例如,整数1, ...