FFmpeg結構體:AVFrame

1.描述

AVFrame用來存儲解碼后的(或原始)音頻或視頻數據,位于avcodec.h文件中。
AVFrame必須由av_frame_alloc()分配內存,同時必須由av_frame_free()釋放。
AVFrame分配內存后能夠被多次用來存儲不同的數據(例如:decoder解碼后的幀)。av_frame_unref釋放任何持幀的引用,并結構體還原到未被使用的狀態。

2.常見變量及其作用

uint8_t *   data [AV_NUM_DATA_POINTERS];//解碼后原始數據(對視頻來說是YUV,RGB,對音頻來說是PCM)。
int linesize[AV_NUM_DATA_POINTERS];//在視頻中,表示圖片一行數據的大小。
uint8_t **extended_data;//指向數據平面/通道。
int width, height;//一個視頻幀的寬度和高度。
int nb_samples;//這個AVFrame中的每個音頻通道中包含的音頻幀個數。
int format;//表示解碼后的數據類型或格式,-1表示未被設置或不能識別的類型。
int key_frame;//是否為關鍵幀。
enum AVPictureType pict_type;//幀的類型。
AVRational sample_aspect_ratio;//視頻幀的寬高比,0表示未知。
int64_t pts;//顯示時間戳,表示該什么時候被顯示。
int64_t pkt_dts;//從AVPacket中拷貝的值。
int coded_picture_number;//編碼幀序號。
int display_picture_number;//顯示幀需要。
void *opaque;//用戶私有信息。
int repeat_pict;//解碼時,每幀圖片延遲的時間,extra_delay = repeat_pict / (2*fps)。
int interlaced_frame;//是否是隔行掃描
int sample_rate;//音頻的采樣率。
uint64_t channel_layout;//音頻的布局方式。
/**
* MPEG vs JPEG YUV range.
* - encoding: Set by user
* - decoding: Set by libavcodec
*/
enum AVColorRange color_range;
enum AVColorPrimaries color_primaries;
enum AVColorTransferCharacteristic color_trc;

/**
* YUV colorspace type.
* - encoding: Set by user
* - decoding: Set by libavcodec
*/
enum AVColorSpace colorspace;
enum AVChromaLocation chroma_location;

/**
* frame timestamp estimated using various heuristics, in stream time base
* - encoding: unused
* - decoding: set by libavcodec, read by user.
*/
int64_t best_effort_timestamp;

/**
* reordered pos from the last AVPacket that has been input into the decoder
* - encoding: unused
* - decoding: Read by user.
*/
int64_t pkt_pos;

/**
     * duration of the corresponding packet, expressed in
     * AVStream->time_base units, 0 if unknown.
     * - encoding: unused
     * - decoding: Read by user.
*/
int64_t pkt_duration;

/**
     * metadata.
     * - encoding: Set by user.
     * - decoding: Set by libavcodec.
     */
    AVDictionary *metadata;

    /**
     * decode error flags of the frame, set to a combination of
     * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
     * were errors during the decoding.
     * - encoding: unused
     * - decoding: set by libavcodec, read by user.
     */
int decode_error_flags;

    /**
     * number of audio channels, only used for audio.
     * - encoding: unused
     * - decoding: Read by user.
     */
int channels;//音頻通道個數

    /**
     * size of the corresponding packet containing the compressed
     * frame.
     * It is set to a negative value if unknown.
     * - encoding: unused
     * - decoding: set by libavcodec, read by user.
     */
int pkt_size;

int8_t *qscale_table;
int qstride;
int qscale_type;
AVBufferRef *qp_table_buf;

    /**
     * For hwaccel-format frames, this should be a reference to the
     * AVHWFramesContext describing the frame.
     */
AVBufferRef *hw_frames_ctx;

    /**
     * AVBufferRef for free use by the API user. FFmpeg will never check the
     * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
     * the frame is unreferenced. av_frame_copy_props() calls create a new
     * reference with av_buffer_ref() for the target frame's opaque_ref field.
     *
     * This is unrelated to the opaque field, although it serves a similar
     * purpose.
     */
AVBufferRef *opaque_ref;
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 教程一:視頻截圖(Tutorial 01: Making Screencaps) 首先我們需要了解視頻文件的一些基...
    90后的思維閱讀 4,794評論 0 3
  • ffmpeg是一個非常有用的命令行程序,它可以用來轉碼媒體文件。它是領先的多媒體框架FFmpeg的一部分,其有很多...
    城市之光閱讀 6,883評論 3 6
  • 在此不再詳述,其中AVFrame是包含碼流參數較多的結構體。本文將會詳細分析一下該結構體里主要變量的含義和作用。(...
    心有琳鑫閱讀 5,921評論 1 4
  • 廉租房后續[撇嘴] 文/陌宇軒 申請房的時候 我替俺舅,排著長隊 公安的圍上 社保的圍上 我也搶先圍上 搖號 抽簽...
    小哲小詩閱讀 140評論 0 0