FFmpeg結(jié)構(gòu)體:AVOutputFormat

1.描述

AVOutpufFormat與AVInputFormat類似泪蔫,是類似COM 接口的數(shù)據(jù)結(jié)構(gòu)蹦狂,表示輸出文件容器格式,著重于功能函數(shù)嗦明,位于Avoformat.h文件中笼沥。
ffmpeg支持各種各樣的輸出文件格式,MP4,F(xiàn)LV奔浅,3GP等等馆纳。而 AVOutputFormat 結(jié)構(gòu)體則保存了這些格式的信息和一些常規(guī)設(shè)置。

每一種封裝對應(yīng)一個 AVOutputFormat 結(jié)構(gòu)汹桦,ffmpeg將AVOutputFormat 按照鏈表存儲:

2.結(jié)構(gòu)體定義

typedef struct AVOutputFormat {
    const char *name;
    /**
     * Descriptive name for the format, meant to be more human-readable
     * than name. You should use the NULL_IF_CONFIG_SMALL() macro
     * to define it.
     */
    const char *long_name;
    const char *mime_type;
    const char *extensions; /**< comma-separated filename extensions */
    /* output support */
    enum AVCodecID audio_codec;    /**< default audio codec */
    enum AVCodecID video_codec;    /**< default video codec */
    enum AVCodecID subtitle_codec; /**< default subtitle codec */
    /**
     * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER,
     * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
     * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
     * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE
     */
    int flags;

    /**
     * List of supported codec_id-codec_tag pairs, ordered by "better
     * choice first". The arrays are all terminated by AV_CODEC_ID_NONE.
     */
    const struct AVCodecTag * const *codec_tag;


    const AVClass *priv_class; ///< AVClass for the private context

    /*****************************************************************
     * No fields below this line are part of the public API. They
     * may not be used outside of libavformat and can be changed and
     * removed at will.
     * New public fields should be added right above.
     *****************************************************************
     */
    struct AVOutputFormat *next;
    /**
     * size of private data so that it can be allocated in the wrapper
     */
    int priv_data_size;

    int (*write_header)(struct AVFormatContext *);
    /**
     * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
     * pkt can be NULL in order to flush data buffered in the muxer.
     * When flushing, return 0 if there still is more data to flush,
     * or 1 if everything was flushed and there is no more buffered
     * data.
     */
    int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
    int (*write_trailer)(struct AVFormatContext *);
    /**
     * Currently only used to set pixel format if not YUV420P.
     */
    int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
                             AVPacket *in, int flush);
    /**
     * Test if the given codec can be stored in this container.
     *
     * @return 1 if the codec is supported, 0 if it is not.
     *         A negative number if unknown.
     *         MKTAG('A', 'P', 'I', 'C') if the codec is only supported as AV_DISPOSITION_ATTACHED_PIC
     */
    int (*query_codec)(enum AVCodecID id, int std_compliance);

    void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
                                 int64_t *dts, int64_t *wall);
    /**
     * Allows sending messages from application to device.
     */
    int (*control_message)(struct AVFormatContext *s, int type,
                           void *data, size_t data_size);

    /**
     * Write an uncoded AVFrame.
     *
     * See av_write_uncoded_frame() for details.
     *
     * The library will free *frame afterwards, but the muxer can prevent it
     * by setting the pointer to NULL.
     */
    int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,
                               AVFrame **frame, unsigned flags);
    /**
     * Returns device list with it properties.
     * @see avdevice_list_devices() for more details.
     */
    int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
    /**
     * Initialize device capabilities submodule.
     * @see avdevice_capabilities_create() for more details.
     */
    int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
    /**
     * Free device capabilities submodule.
     * @see avdevice_capabilities_free() for more details.
     */
    int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
    enum AVCodecID data_codec; /**< default data codec */
    /**
     * Initialize format. May allocate data here, and set any AVFormatContext or
     * AVStream parameters that need to be set before packets are sent.
     * This method must not write output.
     *
     * Any allocations made here must be freed in deinit().
     */
    int (*init)(struct AVFormatContext *);
    /**
     * Deinitialize format. If present, this is called whenever the muxer is being
     * destroyed, regardless of whether or not the header has been written.
     *
     * If a trailer is being written, this is called after write_trailer().
     *
     * This is called if init() fails as well.
     */
    void (*deinit)(struct AVFormatContext *);
    /**
     * Set up any necessary bitstream filtering and extract any extra data needed
     * for the global header.
     * Return 0 if more packets from this stream must be checked; 1 if not.
     */
    int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt);
} AVOutputFormat;

3.常見變量及其作用

const char *name;
const char *long_name;//格式的描述性名稱鲁驶,易于閱讀。
enum AVCodecID audio_codec; //默認(rèn)的音頻編解碼器
enum AVCodecID video_codec; //默認(rèn)的視頻編解碼器
enum AVCodecID subtitle_codec; //默認(rèn)的字幕編解碼器
struct AVOutputFormat *next;
int (*write_header)(struct AVFormatContext *);
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);//寫一個數(shù)據(jù)包舞骆。 如果在標(biāo)志中設(shè)置AVFMT_ALLOW_FLUSH钥弯,則pkt可以為NULL。
int (*write_trailer)(struct AVFormatContext *);
int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
int (*control_message)(struct AVFormatContext *s, int type, void *data, size_t data_size);//允許從應(yīng)用程序向設(shè)備發(fā)送消息葛作。
int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,   AVFrame **frame, unsigned flags);//寫一個未編碼的AVFrame寿羞。
int (*init)(struct AVFormatContext *);//初始化格式。 可以在此處分配數(shù)據(jù)赂蠢,并設(shè)置在發(fā)送數(shù)據(jù)包之前需要設(shè)置的任何AVFormatContext或AVStream參數(shù)绪穆。
void (*deinit)(struct AVFormatContext *);//取消初始化格式。
int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt);//設(shè)置任何必要的比特流過濾虱岂,并提取全局頭部所需的任何額外數(shù)據(jù)玖院。
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市第岖,隨后出現(xiàn)的幾起案子难菌,更是在濱河造成了極大的恐慌,老刑警劉巖蔑滓,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件郊酒,死亡現(xiàn)場離奇詭異,居然都是意外死亡键袱,警方通過查閱死者的電腦和手機燎窘,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來蹄咖,“玉大人褐健,你說我怎么就攤上這事±教溃” “怎么了蚜迅?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長俊抵。 經(jīng)常有香客問我谁不,道長,這世上最難降的妖魔是什么务蝠? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任拍谐,我火速辦了婚禮烛缔,結(jié)果婚禮上馏段,老公的妹妹穿的比我還像新娘轩拨。我一直安慰自己,他們只是感情好院喜,可當(dāng)我...
    茶點故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布亡蓉。 她就那樣靜靜地躺著,像睡著了一般喷舀。 火紅的嫁衣襯著肌膚如雪砍濒。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天硫麻,我揣著相機與錄音爸邢,去河邊找鬼。 笑死拿愧,一個胖子當(dāng)著我的面吹牛杠河,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播浇辜,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼券敌,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了柳洋?” 一聲冷哼從身側(cè)響起待诅,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎熊镣,沒想到半個月后卑雁,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡绪囱,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年测蹲,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片毕箍。...
    茶點故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡弛房,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出而柑,到底是詐尸還是另有隱情文捶,我是刑警寧澤,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布媒咳,位于F島的核電站粹排,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏涩澡。R本人自食惡果不足惜顽耳,卻給世界環(huán)境...
    茶點故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧射富,春花似錦膝迎、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至柴灯,卻和暖如春卖漫,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背赠群。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工羊始, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人查描。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓突委,卻偏偏與公主長得像,于是被迫代替她去往敵國和親叹誉。 傳聞我的和親對象是個殘疾皇子鸯两,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,066評論 2 355

推薦閱讀更多精彩內(nèi)容

  • 0 概述 FFmpeg是一套領(lǐng)先的音視頻多媒體處理開源框架,采用LGPL或GPL許可證长豁。它提供了對音視頻的采集钧唐、編...
    但行耕者閱讀 6,814評論 0 19
  • 九月,不約而至匠襟,微風(fēng)悄悄拂過學(xué)院的喧騰钝侠,今天是報道,開學(xué)第一天酸舍。沉睡了一個暑假的校園如同死灰復(fù)燃帅韧。只不過,蜿蜒古樸...
    深巷離人閱讀 183評論 0 0
  • 2017.4.14 孩子們晚上好啃勉,今晚想和你們談?wù)勗庥龊鲋郏≡庥觯愀獾挠鲆娀床覀兺ǔ_@么想叮阅,實際上也確實是如此!人的...
    來自過去的信閱讀 153評論 0 0
  • 已經(jīng)九月份了,也到了俗稱找工作的金九銀十黃金期状您,各種工作招聘信息也是漫天飛舞勒叠。那自己該找什么樣的工作兜挨,什么樣的工作...
    小明有主見了嗎閱讀 457評論 7 0
  • 創(chuàng)建一個類拌汇,將要執(zhí)行的 block 封裝起來,然后類的內(nèi)部有一個 _isCanceled 變量颗搂,在執(zhí)行的時候担猛,檢查...
    指尖的跳動閱讀 595評論 0 0