前提
I帧:关键帧,帧内压缩,不使用运动补偿,不依赖其他库,可以独立解码
P帧:帧间编码方式,前向时间预测,可以包含帧内编码的部分,p帧的宏块可以是前向预测,也可以是帧内编码。依赖于前面的I帧或P帧
B帧:帧间编码方式,双向时间预测,大大提高压缩倍数。视频帧的传输顺序和显示顺序不同,依赖前面的P帧或I帧,依赖后面的P帧
图像组GOP:两个关键帧之间的距离,码率不变,GOP越大,P、B帧越多,图像质量越好
库
libavformat:媒体文件容器格式处理库,音视频混流处理MediaMuxer和音视频解析MediaDemuxer:需要用到该库进行码流文件解析和混流
libavcodec:编解码器库
libswresample:音频格式转换和重采样处理的库
libswscale:视频格式转换和缩放处理的库
libavfilter:音视频滤镜、特效处理的库
libavdevice:设备操作库
libavutil:Utility辅助函数库,提供一些独立的辅助函数功能
重点数据结构和基础
1、音视频数据帧AVFrame,表示未进行编码压缩的音视频数据
typedef struct AVFrame{
......
// 视频帧图像数据 或者 音频帧PCM数据, 根据不同的格式有不同的存放方式
// 对于视频帧:RGB/RGBA 格式时 data[0] 中一次存放每个像素的RGB/RGBA数据
// YUV420 格式时 data[0]存放Y数据; data[1]存放U数据; data[2]存放V数据
// 对于音频帧: data[0]存放左声道数据; data[1]存放右声道数据
uint8_t *data[AV_NUM_DATA_POINTERS];
// 行字节跨度, 相当于stride
// 对于视频帧: 上下两行同一列像素相差的字节数,例如:对于RGBA通常是(width*4), 但是有时FFMPEG内部会有扩展, 可能会比这个值大
// 对于音频帧: 单个通道中所有采样占用的字节数
int linesize[AV_NUM_DATA_POINTERS];
int format;// 视频帧是图像格式,音频帧是采样格式
int64_t pts;// 当前数据帧的时间戳
int width,height;// 仅用于视频帧,宽度高度
int key_frame;// 仅用于视频,当前是否是I帧
int sample_rate;// 音频,采样率
uint64_t channel_layout;// 音频,通道类型
int nb_samples;// 音频,样本数量
}AVFrame;
常用的操作函数
AVFrame *av_frame_alloc(void); // 分配一个数据帧结构
AVFrame *av_frame_clone(const AVFrame *src); // 完整的克隆数据帧结构, 包括其内部数据
void av_frame_free(AVFrame **frame); // 释放数据帧结构及其内部数据
int av_frame_ref(AVFrame *dst, const AVFrame *src); // 增加引用计数
void av_frame_unref(AVFrame *frame); // 减少引用计数
2、音视频数据包AVPacket,表示压缩后的音视频数据
typedef struct AVPacket{
......
int64_t pts;// 显示时间戳
int64_t dts;// 解码时间戳,对于音频来说,通常与pts相同
uint8_t *data;// 实际压缩后的视频或者音频数据
int size;// 压缩后的数据大小
int stream_index;// 流索引值,在媒体文件中,使用0,1来区分音视频流
int flags;
int64_t duration;// 渲染显示时长
int64_t pos;// 当前包在流中的位置,-1表示未知
......
}AVPacket;
常用的操作函数
AVPacket *av_packet_alloc(void); // 分配一个数据包结构体
AVPacket *av_packet_clone(const AVPacket *src); // 完整赋值一个数据包
void av_packet_free(AVPacket **pkt); // 释放数据包结构及其内部的数据
void av_init_packet(AVPacket *pkt); // 初始化数据包结构,可选字段都设置为默认值
int av_new_packet(AVPacket *pkt, int size); // 根据指定大小创建包结构中的数据
3、时间基和时间戳
时间基time_base:时间刻度的概念
eg:time_base = 1/200,相当于将1000ms均分为200份,每个时间单位是5ms,当视频帧的pts=1173时,对应的实际时刻点是1173*5=5865ms
媒体文件解析分流
文件处理:1、音频流 2、视频流
流媒体文件相关的API:libavformat库中的函数
1、avformat_open_input()/avformat_close_input()
2、avformat_seek_file()——暂时不推荐使用
3、av_read_frame()
解码器相关API:libavcodec库中的函数
1、avcodec_alloc_context3()/avcodec_free_context()
2、avcodec_parameters_to_context()
3、avcodec_open2()/avcodec_close()
4、avcodec_send_packet()/avcodec_receive_frame()
本文由 szr 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Sep 14, 2021 at 08:44 pm
Greetings! Very useful advice within this post! It is the little changes that produce the most significant changes. Thanks for sharing!
theteethwhitenerbali.com
Частенько Fonbet раздаёт эксклюзивные коды на фрибеты – бесплатная ставка, которая не требует, чтобы на балансе были деньги. Если выполните все условия букмекерской конторы и выиграете, тогда кеш зачислится уже в виде реальных денег. Их получится перевести на карточку или e-кошелёк https://www.inserrh.com/media/pgs/code_promotionnel_1xbet.html
Hello, Neat post. There is an issue with your website in web explorer, maytest this? IE nonetheless is the market chief and a large element of other people will leave out your magnificent writing due to this problem.
phanmuoi.vn
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
Download latest version of the application online casino Brazino777 - play today!
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
https://brazino777.directorio-de-casinos-mx.com/
Узнать больше 1xslots
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
Upload client casino 1win - play today!
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
https://1win.directorio-de-casinos-mx.com/
Гизбо Казино — это платформа, которая привлекает внимание игроков широким ассортиментом азартных развлечений и выгодными бонусами. Здесь вы найдете слоты с прогрессивными джекпотами, настольные игры, а также турниры, которые проходят на регулярной основе казино Gizbo
will be a great author. I will be sure to bookmark your blog and definitely will come back at some point. I want to encourage continue your great work, have a nice holiday weeken
jmvgroup.co.in
I have saved as a favorite for later!
agieducation.org
Нормальное казино, платит. Сам играю в Joycasino и после выигрыша вывожу деньги и доходят довольно быстро. Всегда выводил через электронные кошельки, мне так https://pizzanyam.ru/