AVFrame是包含碼流參數較多的結構體。
參考結構體理解:http://www.lxweimin.com/p/d109e7ef9749
struct AVInputFormat *iformat
:輸入數據的封裝格式
AVIOContext *pb
:輸入數據的緩存
unsigned int nb_streams
:視音頻流的個數
AVStream **streams
:視音頻流
char filename[1024]
:文件名
int64_t duration
//duration是以微秒為單位
//轉換成hh:mm:ss形式
int tns, thh, tmm, tss;
tns = (pFormatCtx->duration)/1000000;
thh = tns / 3600;
tmm = (tns % 3600) / 60;
tss = (tns % 60);
timelong.Format("%02d:%02d:%02d",thh,tmm,tss);
:時長(單位:微秒us,轉換為秒需要除以1000000)
int bit_rate
:比特率(單位bps,轉換為kbps需要除以1000)
AVDictionary *metadata
:元數據
視頻的原數據(metadata)信息可以通過AVDictionary獲取。元數據存儲在AVDictionaryEntry結構體中,如下所示
typedef struct AVDictionaryEntry {
char *key;
char *value;
} AVDictionaryEntry;
每一條元數據分為key和value兩個屬性。
在ffmpeg中通過av_dict_get()函數獲得視頻的原數據。
下列代碼顯示了獲取元數據并存入meta字符串變量的過程,注意每一條key和value之間有一個"\t:",value之后有一個"\r\n"
//MetaData------------------------------------------------------------
//從AVDictionary獲得
//需要用到AVDictionaryEntry對象
//CString author,copyright,description;
CString meta=NULL,key,value;
AVDictionaryEntry *m = NULL;
//不用一個一個找出來
/* m=av_dict_get(pFormatCtx->metadata,"author",m,0);
author.Format("作者:%s",m->value);
m=av_dict_get(pFormatCtx->metadata,"copyright",m,0);
copyright.Format("版權:%s",m->value);
m=av_dict_get(pFormatCtx->metadata,"description",m,0);
description.Format("描述:%s",m->value);
*/
//使用循環讀出
//(需要讀取的數據,字段名稱,前一條字段(循環時使用),參數)
while(m=av_dict_get(pFormatCtx->metadata,"",m,AV_DICT_IGNORE_SUFFIX)){
key.Format(m->key);
value.Format(m->value);
meta+=key+"\t:"+value+"\r\n" ;
}