1 avcodec_find_decoder()

/**

* Find a registered decoder with a matching codec ID.

*

* @param id CodecID of the requested decoder

* @return A decoder if one was found, NULL otherwise.

*/

AVCodec *avcodec_find_decoder(enum CodecID id);

// 通过code ID查找一个已经注册的音视频解码器

// 引入 #include
"libavcodec/avcodec.h"

// 实现在: \ffmpeg\libavcodec\utils.c

// 查找解码器之前,必须先调用av_register_all注册所有支持的解码器

// 查找成功返回解码器指针,否则返回NULL

// 音视频解码器保存在一个链表中,查找过程中,函数从头到尾遍历链表,通过比较解码器的ID来查找

2 avcodec_find_decoder_by_name()

/**

* Find a registered decoder with the specified name.

*

* @param name name of the requested decoder

* @return A decoder if one was found, NULL otherwise.

*/

AVCodec *avcodec_find_decoder_by_name(const
char *name);

// 通过一个指定的名称查找一个已经注册的音视频解码器

// 引入 #include
"libavcodec/avcodec.h"

// 实现在: \ffmpeg\libavcodec\utils.c

// 查找解码器之前,必须先调用av_register_all注册所有支持的解码器

// 查找成功返回解码器指针,否则返回NULL

// 音视频解码器保存在一个链表中,查找过程中,函数从头到尾遍历链表,通过比较解码器的name来查找

3 avcodec_find_encoder()

/**

* Find a registered encoder with a matching codec ID.

*

* @param id CodecID of the requested encoder

* @return An encoder if one was found, NULL otherwise.

*/

AVCodec *avcodec_find_encoder(enum CodecID id);

// 通过code ID查找一个已经注册的音视频编码器

// 引入 #include
"libavcodec/avcodec.h"

// 实现在: \ffmpeg\libavcodec\utils.c

// 查找编码器之前,必须先调用av_register_all注册所有支持的编码器

// 查找成功返回编码器指针,否则返回NULL

// 音视频编码器保存在一个链表中,查找过程中,函数从头到尾遍历链表,通过比较编码器的ID来查找

4 avcodec_find_encoder_by_name()

/**

* Find a registered encoder with the specified name.

*

* @param name name of the requested encoder

* @return An encoder if one was found, NULL otherwise.

*/

AVCodec *avcodec_find_encoder_by_name(const
char *name);

// 通过一个指定的名称查找一个已经注册的音视频编码器

// 引入 #include
"libavcodec/avcodec.h"

// 实现在: \ffmpeg\libavcodec\utils.c

// 查找编码器之前,必须先调用av_register_all注册所有支持的编码器

// 查找成功返回编码器指针,否则返回NULL

// 音视频编码器保存在一个链表中,查找过程中,函数从头到尾遍历链表,通过比较编码器的名称来查找

5 avcodec_open()

/**

* Initialize the AVCodecContext to use the given AVCodec. Prior to using this

* function the context has to be allocated.

*

* The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),

* avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for

* retrieving a codec.

*

* @warning This function is not thread safe!

*

* @code

* avcodec_register_all();

* codec = avcodec_find_decoder(CODEC_ID_H264);

* if (!codec)

*     exit(1);

*

* context = avcodec_alloc_context();

*

* if (avcodec_open(context, codec) < 0)

*     exit(1);

* @endcode

*

* @param avctx The context which will be set up to use the given codec.

* @param codec The codec to use within the context.

* @return zero on success, a negative value on error

* @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder, avcodec_close

*/

int avcodec_open(AVCodecContext *avctx, AVCodec *codec);

// 使用给定的AVCodec初始化AVCodecContext

// 引入#include
"libavcodec/avcodec.h"

// 方法: avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), avcodec_find_decoder() and avcodec_find_encoder() 提供了快速获取一个codec的途径

// 该方法在编码和解码时都会用到

// 返回0时成功,打开作为输出时,参数设置不对的话,调用会失败

 
6 av_guess_format()

/**

* Return the output format in the list of registered output formats

* which best matches the provided parameters, or return NULL if

* there is no match.

*

* @param short_name if non-NULL checks if short_name matches with the

* names of the registered formats

* @param filename if non-NULL checks if filename terminates with the

* extensions of the registered formats

* @param mime_type if non-NULL checks if mime_type matches with the

* MIME type of the registered formats

*/

AVOutputFormat *av_guess_format(const
char *short_name,

const
char *filename,

const
char *mime_type);

// 返回一个已经注册的最合适的输出格式

// 引入#include
"libavformat/avformat.h"

// 可以通过 const
char *short_name 获取,如"mpeg"

// 也可以通过 const
char *filename 获取,如"E:\a.mp4"

7 av_new_stream()

/**

* Add a new stream to a media file.

*

* Can only be called in the read_header() function. If the flag

* AVFMTCTX_NOHEADER is in the format context, then new streams

* can be added in read_packet too.

*

* @param s media file handle

* @param id file-format-dependent stream ID

*/

AVStream *av_new_stream(AVFormatContext *s,
int id);

// 为媒体文件添加一个流,一般为作为输出的媒体文件容器添加音视频流

// 引入 #include
"libavformat/avformat.h"

// 再打开源文件时用户一般不需要直接调用该方法

 
8 dump_format()

#if FF_API_DUMP_FORMAT

/**

* @deprecated Deprecated in favor of av_dump_format().

*/

attribute_deprecated void dump_format(AVFormatContext *ic,

int index,

const
char *url,

int is_output);

#endif

// 该函数的作用就是检查下初始化过程中设置的参数是否符合规范
// 有些版本中为 av_dump_format
 
9 av_set_parameters()

#if FF_API_FORMAT_PARAMETERS

/**

* @deprecated pass the options to avformat_write_header directly.

*/

attribute_deprecated int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);

#endif

// 设置初始化参数
// 不赞成跳过该方法,直接调用 avformat_write_header/av_write_header
 
10 av_write_header()

#if FF_API_FORMAT_PARAMETERS

/**

* Allocate the stream private data and write the stream header to an

* output media file.

* @note: this sets stream time-bases, if possible to stream->codec->time_base

* but for some formats it might also be some other time base

*

* @param s media file handle

* @return 0 if OK, AVERROR_xxx on error

*

* @deprecated use avformat_write_header.

*/

attribute_deprecated int av_write_header(AVFormatContext *s);

#endif

// 把流头信息写入到媒体文件中
// 返回0成功

ffmpeg结构体以及函数介绍(二)的更多相关文章

  1. ffmpeg结构体以及函数介绍(一)

    本文对在使用ffmpeg进行音视频编解码时使用到的一些函数做一个简单介绍,我当前使用的ffmpeg版本为:0.8.5,因为本人发现在不同的版本中,有些函数名称会有点小改动,所以在此有必要说明下ffmp ...

  2. ffmpeg结构体以及函数介绍(三)

    1 AVPacket typedef struct AVPacket { /** * Presentation timestamp in AVStream->time_base units; t ...

  3. FFmpeg 结构体学习(二): AVStream 分析

    在上文FFmpeg 结构体学习(一): AVFormatContext 分析我们学习了AVFormatContext结构体的相关内容.本文,我们将讲述一下AVStream. AVStream是存储每一 ...

  4. FFmpeg 结构体学习(五): AVCodec 分析

    在上文FFmpeg 结构体学习(四): AVFrame 分析我们学习了AVFrame结构体的相关内容.本文,我们将讲述一下AVCodec. AVCodec是存储编解码器信息的结构体.下面我们来分析一下 ...

  5. FFMPEG结构体分析:AVCodec

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  6. FFMPEG结构体分析:AVFrame

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrameFFMPEG结构体分析:AVFormatContextFFMPEG结构体分析:AVCodecContext ...

  7. FFmpeg 结构体学习(七): AVIOContext 分析

    在上文FFmpeg 结构体学习(六): AVCodecContext 分析我们学习了AVCodec结构体的相关内容.本文,我们将讲述一下AVIOContext. AVIOContext是FFMPEG管 ...

  8. [转载] FFMPEG结构体分析:AVFrame

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrameFFMPEG结构体分析:AVFormatContextFFMPEG结构体分析:AVCodecContext ...

  9. FFMPEG结构体分析:AVIOContext

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

随机推荐

  1. LCA(最近公共祖先)之倍增算法

    概述 对于有根树T的两个结点u.v,最近公共祖先LCA(T,u,v)表示一个结点x,满足x是u.v的祖先且x的深度尽可能大. 如图,3和5的最近公共祖先是1,5和2的最近公共祖先是4 在本篇中我们先介 ...

  2. CGI编程

    1简介 .CGI:通用网关接口(Common Gateway Interface)是一个Web服务器主机提供信息服务的标准接口,服务器和客户端之间的通信,是客户端的浏览器和服务器端的http服务器之间 ...

  3. #pragma once 与 #ifndef 解析

    转自:http://www.cnblogs.com/hokyhu/archive/2009/03/30/1425604.html 为了避免同一个文件被include多次,C/C++中有两种方式,一种是 ...

  4. Hadoop学习笔记四

    一.fsimage,edits和datanode的block在本地文件系统中位置的配置 fsimage:hdfs-site.xml中的dfs.namenode.name.dir  值例如file:// ...

  5. Java对正则表达式的支持(二)

    正则表达式的主要用途: a.在目标字符串中找出匹配正则表达式的部分 b.校验目标字符串是否符合正则表达式,例如校验邮箱地址 c.在目标字符串中替换符合正则表达式的部分为其他的字符串 Scanner类是 ...

  6. BZOJ 4129: Haruna’s Breakfast [树上莫队 分块]

    传送门 题意: 单点修改,求一条链的mex 分块维护权值,$O(1)$修改$O(S)$求mex...... 带修改树上莫队 #include <iostream> #include < ...

  7. BZOJ 1097: [POI2007]旅游景点atr [DP 状压 最短路]

    传送门 题意: 一个无向图,从$1$到$n$,要求必须经过$2,3,...,k+1$,给出一些限制关系,要求在经过$v \le k+1$之前必须经过$u \le k+1$ 求最短路 预处理出$1... ...

  8. BZOJ 3932: [CQOI2015]任务查询系统 [主席树]

    传送门 题意: 任务用三元组(Si,Ei,Pi)描述,(Si,Ei,Pi)表示任务从第Si秒开始,在第Ei秒后结束(第Si秒和Ei秒任务也在运行),其优先级为Pi 调度系统会经常向查询系统询问,第Xi ...

  9. 在window上安装redis

    redis没有官方的windows版本,如果需要在windows安装可以下载由微软维护的redis(https://github.com/MicrosoftArchive/redis). 在这里我们采 ...

  10. php环境搭建和第一个php程序

    一.开发环境搭建 因为是初学,使用的还是非常经典的组合appserv+dreamweaver cs6; 1.1   appserv安装 appserv的安装还是非常简单的,直接双击可执行程序appse ...