zoukankan      html  css  js  c++  java
  • ffmpeg结构体以及函数介绍(二)

    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成功
    #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成功

    转载自:http://blog.chinaunix.net/uid-20718335-id-3025307.html

  • 相关阅读:
    Autofs
    markdown 基本语法
    Why Linux Doesn’t Need Defragmenting
    How to reconfigure installed dpkg package (tzdata, locales)
    weblogic性能监控
    exec
    在Oracle中查询表的大小
    hadoop主要概念的理解和学习
    ORACLE ASM中查询表空间使用情况、数据文件路径、裸设备磁盘总大小剩余大小
    linux 查看内存和cpu占用比较多的进程
  • 原文地址:https://www.cnblogs.com/xuanyuanchen/p/2445052.html
Copyright © 2011-2022 走看看