首页 > 其他 > 详细

FFMpeg 中的数据结构

时间:2020-01-16 16:51:02      阅读:74      评论:0      收藏:0      [点我收藏+]

FFMpeg 中比较重要的函数以及数据结构如下:

  1. 数据结构:

(1) AVFormatContext

(2) AVOutputFormat

(3) AVInputFormat

(4) AVCodecContext

(5) AVCodec

(6) AVFrame

(7) AVPacket

(8) AVPicture

(9) AVStream

  1. 初始化函数:

(1) av_register_all()

(2) avcodec_open()

(3) avcodec_close()

(4) av_open_input_file()

(5) av_find_input_format()

(6) av_find_stream_info()

(7) av_close_input_file()

  1. 音视频编解码函数:

(1) avcodec_find_decoder()

(2) avcodec_alloc_frame()

(3) avpicture_get_size()

(4) avpicture_fill()

(5) img_convert()

(6) avcodec_alloc_context()

(7) avcodec_decode_video()

(8) av_free_packet()

(9) av_free()

  1. 文件操作:

(1) avnew_steam()

(2) av_read_frame()

(3) av_write_frame()

(4) dump_format()

  1. 其他函数:

(1) avpicture_deinterlace()

(2) ImgReSampleContext()

AVFormatContext

一般在使用 ffmpeg sdk 的代码中 AVFormatContext 是一个贯穿始终的数据结构,很多函数都要用到它 作为参数。FFmpeg 代码中对这个数据结构的注释是:format I/O context 。
此结构包含了一个视频流的格式内容。其中存有了 AVInputFormat(or AVOutputFormat 同一时间 AVFormatContext 内只能存在其中一个),和 AVStream、AVPacket 这几个重要的数据结构以及一些其他的 相关信息,比如 title,author,copyright 等。还有一些可能在编解码中会用到的信息,诸如:duration, file_size, bit_rate 等。参考 avformat.h 头文件。
Useage: 声明:
AVFormatContext *oc; (1)
初始化:
由于 AVFormatConext 结构包含许多信息因此初始化过程是分步完成,而且有些变量如果没 有值可用,也可不初始化。但是由于一般声明都是用指针因此一个分配内存过程不可少:

oc = av_alloc_format_context(); (2)

结构中的 AVInputFormat(或 AVOutputFormat)是一定要初始化的,基本上这是编译码要使用什么 codec 的依据所在:
oc->oformat = fmt; or oc->iformat = fmt; (3)

其中 AVOutputFormat* fmt 或 AVInputFormat* fmt。(AVInputFormat and AVOutputFormat 的初始化在后 面介绍。随后在参考代码 output_example.c 中有一行:

snprintf(oc->filename, sizeof(oc->filename), “%s”, filename); (4)

还不是十分清楚有什么作用,估计是先要在输出文件中写一些头信息。

FFMpeg 中的数据结构

原文:https://www.cnblogs.com/schips/p/12201740.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!