说明 :将 avfromatContext 的变量依次打印分析,根据ffmpeg 给的说明,猜测,结合网上的文章字节写测试代码分析二。
37 AVInputFormat *iformat;
/**
* The input container format.
*
* Demuxing only, set by avformat_open_input().
*/
ff_const59 struct AVInputFormat *iformat;
AVInputFormat 再分析-CSDN博客
38 AVFormatInternal *internal; 对开发者隐藏,但是对于阅读ffmpeg源码有用。
/**
* An opaque field for libavformat internal usage.
* Must not be accessed in any way by callers.
*/
AVFormatInternal *internal;
*libavformat内部使用的不透明字段。
*使用不得以任何方式访问。
AVFormatContext 中的 AVFormatInternal *internal
字段是 FFmpeg 内部用于存储与解封装/封装过程相关的私有状态数据的结构体7。以下是其核心特性的总结:
1. 设计目的
- 内部数据隔离:
internal
封装了AVFormatContext
运行时的临时状态和中间数据,避免用户直接操作导致的结构不稳定或版本兼容性问题7。 - 模块化扩展:通过独立结构体管理内部状态,方便 FFmpeg 在不同版本中扩展或修改内部实现逻辑,而无需修改
AVFormatContext
的公开接口7。
2. 关键特性
-
不透明性:
AVFormatInternal
的具体定义未在公共头文件(如avformat.h
)中公开,开发者无法直接访问其内部字段7。- 所有操作需通过 FFmpeg 提供的 API 完成(如
avformat_open_input()
、av_read_frame()
等)78。
-
生命周期管理:
internal
的内存分配与释放由 FFmpeg 内部自动完成,用户无需手动干预(例如在调用avformat_close_input()
时会自动清理)7。- 初始化时,
internal
通常通过avformat_alloc_context()
函数间接创建7。
3. 关联功能
- 流探测缓冲:缓存输入数据的部分内容,用于格式探测(如
avformat_find_stream_info()
中的流参数分析)8。 - 中间状态存储:
- 封装/解封装过程中的临时数据包队列3。
- 时间戳校正、流交错(interleaving)等算法所需的上下文信息38。
4. 开发者注意事项
- 禁止直接访问:由于 FFmpeg 不保证
AVFormatInternal
的跨版本二进制兼容性,直接操作其字段可能导致程序崩溃或未定义行为7。 - 调试限制:若需调试内部状态,通常需结合 FFmpeg 源码中的日志输出或使用调试器跟踪相关函数调用7。
与类似字段的对比
字段 | 作用域 | 可见性 | 管理方式 |
---|---|---|---|
priv_data | 格式私有数据 | 半公开(需API) | 由 AVInputFormat/AVOutputFormat 管理14 |
internal | 全局运行时 | 完全内部 | FFmpeg 内部自动管理7 |
此设计模式体现了 FFmpeg 对“接口稳定”和“实现灵活”的平衡,确保用户仅通过规范 API 即可安全使用核心功能78。
39.AVIOInterruptCB interrupt_callback
/**
* Custom interrupt callbacks for the I/O layer.
*
* demuxing: set by the user before avformat_open_input().
* muxing: set by the user before avformat_write_header()
* (mainly useful for AVFMT_NOFILE formats). The callback
* should also be passed to avio_open2() if it's used to
* open the file.
*/
AVIOInterruptCB interrupt_callback;
/**
* Callback for checking whether to abort blocking functions.
* AVERROR_EXIT is returned in this case by the interrupted
* function. During blocking operations, callback is called with
* opaque as parameter. If the callback returns 1, the
* blocking operation will be aborted.
*
* No members can be added to this struct without a major bump, if
* new elements have been added after this struct in AVFormatContext
* or AVIOContext.
*/
typedef struct AVIOInterruptCB {
int (*callback)(void*);
void *opaque;
} AVIOInterruptCB;
AVFormatContext 中的 interrupt_callback
字段用于实现自定义 I/O 中断控制机制,主要解决网络流处理时的阻塞问题。以下是其核心功能与使用方法的总结:
1. 功能与作用
- 阻塞中断:在
avformat_open_input()
或av_read_frame()
等操作中,若因网络延迟、设备断开或无数据导致长时间阻塞,可通过回调函数强制终止等待12。 - 超时控制:允许开发者设置最大等待时间,避免程序无响应(如 RTSP 流超时断开)48。
- 跨协议兼容:适用于 RTSP、RTMP 等网络协议,弥补某些协议(如 RTMP)不支持超时参数的缺陷16。
2. 结构体定义
interrupt_callback
是 AVFormatContext
的成员,类型为 AVIOInterruptCB
,包含两个关键字段:
-
callback
:函数指针,指向用户定义的中断检测函数。 -
opaque
:用户自定义的上下文指针(如对象实例、计时器等),传递给回调函数。
typedef struct AVIOInterruptCB {int (*callback)(void*); // 中断检测函数void *opaque; // 用户上下文数据
} AVIOInterruptCB;
3. 回调函数实现
回调函数需返回 1
(中断) 或 0
(继续等待)。典型实现逻辑:
- 通过
opaque
获取上下文数据(如超时起始时间)。 - 计算当前时间与起始时间的差值。
- 若超过预设阈值(如 5 秒),返回
1
终止操作。
// 示例:超时检测回调
int interrupt_cb(void *ctx) {int64_t start_time = *(int64_t*)ctx; // 通过 opaque 传递起始时间int64_t current_time = av_gettime(); // 获取当前时间(微秒)return (current_time - start_time > 5000000) ? 1 : 0; // 超过5秒则中断
}
4. 设置步骤
- 分配上下文:创建
AVFormatContext
实例。 - 绑定回调:设置
interrupt_callback
的callback
和opaque
。 - 启动计时:在关键操作前记录起始时间(如
av_gettime()
)。 - 打开输入流:调用
avformat_open_input()
,阻塞操作将触发回调检测。
AVFormatContext *fmt_ctx = avformat_alloc_context();
int64_t timeout_start = av_gettime(); // 记录起始时间// 设置回调函数及上下文
fmt_ctx->interrupt_callback.callback = interrupt_cb;
fmt_ctx->interrupt_callback.opaque = &timeout_start;// 打开输入流(如 RTSP)
if (avformat_open_input(&fmt_ctx, "rtsp://example.com", NULL, NULL) < 0) {// 错误处理
}
5. 注意事项
- 协议差异:对于 RTSP,可同时设置
stimeout
参数(单位:微秒)增强超时控制68:cCopy Code
AVDictionary *options = NULL; av_dict_set(&options, "stimeout", "2000000", 0); // 2秒超时 avformat_open_input(&fmt_ctx, url, NULL, &options);
- 线程安全:回调函数需确保线程安全,避免竞态条件8。
- 资源释放:无需手动释放
interrupt_callback
,其生命周期与AVFormatContext
绑定5。
6. 典型问题与调试
- 回调未触发:检查是否在
avformat_open_input()
前正确设置回调8。 - 误中断:调整超时阈值,或在回调中增加状态判断(如网络重连尝试次数)6。
40 回调函数 io_open
谨慎
/**
* A callback for opening new IO streams.
*
* Whenever a muxer or a demuxer needs to open an IO stream (typically from
* avformat_open_input() for demuxers, but for certain formats can happen at
* other times as well), it will call this callback to obtain an IO context.
*
* @param s the format context
* @param pb on success, the newly opened IO context should be returned here
* @param url the url to open
* @param flags a combination of AVIO_FLAG_*
* @param options a dictionary of additional options, with the same
* semantics as in avio_open2()
* @return 0 on success, a negative AVERROR code on failure
*
* @note Certain muxers and demuxers do nesting, i.e. they open one or more
* additional internal format contexts. Thus the AVFormatContext pointer
* passed to this callback may be different from the one facing the caller.
* It will, however, have the same 'opaque' field.
*/
int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url,
int flags, AVDictionary **options);
目前看的信息是:avformatContext 的 io_open 回调函数 在默认情况下叫 io_open_default,在解复用的 avformat_open_input 方法中一定会调用。
io_open_default
是 FFmpeg 中用于初始化输入/输出上下文 (AVIOContext
) 的关键函数,主要在解封装流程中处理协议检测与连接。以下是其核心机制与作用解析:
一、功能定位
-
协议初始化入口
在avformat_open_input()
调用流程中,io_open_default
作为默认的 I/O 上下文初始化函数,负责根据输入 URL 的协议类型(如 HTTP、HLS、文件)创建对应的AVIOContext
,并绑定底层协议实现1。 -
协议白名单校验
通过调用ffio_open_whitelist
,该函数会校验协议是否在允许范围内,防止加载未授权的协议实现(如自定义或非标准协议),确保安全性1。 -
多层封装调用链
其执行链路为:
avformat_open_input
→init_input
→io_open_default
→ffio_open_whitelist
→ffurl_open_whitelist
→ffurl_connect
→ 具体协议实现(如http_open
)1。
最终通过系统调用(如socket
)建立网络连接或打开本地文件12。
二、实现机制
-
协议适配层
io_open_default
通过协议前缀(如http://
、file://
)匹配对应的URLProtocol
实现(如ff_http_protocol
),并初始化协议上下文 (URLContext
),最终关联到AVIOContext
的opaque
字段15。 -
缓冲与回调设置
自动配置读写缓冲区大小,并设置默认的read_packet
、write_packet
等回调函数,确保数据通过协议层高效传输至解封装模块17。 -
错误处理
若协议检测失败(如 URL 无效或协议未注册),函数返回错误码并终止后续流程,触发avformat_open_input
的异常处理逻辑1。
三、应用场景
- 标准协议处理:自动处理 HTTP、RTMP、HLS 等协议连接的初始化,无需手动创建
AVIOContext
15。 - 安全限制场景:通过白名单机制限制可访问的协议类型,适用于需严格管控输入源的场景(如嵌入式设备)1。
四、扩展性
- 自定义协议支持:若需支持私有协议,需绕过
io_open_default
,通过avio_alloc_context
手动创建AVIOContext
并注册自定义协议实现37。
41 回调函数io_close
/**
* A callback for closing the streams opened with AVFormatContext.io_open().
*/
void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
42 int io_repositioned;
/**
* IO repositioned flag.
* This is set by avformat when the underlaying IO context read pointer
* is repositioned, for example when doing byte based seeking.
* Demuxers can use the flag to detect such changes.
*/
int io_repositioned;
io_repositioned
是 FFmpeg 中 AVFormatContext
结构体的一个标志字段,用于指示底层 I/O 上下文的读指针是否发生了位置重置。其核心作用与应用场景如下:
一、功能定义
-
标志位作用
io_repositioned
由 FFmpeg 的解封装模块(avformat
)自动设置,主要用于标识底层 I/O 上下文(如AVIOContext
)的读指针是否被显式重定位。例如,在基于字节的随机访问(byte-based seeking)时,该标志会被触发。 -
触发条件
当调用av_seek_frame()
或类似函数导致底层 I/O 缓冲区的读指针位置发生变化时,io_repositioned
会被设置为非零值,表示发生了位置重置。
二、应用场景
-
解封装逻辑适配
解复用器(Demuxer)可通过检查io_repositioned
标志判断是否需要重新同步内部状态(如重新解析流头信息或调整时间戳计算逻辑),以应对底层 I/O 位置突变带来的数据不一致问题。 -
性能优化
在处理网络流或大文件时,通过检测io_repositioned
标志,可避免无效的缓存数据读取,确保后续操作基于最新的 I/O 位置执行1。
三、实现关联
- 与
AVIOContext
的交互
io_repositioned
直接关联AVIOContext
的seek
操作,若用户代码通过avio_seek()
手动调整读指针位置,也会触发该标志的更新
打印值是0
avformatContext->io_repositioned;cout << "avformatContext->io_repositioned = " << avformatContext->io_repositioned << endl;
43 const uint8_t *key; int keylen;作用未知
const uint8_t *key;
int keylen;
44 int64_t max_analyze_duration;
/**
* Maximum duration (in AV_TIME_BASE units) of the data read
* from input in avformat_find_stream_info().
* Demuxing only, set by the caller before avformat_find_stream_info().
* Can be set to 0 to let avformat choose using a heuristic.
*/
int64_t max_analyze_duration;
参见
AVFormatContext 再分析一-CSDN博客
36 int64_t max_analyze_duration; 解复用时使用,在avformat_find_stream_info 方法中使用
avfromatContext 中可以优化的参数。format_probesize,fps_probe_size,probesize,max_analyze_duration-CSDN博客
avformatContext->max_analyze_duration = 0
45 int max_chunk_duration;
/**
* Max chunk time in microseconds.
* Note, not all formats support this and unpredictable things may happen if it is used when not supported.
* - encoding: Set by user
* - decoding: unused
*/
int max_chunk_duration;
用于设置流媒体传输中的最大块持续时间。在FFmpeg的RTMP协议中,这个参数定义了每个RTMP消息的最大持续时间。如果超过这个时间,FFmpeg会自动将数据分成多个块进行传输,以确保流媒体的稳定性和效率。
max_chunk_duration的作用和重要性
- 稳定性:通过限制每个数据块的大小,max_chunk_duration有助于确保流媒体的稳定性。如果数据块过大,可能会导致网络延迟或丢包,影响观看体验。
- 效率:合理设置max_chunk_duration可以提高传输效率,减少缓冲时间,提升用户体验。
- 兼容性:不同的设备和网络环境对数据块的大小有不同的要求,合理设置max_chunk_duration可以增强兼容性。
如何设置max_chunk_duration
在FFmpeg的命令行中,可以通过-max_chunk_duration
选项来设置
打印默认值
avformatContext->max_chunk_duration = 0
46 int max_chunk_size;
/**
* Max chunk size in bytes
* Note, not all formats support this and unpredictable things may happen if it is used when not supported.
* - encoding: Set by user
* - decoding: unused
*/
int max_chunk_size;
avformatContext->max_chunk_size = 0
avformat_context
结构体中的 max_chunk_size
字段在 FFmpeg 库中用于控制读取媒体文件时的最大块大小。这个字段主要用于某些特定的格式处理,尤其是在处理非常大的数据块时,例如在处理非常大的音频或视频帧时。
字段的作用
max_chunk_size
字段通常在处理某些格式的流时非常有用,特别是在需要分割大型文件或流为较小块进行处理时。例如,在某些情况下,直接读取整个大型文件到一个内存块可能会导致内存不足的问题。通过设置 max_chunk_size
,你可以指定每次读取的最大字节数,这有助于更有效地管理内存使用。
如何使用
在 FFmpeg 的 C API 中,你可以在打开媒体文件后设置 max_chunk_size
。例如:
AVFormatContext* formatCtx = NULL;avformat_open_input(&formatCtx, "input.file", NULL, NULL);// 设置最大块大小if (formatCtx) {formatCtx->max_chunk_size = 1024 * 1024; // 例如,设置为1MB}
注意事项
-
兼容性:不是所有的格式和流都支持
max_chunk_size
。在某些情况下,即使设置了此值,FFmpeg 也可能忽略它。因此,最好检查文档和源代码来确认你的格式支持此功能。 -
性能影响:虽然
max_chunk_size
可以帮助管理内存使用,但设置过小的值可能会导致性能下降,因为频繁的磁盘I/O操作会增加。 -
默认值:如果没有特别设置,FFmpeg 可能使用其默认的块大小处理策略。
结论
max_chunk_size
是一个有用的工具,特别是在处理大型媒体文件时,可以帮助优化内存使用和改善应用程序的稳定性和性能。然而,正确使用它需要你对你的媒体文件和FFmpeg的内部机制有一定的了解。在使用之前,最好查阅最新的FFmpeg文档和源代码以了解更多细节和最佳实践。
47 int max_delay;
max_delay字段的作用
max_delay
字段主要用于控制媒体流在播放时的最大延迟。在一些情况下,比如直播流或需要低延迟的场景,控制延迟是非常重要的。例如,在视频会议或实时视频流中,延迟过高会导致用户体验不佳。
如何设置max_delay
在FFmpeg中,你可以通过编程方式设置AVFormatContext
的max_delay
字段来控制延迟。以下是一个基本的示例代码,展示了如何设置这个字段:
#include <libavformat/avformat.h>int main() {AVFormatContext* formatCtx = NULL;if (avformat_open_input(&formatCtx, "input.mp4", NULL, NULL) != 0) {fprintf(stderr, "Could not open input file\n");return -1;}if (avformat_find_stream_info(formatCtx, NULL) < 0) {fprintf(stderr, "Could not find stream information\n");return -1;}// 设置最大延迟,单位为微秒(μs)formatCtx->max_delay = (int64_t)(1000000); // 例如,设置为1秒的延迟// 继续处理...avformat_close_input(&formatCtx);return 0;}
注意事项
-
单位:
max_delay
的单位是微秒(μs)。因此,如果你想设置延迟为1秒,应该将值设置为1000000(因为1秒=1000毫秒=1000000微秒)。 -
影响:设置
max_delay
可能会影响流的播放性能和延迟特性。需要根据具体应用场景进行合理设置。 -
兼容性:不是所有的媒体格式或编解码器都支持动态调整延迟。某些实现可能不完全遵循此设置。
-
4. 与其他参数的关系
-
AVCodecContext
的max_b_frames
若编码层存在 B 帧(双向预测帧),需确保max_delay
大于 B 帧的解码依赖时间,否则可能导致解码错误4。 -
网络协议缓冲区
当通过AVIOContext
处理网络流时,max_delay
需与协议层的缓冲区大小(如buffer_size
)协同配置,避免网络抖动影响同步37。
结论
通过合理设置max_delay
,你可以更好地控制媒体流的播放延迟,这对于需要低延迟的应用场景(如实时视频通信)尤其重要。确保在实际应用中根据具体需求调整此参数。
打印结果为-1
avformatContext->max_delay;cout << "avformatContext->max_delay = " << avformatContext->max_delay << endl;
48 unsigned int max_index_size;
/**
* Maximum amount of memory in bytes to use for the index of each stream.
* If the index exceeds this size, entries will be discarded as
* needed to maintain a smaller size. This can lead to slower or less
* accurate seeking (depends on demuxer).
* Demuxers for which a full in-memory index is mandatory will ignore
* this.
* - muxing: unused
* - demuxing: set by user
*/
unsigned int max_index_size;
max_index_size
字段是用来指示该容器中索引条目可能达到的最大数量。
解释
max_index_size
字段通常用在需要快速访问媒体文件中的多个片段或关键帧的场景。例如,在视频文件中,你可能想要快速跳转到文件的某个特定时间点。在这种情况下,索引可以帮助你快速定位到包含目标时间点的数据块。
使用场景
-
视频播放:在播放视频时,播放器可能需要根据用户操作(如快进、快退)快速定位到视频的特定部分。
-
媒体编辑:在编辑视频或音频文件时,快速访问不同部分的内容。
如何设置和使用
在FFmpeg的API中,你通常不需要手动设置 max_index_size
,因为这个值会根据你打开的媒体文件的具体格式和内容自动确定。当你使用 avformat_open_input()
函数打开一个媒体文件时,FFmpeg会自动填充 AVFormatContext
结构体,包括 max_index_size
。
历史版本兼容性
某些旧版本FFmpeg可能曾定义过类似字段,但在当前主流版本(如6.x)中被移除或更名。建议通过最新源码或官方文档确认
avformatContext->max_index_size = 1048576
49 int64_t max_interleave_delta;
/**
* Maximum buffering duration for interleaving.
*
* To ensure all the streams are interleaved correctly,
* av_interleaved_write_frame() will wait until it has at least one packet
* for each stream before actually writing any packets to the output file.
* When some streams are "sparse" (i.e. there are large gaps between
* successive packets), this can result in excessive buffering.
*
* This field specifies the maximum difference between the timestamps of the
* first and the last packet in the muxing queue, above which libavformat
* will output a packet regardless of whether it has queued a packet for all
* the streams.
*
* Muxing only, set by the caller before avformat_write_header().
*/
int64_t max_interleave_delta;
max_interleave_delta
字段是用于控制输出文件中的数据交织(interleaving)的一个参数。
什么是交织(Interleaving)?
交织是指在输出文件时,将不同流(如视频流、音频流)的数据交错写入,以减少文件头部的延迟并提高播放的流畅性。例如,在一个视频文件中,视频帧和音频帧可能会交错出现,这样播放器就可以在等待下一个视频帧的同时播放音频。
max_interleave_delta 的作用
max_interleave_delta
字段用于控制交织过程中允许的最大时间差(以时间戳为单位)。这个参数决定了在输出文件时,不同流之间的最大时间差。例如,如果一个视频帧的时间戳与紧接着的音频帧的时间戳相差超过了这个值,FFmpeg 可能会选择等待或插入额外的数据包来调整这种差值,以确保流的正确交织。
如何设置 max_interleave_delta
在 FFmpeg 的 API 中,你可以通过直接设置 AVFormatContext
结构体的 max_interleave_delta
字段来调整这个值。例如:
AVFormatContext *fmt_ctx;
avformat_alloc_output_context2(&fmt_ctx, NULL, NULL, "output.mp4");
if (!fmt_ctx) {fprintf(stderr, "Could not create format context\n");exit(1);
}// 设置最大交织延迟为 100ms
fmt_ctx->max_interleave_delta = 100000; // 单位为微秒(1秒=1000000微秒)
注意事项
-
单位:
max_interleave_delta
的单位是微秒(1秒 = 1,000,000微秒)。 -
性能影响:增加
max_interleave_delta
的值可以减少编码时的等待时间,但可能会增加播放时的延迟。 -
合理设置:根据你的具体需求(如实时性要求、文件大小优化等)合理设置此值。
通过调整 max_interleave_delta
,你可以更好地控制输出多媒体文件的性能和播放体验。
打印
avformatContext->max_interleave_delta = 10000000
avformatContext->max_interleave_delta;cout << "avformatContext->max_interleave_delta = " << avformatContext->max_interleave_delta << endl;
50 unsigned int max_picture_buffer;
/**
* Maximum amount of memory in bytes to use for buffering frames
* obtained from realtime capture devices.
*/
unsigned int max_picture_buffer;
用于缓冲从实时捕获设备获得的帧的最大内存量(字节)。
打印
avformatContext->max_picture_buffer = 3041280
51 int max_probe_packets;
/**
* Maximum number of packets that can be probed
* - encoding: unused
* - decoding: set by user
*/
int max_probe_packets;
设置最大 可探测的最大数据包数
AVFormatContext
结构体中的 max_probe_packets
字段用于控制格式探测阶段的数据包数量限制,其作用与封装格式的自动识别逻辑直接相关36。以下是详细解析:
1. 核心功能
-
格式探测(Probing)
当未明确指定输入文件的封装格式时,FFmpeg 会通过读取文件头部数据(或前几个数据包)自动推测格式类型。max_probe_packets
定义了此阶段允许读取的最大数据包数量,以避免因探测耗时过长影响性能36。 -
默认值与调整
- 典型默认值为
50
(具体值可能因 FFmpeg 版本而异)3。 - 若输入文件头部信息复杂或分布在多个数据包中,需适当增大此值以提高探测准确性36。
- 典型默认值为
2. 应用场景
-
特殊文件处理
对于头部信息分散的非标准文件(如某些流媒体分段文件),增加max_probe_packets
可确保 FFmpeg 读取足够的数据包完成格式识别36。 -
延时敏感场景
在实时流处理中,若需降低初始探测阶段的延迟,可减少此参数值,但可能牺牲格式识别的可靠性36。
3. 参数关联性
-
与
probesize
的区别
probesize
限制探测阶段的总字节数,而max_probe_packets
限制数据包数量。两者共同作用,确保探测过程在资源消耗和准确性间权衡36。 -
封装格式影响
某些格式(如 MPEG-TS)依赖多个数据包头信息,需更高的max_probe_packets
值以保证正确识别6。
4. 配置示例
AVFormatContext *fmt_ctx = avformat_alloc_context();
fmt_ctx->max_probe_packets = 100; // 允许探测最多100个数据包
avformat_open_input(&fmt_ctx, input_file, NULL, NULL);
总结
max_probe_packets
是 FFmpeg 格式探测机制的关键参数,通过控制数据包数量平衡识别精度与效率36。实际应用中需结合文件特性与性能需求动态调整。
默认打印值
avformatContext->max_probe_packets = 2500
52 int max_streams;一般也没啥用,什么情况下1000个不够用呢?
/**
* The maximum number of streams.
* - encoding: unused
* - decoding: set by user
*/
int max_streams;
在解复用的时候使用
打印值是 1000
cout << "avformatContext->max_streams = " << avformatContext->max_streams << endl;结果为:avformatContext->max_streams = 1000
53 int max_ts_probe,在解复用ts文件的时候用
/**
* Maximum number of packets to read while waiting for the first timestamp.
* Decoding only.
*/
int max_ts_probe;
int max_ts_probe:解码TS格式时,在得到第一个PTS前可解码的最大packet的数量。
同时关联的还有 avformatcontext 的 ts_id .
int ts_id:TS格式中流的pid
打印结果 avformatContext->max_ts_probe = 50
avformatContext->max_ts_probe;cout << "avformatContext->max_ts_probe = " << avformatContext->max_ts_probe << endl;
从实现 看,是在 avformat_find_stream_info方法内部使用。
也就是说:如果我们读取的ts文件,那么有可能需要调整 max_ts_probe的值,当然越大,解析的包越多,花费的时间越多
54 元数据 AVDictionary *metadata;
/**
* Metadata that applies to the whole file.
*
* - demuxing: set by libavformat in avformat_open_input()
* - muxing: may be set by the caller before avformat_write_header()
*
* Freed by libavformat in avformat_free_context().
*/
AVDictionary *metadata;
参考
ffmpeg 元数据-CSDN博客
55 int metadata_header_padding;
/**
* Number of bytes to be written as padding in a metadata header.
* Demuxing: Unused.
* Muxing: Set by user via av_format_set_metadata_header_padding.
*/
int metadata_header_padding;
56
57
58
59