AVFrame
时间: 2023-08-12 08:07:52 浏览: 92
AVFrame 是 FFmpeg 中表示视频或音频帧的结构体,它包含了一帧的所有信息,如像素数据、采样数据、时间戳、宽高等等。在 FFmpeg 中,解码后的数据一般都会被存储在 AVFrame 中,然后再进行后续的处理。
AVFrame 的定义如下:
```
typedef struct AVFrame {
/**
* Pointer to the picture/channel planes.
* This might be different from the first allocated byte
*/
uint8_t *data[AV_NUM_DATA_POINTERS];
/**
* Size, in bytes, of the data for each plane.
*/
int linesize[AV_NUM_DATA_POINTERS];
/**
* pointers to the samples in uint8_t **
* planar audio only
*/
uint8_t **extended_data;
/**
* Width and height of the video frame
*/
int width, height;
/**
* Format of the video frame
*/
enum AVPixelFormat format;
/**
* Sample rate of the audio frame
*/
int sample_rate;
/**
* Number of audio samples (per channel) described by this frame
*/
int nb_samples;
/**
* Channel layout of the audio frame
*/
uint64_t channel_layout;
/**
* Presentation timestamp in timebase units (time when frame should be shown to user).
*/
int64_t pts;
/**
* PTS copied from the AVPacket that was decoded to produce this frame
*/
int64_t pkt_pts;
/**
* Duration of this frame in timebase units (0 if unknown or undefined).
*/
int64_t duration;
/**
* Flags indicating which frame properties are present
*/
int flags;
/**
* A Boolean value indicating whether the frame is a key frame (1) or not (0).
*/
int key_frame;
/**
* A pointer to the next frame in the linked list.
*/
struct AVFrame *next;
/**
* The number of elements in the extended_data array.
*/
int8_t *extended_data_size;
/**
* Metadata for the frame.
*/
AVDictionary *metadata;
} AVFrame;
```
AVFrame 中最重要的是 data 和 linesize 这两个成员,它们表示每个像素或采样数据的地址和大小,可以通过它们来访问帧中的数据。同时,AVFrame 中还包含了一些其他的信息,如帧的宽高、格式、时间戳等等。
阅读全文