最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

FFMpeg SDK 开发手册

IT圈 admin 49浏览 0评论

2024年5月11日发(作者:阴幻桃)

FFMpeg SDK 开发手册

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

1. 数据结构:

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

(9)

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

(9)

(1)

(2)

(3)

(4)

(1)

(2)

AVFormatContext

AVOutputFormat

AVInputFormat

AVCodecContext

AVCodec

AVFrame

AVPacket

AVPicture

AVStream

av_register_all()

avcodec_open()

avcodec_close()

av_open_input_file()

av_find_input_format()

av_find_stream_info()

av_close_input_file()

avcodec_find_decoder()

avcodec_alloc_frame()

avpicture_get_size()

avpicture_fill()

img_convert()

avcodec_alloc_context()

avcodec_decode_video()

av_free_packet()

av_free()

avnew_steam()

av_read_frame()

av_write_frame()

dump_format()

avpicture_deinterlace()

ImgReSampleContext()

2.

初始化函数:

3.

音视频编解码函数:

4.

文件操作:

5.

其他函数:

以下就根据,以上数据结构及函数在ffmpeg测试代码output_example.c中出现的前后顺进行分析。在

此之前还是先谈一下ffmpeg的编译问题。在linux下的编译比较简单,这里不多说了。在windows下的编

译可以参考以下网页:

/?tid=1897&extra=page%3D1

值得一提的是,在使用编译后的sdk进行测试时(用到ffmpeg目录下的output_example.c)编译过程

中可能会有以下两个问题:

1. Output_example.c用到了snprintf.h这个头文件。然而这个头文件在win下和linux下有所不同。

具体在win下可以用以下方法解决:

/software/snprintf/

2. 如果使用vc6,或是vc6的命令行进行编译,inline可能不认。错误会出现在common.h文件

中,可以在common.h中加入

#ifdef _MSC_VAR

#define inline __inline

#endif

交待完毕进入正题。

一.FFMpeg 中的数据结构:

I. 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)

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

2024年5月11日发(作者:阴幻桃)

FFMpeg SDK 开发手册

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

1. 数据结构:

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

(9)

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

(9)

(1)

(2)

(3)

(4)

(1)

(2)

AVFormatContext

AVOutputFormat

AVInputFormat

AVCodecContext

AVCodec

AVFrame

AVPacket

AVPicture

AVStream

av_register_all()

avcodec_open()

avcodec_close()

av_open_input_file()

av_find_input_format()

av_find_stream_info()

av_close_input_file()

avcodec_find_decoder()

avcodec_alloc_frame()

avpicture_get_size()

avpicture_fill()

img_convert()

avcodec_alloc_context()

avcodec_decode_video()

av_free_packet()

av_free()

avnew_steam()

av_read_frame()

av_write_frame()

dump_format()

avpicture_deinterlace()

ImgReSampleContext()

2.

初始化函数:

3.

音视频编解码函数:

4.

文件操作:

5.

其他函数:

以下就根据,以上数据结构及函数在ffmpeg测试代码output_example.c中出现的前后顺进行分析。在

此之前还是先谈一下ffmpeg的编译问题。在linux下的编译比较简单,这里不多说了。在windows下的编

译可以参考以下网页:

/?tid=1897&extra=page%3D1

值得一提的是,在使用编译后的sdk进行测试时(用到ffmpeg目录下的output_example.c)编译过程

中可能会有以下两个问题:

1. Output_example.c用到了snprintf.h这个头文件。然而这个头文件在win下和linux下有所不同。

具体在win下可以用以下方法解决:

/software/snprintf/

2. 如果使用vc6,或是vc6的命令行进行编译,inline可能不认。错误会出现在common.h文件

中,可以在common.h中加入

#ifdef _MSC_VAR

#define inline __inline

#endif

交待完毕进入正题。

一.FFMpeg 中的数据结构:

I. 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)

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

发布评论

评论列表 (0)

  1. 暂无评论