首页 > 其他分享 >FFmpeg结构体:AVOutputFormat

FFmpeg结构体:AVOutputFormat

时间:2024-06-11 09:00:23浏览次数:16  
标签:AVFMT struct AVFormatContext int FFmpeg codec data AVOutputFormat 结构

1.描述

AVOutpufFormat与AVInputFormat类似,是类似COM 接口的数据结构,表示输出文件容器格式,着重于功能函数,位于Avoformat.h文件中。
ffmpeg支持各种各样的输出文件格式,MP4,FLV,3GP等等。而 AVOutputFormat 结构体则保存了这些格式的信息和一些常规设置。

每一种封装对应一个 AVOutputFormat 结构,ffmpeg将AVOutputFormat 按照链表存储:

2.结构体定义

  1 typedef struct AVOutputFormat {
  2     const char *name;
  3     /**
  4      * Descriptive name for the format, meant to be more human-readable
  5      * than name. You should use the NULL_IF_CONFIG_SMALL() macro
  6      * to define it.
  7      */
  8     const char *long_name;
  9     const char *mime_type;
 10     const char *extensions; /**< comma-separated filename extensions */
 11     /* output support */
 12     enum AVCodecID audio_codec;    /**< default audio codec */
 13     enum AVCodecID video_codec;    /**< default video codec */
 14     enum AVCodecID subtitle_codec; /**< default subtitle codec */
 15     /**
 16      * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER,
 17      * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
 18      * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
 19      * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE
 20      */
 21     int flags;
 22 
 23     /**
 24      * List of supported codec_id-codec_tag pairs, ordered by "better
 25      * choice first". The arrays are all terminated by AV_CODEC_ID_NONE.
 26      */
 27     const struct AVCodecTag * const *codec_tag;
 28 
 29 
 30     const AVClass *priv_class; ///< AVClass for the private context
 31 
 32     /*****************************************************************
 33      * No fields below this line are part of the public API. They
 34      * may not be used outside of libavformat and can be changed and
 35      * removed at will.
 36      * New public fields should be added right above.
 37      *****************************************************************
 38      */
 39     struct AVOutputFormat *next;
 40     /**
 41      * size of private data so that it can be allocated in the wrapper
 42      */
 43     int priv_data_size;
 44 
 45     int (*write_header)(struct AVFormatContext *);
 46     /**
 47      * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
 48      * pkt can be NULL in order to flush data buffered in the muxer.
 49      * When flushing, return 0 if there still is more data to flush,
 50      * or 1 if everything was flushed and there is no more buffered
 51      * data.
 52      */
 53     int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
 54     int (*write_trailer)(struct AVFormatContext *);
 55     /**
 56      * Currently only used to set pixel format if not YUV420P.
 57      */
 58     int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
 59                              AVPacket *in, int flush);
 60     /**
 61      * Test if the given codec can be stored in this container.
 62      *
 63      * @return 1 if the codec is supported, 0 if it is not.
 64      *         A negative number if unknown.
 65      *         MKTAG('A', 'P', 'I', 'C') if the codec is only supported as AV_DISPOSITION_ATTACHED_PIC
 66      */
 67     int (*query_codec)(enum AVCodecID id, int std_compliance);
 68 
 69     void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
 70                                  int64_t *dts, int64_t *wall);
 71     /**
 72      * Allows sending messages from application to device.
 73      */
 74     int (*control_message)(struct AVFormatContext *s, int type,
 75                            void *data, size_t data_size);
 76 
 77     /**
 78      * Write an uncoded AVFrame.
 79      *
 80      * See av_write_uncoded_frame() for details.
 81      *
 82      * The library will free *frame afterwards, but the muxer can prevent it
 83      * by setting the pointer to NULL.
 84      */
 85     int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,
 86                                AVFrame **frame, unsigned flags);
 87     /**
 88      * Returns device list with it properties.
 89      * @see avdevice_list_devices() for more details.
 90      */
 91     int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
 92     /**
 93      * Initialize device capabilities submodule.
 94      * @see avdevice_capabilities_create() for more details.
 95      */
 96     int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
 97     /**
 98      * Free device capabilities submodule.
 99      * @see avdevice_capabilities_free() for more details.
100      */
101     int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
102     enum AVCodecID data_codec; /**< default data codec */
103     /**
104      * Initialize format. May allocate data here, and set any AVFormatContext or
105      * AVStream parameters that need to be set before packets are sent.
106      * This method must not write output.
107      *
108      * Any allocations made here must be freed in deinit().
109      */
110     int (*init)(struct AVFormatContext *);
111     /**
112      * Deinitialize format. If present, this is called whenever the muxer is being
113      * destroyed, regardless of whether or not the header has been written.
114      *
115      * If a trailer is being written, this is called after write_trailer().
116      *
117      * This is called if init() fails as well.
118      */
119     void (*deinit)(struct AVFormatContext *);
120     /**
121      * Set up any necessary bitstream filtering and extract any extra data needed
122      * for the global header.
123      * Return 0 if more packets from this stream must be checked; 1 if not.
124      */
125     int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt);
126 } AVOutputFormat;

 

3.常见变量及其作用


 1 const char *name;
 2 const char *long_name;//格式的描述性名称,易于阅读。
 3 enum AVCodecID audio_codec; //默认的音频编解码器
 4 enum AVCodecID video_codec; //默认的视频编解码器
 5 enum AVCodecID subtitle_codec; //默认的字幕编解码器
 6 struct AVOutputFormat *next;
 7 int (*write_header)(struct AVFormatContext *);
 8 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);//写一个数据包。 如果在标志中设置AVFMT_ALLOW_FLUSH,则pkt可以为NULL。
 9 int (*write_trailer)(struct AVFormatContext *);
10 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
11 int (*control_message)(struct AVFormatContext *s, int type, void *data, size_t data_size);//允许从应用程序向设备发送消息。
12 int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,   AVFrame **frame, unsigned flags);//写一个未编码的AVFrame。
13 int (*init)(struct AVFormatContext *);//初始化格式。 可以在此处分配数据,并设置在发送数据包之前需要设置的任何AVFormatContext或AVStream参数。
14 void (*deinit)(struct AVFormatContext *);//取消初始化格式。
15 int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt);//设置任何必要的比特流过滤,并提取全局头部所需的任何额外数据。

 


作者:YellowLayne
链接:https://www.jianshu.com/p/4d1629aaba42
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

标签:AVFMT,struct,AVFormatContext,int,FFmpeg,codec,data,AVOutputFormat,结构
From: https://www.cnblogs.com/lizishaoye/p/18241462

相关文章

  • 【Python核心数据结构探秘】:元组与字典的完美协奏曲
    文章目录......
  • 保研复习——数据结构篇
    前言:本笔记是对《王道数据结构》中各章节涉及的基础知识进行整理。本笔记主要用以应对夏令营面试中可能会问到的数据结构方面的问题,比较泛泛而谈,如果您对这些内容感兴趣,建议参考原书。大佬可自行绕路材料来源:王道2025年《数据结构考研复习指导》https://pan.baidu.com/s......
  • 深入STL之 栈与队列:数据结构探索之旅
    ......
  • 【数据结构】前缀树(字典树)汇总
    基础{“a”,“abc”,“bac”,“bbc”,“ca”}的字典树如下图:最主用的应用:一,字符串编码。二,位运算。字符串编码相比利用哈希映射编码,优点如下:依次查询长度为n的字符串s的前缀时间复杂度是O(n)。查询完s[0…i],再查询s[0…i+1]的时间复杂度是O(1)。而哈希映射的时间复杂......
  • 【设计模式】结构型-桥接模式
    当抽象与实现,各自独立,桥接模式,如彩虹桥,连接两岸。文章目录一、类爆炸与代码重复二、桥接模式三、桥接模式的核心组成四、运用桥接模式五、桥接模式的应用场景六、小结推荐阅读一、类爆炸与代码重复场景假设:假设我们正在设计一个模拟城市交通的系统。在这个系统中,......
  • 在Linux中,目录结构是怎样的?
    在Linux中,目录结构是一个层次化的文件系统结构,它定义了Linux操作系统中各个目录的作用和存放内容的规范。以下是Linux目录结构的详细介绍:一、根目录(/)作用:整个文件系统的起始点,所有其他目录和文件都是从根目录开始的。根目录包含了系统中的所有文件和目录。二、主要目录及其功......
  • 【C语言】宏offsetof的模拟实现(计算结构体中某变量相对于首地址的偏移)
    首先我们应该特别留意:offsetof是一个宏,并非是一个函数!宏offsetof的介绍:参数:第一个是结构体类型名称,第二个是结构体成员名返回类型:size_t无符号整形引用的头文件:<stddef.h>offsetof的使用举列:#include<stddef.h>structStu//注释为相对于起始位置的偏移量{......
  • 1900springboot VUE 生态菜园管理系统开发mysql数据库web结构java编程计算机网页源码m
    一、源码特点 springbootVUE生态菜园管理系统是一套完善的完整信息管理类型系统,结合springboot框架和VUE完成本系统,对理解JSPjava编程开发语言有帮助系统采用springboot框架(MVC模式开发),系统具有完整的源代码和数据库,系统主要采用B/S模式开发。前段主要技术vue 后端主......
  • 初始C语言——结构化算法的结构
    C语言程序是一种程序化程序,也就是说,可以用C语言程序来解决的问题,都可以分解成相互独立的几个部分,每个部分都可以通过简单的语句或结构来实现。一般而言,对于结构化的程序,一个完整的算法可以用“顺序结构”,“分支结构”和“循环结构”的有机组合来表示。(一)----------顺序结构......
  • nuxt框架中路由动态传参及结构分析之文章跳转详情页面传递文章id
    在nuxt里面我们会经常使用到路由传递参数,列如,登录,文章跳转详情页面等,下面我就以文章列表跳转文章详情页面记录一下。1、首先这个是我的目录结构:在文章列表页面:list.vue(layout目录下的这里其实是一个组件)里面我写了这样一段实现跳转传递,这里我使用到了<nuxt-link>(当然你有其他......