美文网首页
AVFormatContext结构体分析&空间关闭清理

AVFormatContext结构体分析&空间关闭清理

作者: 遇见猫的大鱼 | 来源:发表于2018-08-01 10:27 被阅读23次

Demo

AVFormatContext 的成员非常多,接下来说一下常用的部分:

一:AVIOContext *pb //IO上下文 自定义格式读/从内存当中读
,av_read_frame 根据 pb结构体来读

image.png

二:char filename[1024] 文件路径文件名,断开重连时用到


image.png

三:AVStream **streams 数组 unsigned int nb_streams 存储音频参数信息


image.png

四: int64_t duration //AV_TIME_BASE 总长度 微妙 (不一定能获取到,如果没有的话要自行处理)


image.png

五:int64_t bit_rate 比特率 每秒文件大小 网络适应调整

六:void avformat_close_input(AVFormatContext **s) 关闭输入的上下文,传一个指针地址。


image.png

AVStream

(1) AVRational time_base 一个分数,时间基数 和duration有关


image.png

(2) int64_t duration //毫秒int64_t nb_frames; 不一定有

(3) AVRational avg_frame_rate 帧率 (分数表示)

(4) AVCodecParameters *codecpar (音视频参数) 替代codec
• enum AVMediaType codec_type; 音频/视频(codec_type AVMediaType AVMEDIA_TYPE_VIDEO)
• enum AVCodecID codec_id (编码格式 codec_id AVCodecID AV_CODEC_ID_H264)
• uint32_t codec_tag(编码器)
• int format(像素格式,音频采样格式)
• int width;int height(宽高)
• uint64_t channel_layout
• int frame_size;一帧音频大小
• int channels; 声道数
• int sample_rate; 样本率

image.png image.png

相关文章

网友评论

      本文标题:AVFormatContext结构体分析&空间关闭清理

      本文链接:https://www.haomeiwen.com/subject/nzyfvftx.html