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; //默認的音頻編解碼器
enum AVCodecID video_codec; //默認的視頻編解碼器
enum AVCodecID subtitle_codec; //默認的字幕編解碼器
struct AVOutputFormat *next;
int (*write_header)(struct AVFormatContext *);
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);//寫一個數(shù)據(jù)包。 如果在標志中設(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)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 0 概述 FFmpeg是一套領(lǐng)先的音視頻多媒體處理開源框架,采用LGPL或GPL許可證。它提供了對音視頻的采集、編...
    但行耕者閱讀 7,218評論 0 19
  • 九月,不約而至,微風(fēng)悄悄拂過學(xué)院的喧騰,今天是報道,開學(xué)第一天。沉睡了一個暑假的校園如同死灰復(fù)燃。只不過,蜿蜒古樸...
    深巷離人閱讀 212評論 0 0
  • 2017.4.14 孩子們晚上好,今晚想和你們談?wù)勗庥觯≡庥?,糟糕的遇見,我們通常這么想,實際上也確實是如此!人的...
    來自過去的信閱讀 179評論 0 0
  • 已經(jīng)九月份了,也到了俗稱找工作的金九銀十黃金期,各種工作招聘信息也是漫天飛舞。那自己該找什么樣的工作,什么樣的工作...
    小明有主見了嗎閱讀 544評論 7 0
  • 創(chuàng)建一個類,將要執(zhí)行的 block 封裝起來,然后類的內(nèi)部有一個 _isCanceled 變量,在執(zhí)行的時候,檢查...
    指尖的跳動閱讀 631評論 0 0

友情鏈接更多精彩內(nèi)容