FFMpeg--AVOutputFormat

FFMpeg中的AVOutputFormat结构体用于描述输出媒体格式,包括名称、人性化描述和MIME类型等关键信息,是进行多媒体处理时的重要组成部分。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;
//媒体格式mime类型描述
const char *mime_type;

const char *extensions; /**< comma-separated filename extensions */
/* output support */
//音频解码器id
enum AVCodecID audio_codec;    /**< default audio codec */
//视频解码器id
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;

/**
 * 一个支持codec_id-codec_tag匹配的列表,按最佳匹配的先后顺序排列,以AV_CODEC_ID_NONE结束。
 * 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;

//AVClass 的关联
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.
 *
 *
 * 该行下方的任何字段都不属于公共API。 它们可能不会在libavformat之外使用,可以随意更改和删除。 应该在上面添加新的公共领域。
 *****************************************************************
 */
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 *);
/**
 * 写数据包的函数指针
 * 如果flags被设置为AVFMT_ALLOW_FLUSH,pkt可以为NULL,然后刷新muxer的缓存数据。
 * 还有数据需要传入时返回值为0,数据传送完成时返回1;
 * 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.返回1时找到,没找到返回0,否者返回负数
 *         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);

/**
 * 写入一个未解析的AVFrame
 * Write an uncoded AVFrame.
 * 详情参考av_write_uncoded_frame()
 * See av_write_uncoded_frame() for details.
 * 后面需要释放*frame,但是muxer可以阻止指针被设置NULL
 * 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);
//数据解码器id
enum AVCodecID data_codec; /**< default data codec */
/**
 * 初始化,在这里可能分配数据大小、并在发送数据包之前设置AVFormatContext或者AVStream的参数,该函数不能写输入
 * 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.
 *
 * Return 0 if streams were fully configured, 1 if not, negative AVERROR on failure
 * 配置成功返回0,失败返回1,出错返回值为负数
 * 任何在该函数中分配的操作,在deinit调用时必须释放
 * Any allocations made here must be freed in deinit().
 */
int (*init)(struct AVFormatContext *);
/**
 * 销毁format。
 * Deinitialize format. If present, this is called whenever the muxer is being
 * destroyed, regardless of whether or not the header has been written.
 * 如果正在操作预告写入,那么在write_trailer()调用完成后调用
 * If a trailer is being written, this is called after write_trailer().
 * 
 * init()操作失败时也会调用
 * This is called if init() fails as well. 
 */
void (*deinit)(struct AVFormatContext *);
/**
 * 设置必要的比特流过滤,并提取文件头的附加数据。 
 * 如果需要检查来自此流的更多数据包,则返回0; 否则返回1
 * 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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值