
ffmpeg
文章平均质量分 81
ffmpeg4.2.2或者ffmpeg4.2.3
风雨兼程8023
这个作者很懒,什么都没留下…
展开
-
ffmpeg源码分析:结构体成员管理系统-AVOption
AVOption用于在FFmpeg中描述结构体中的成员变量。一个AVOption可以包含名称,简短的帮助信息,取值等等。 下面开始从代码的角度记录AVOption。AVOption结构体的定义如下所示。libavutil\Opt.h/*** AVOption*/typedef struct AVOption { const char *name; /** * short English help text * @todo What...原创 2020-11-27 16:41:13 · 619 阅读 · 0 评论 -
ffmpeg源码分析:结构体成员管理系统-AVClass
一、AVClsss和AVOption的关系1.1 何为AVOption?1.2 何为AVClass?1.3 AVClass和AVOption的关系二、AVClass2.1 AVFormatContext的AVClass2.2 AVCodecContext的AVClass2.3 AVFrame的AVClass2.4 libx264的AVClass一、AVClsss和AVOption的关系 AVOption用于在FFmpeg中描述结构体中的成员变量。它最主要的...原创 2020-11-27 16:41:48 · 3292 阅读 · 0 评论 -
ffmpeg源码分析:av_write_frame()
/*** Write a packet to an output media file.** This function passes the packet directly to the muxer, without any buffering* or reordering. The caller is responsible for correctly interleaving the* packets if the format requires it. Callers that...原创 2020-10-22 20:50:09 · 1190 阅读 · 0 评论 -
ffmpeg源码分析:av_write_trailer()
av_write_trailer()用于输出文件尾,它的声明位于libavformat\avformat.h,如下所示。/*** Write the stream trailer to an output media file and free the* file private data.** May only be called after a successful call to avformat_write_header.** @param s media file h...原创 2020-09-24 22:17:14 · 1081 阅读 · 0 评论 -
ffmpeg源码分析:avcodec_send_frame和avcodec_receive_packet(最终调用avcodec_encode_video2())
一、avcodec_send_frame()libavcodec\avcodec.h/*** Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet()* to retrieve buffered output packets.** @param avctx codec context* @param[in] frame AVFrame containing the raw...原创 2020-09-17 22:23:18 · 6994 阅读 · 0 评论 -
ffmpeg源码分析:avformat_write_header()
avformat_write_header()的声明位于libavformat\avformat.h,如下所示。/*** Allocate the stream private data and write the stream header to* an output media file.** @param s Media file handle, must be allocated with avformat_alloc_context().* Its of...原创 2020-09-13 20:08:21 · 1800 阅读 · 0 评论 -
ffmpeg源码分析:avformat_alloc_output_context2()
本文简单分析FFmpeg中常用的一个函数:avformat_alloc_output_context2()。在基于FFmpeg的视音频编码器程序中,该函数通常是第一个调用的函数(除了组件注册函数av_register_all())。avformat_alloc_output_context2()函数可以初始化一个用于输出的AVFormatContext结构体。它的声明位于libavformat\avformat.h,如下所示。/*** Allocate an AVFormatConte...原创 2020-09-06 20:43:47 · 2200 阅读 · 2 评论 -
ffmpeg源码分析:avformat_close_input()
下面看一下avformat_close_input()的源代码,位于libavformat\utils.c文件中。void avformat_close_input(AVFormatContext **ps){ AVFormatContext *s; AVIOContext *pb; if (!ps || !*ps) return; s = *ps; pb = s->pb; if ((s->iformat &...原创 2020-09-04 20:30:04 · 1411 阅读 · 1 评论 -
ffmpeg源码分析:avcodec_send_packet和avcodec_receive_frame(原avcodec_decode_video2())
查看avcodec_decode_video2()函数声明发现,该函数已经过期了,取代它的是avcodec_send_packet、avcodec_receive_frame。我们发现新版的avcodec_decode_video2()最终还是调用了avcodec_send_packet、avcodec_receive_frame。如下所示。avcodec_decode_video2->compat_decode->avcodec_send_packet、avcodec_recei...原创 2020-09-03 22:25:07 · 3812 阅读 · 0 评论 -
ffmpeg源码分析:av_read_frame()
ffmpeg中的av_read_frame()的作用是读取码流中的音频若干帧或者视频一帧。例如,解码视频的时候,每解码一个视频帧,需要先调用 av_read_frame()获得一帧视频的压缩数据,然后才能对该数据进行解码(例如H.264中一帧压缩数据通常对应一个NAL)。 av_read_frame()的声明位于libavformat\avformat.h,如下所示。/*** Return the next frame of a stream.* This funct...原创 2020-09-01 21:49:46 · 1529 阅读 · 0 评论 -
ffmpeg源码分析:avformat_find_stream_info()
本文简单分析FFmpeg中一个常用的函数:avformat_find_stream_info()。该函数可以读取一部分视音频数据并且获得一些相关的信息。avformat_find_stream_info()的声明位于libavformat\avformat.h,如下所示。/*** Read packets of a media file to get stream information. This* is useful for file formats with no head...原创 2020-08-30 21:38:01 · 869 阅读 · 0 评论 -
ffmpeg源码分析:avformat_open_input()
目录一、avformat_alloc_context()二、init_input()2.1 av_probe_input_format2()2.2 av_probe_input_buffer2()2.3 io_open三、read_header() 本文简单分析FFmpeg中一个常用的函数:avformat_open_input()。该函数用于打开多媒体数据并且获得一些相关的信息。它的声明位于libavformat\avformat.h,如下所示。/** * O...原创 2020-08-28 21:14:24 · 1122 阅读 · 0 评论 -
ffmpeg源码分析:avcodec_close()
本文简单分析FFmpeg的avcodec_close()函数。该函数用于关闭编码器。avcodec_close()函数的声明位于libavcodec\avcodec.h,如下所示。/** * Close a given AVCodecContext and free all the data associated with it * (but not the AVCodecContext itself). * * Calling this function on an AVCode...原创 2020-08-27 22:22:24 · 1062 阅读 · 0 评论 -
ffmpeg源码分析:avcodec_open2()
本文简单分析FFmpeg的avcodec_open2()函数。该函数用于初始化一个视音频编解码器的AVCodecContext。avcodec_open2()的声明位于libavcodec\avcodec.h,如下所示。/** * Initialize the AVCodecContext to use the given AVCodec. Prior to using this * function the context has to be allocated with avcod...原创 2020-08-19 21:53:57 · 2828 阅读 · 0 评论 -
ffmpeg源码分析:avio_open2()
libavformat\protocol_list.cstatic const URLProtocol * const url_protocols[] = { &ff_async_protocol, &ff_cache_protocol, &ff_concat_protocol, &ff_crypto_protocol, &ff_data_protocol, &ff_ffrtmphttp_protocol,.原创 2020-08-16 22:17:50 · 793 阅读 · 0 评论 -
ffmpeg源码分析:avcodec_find_encoder()和avcodec_find_decoder()
我们以avcodec_find_encoder(AV_CODEC_ID_AAC)和avcodec_find_decoder(AV_CODEC_ID_AAC)来分析avcodec_find_encoder和avcodec_find_decoder两个函数。一、avcodec_find_encoder()avcodec_find_encoder(AV_CODEC_ID_AAC); 查找ID值为AV_CODEC_ID_AAC的AAC编码器。avcodec_find_encode...原创 2020-08-16 22:14:47 · 3320 阅读 · 0 评论 -
ffmpeg源码分析:av_register_all()和avcodec_register_all()
一、av_register_all()二、avcodec_register_all()一、av_register_all() av_register_all()注册所有的demuxer,muxer,outdev,indev设备。其定义在文件libavformat\allformats.c中,如下所示:void av_register_all(void){ ff_thread_once(&av_format_next_init, av_format_init_ne...原创 2020-08-12 21:10:50 · 3488 阅读 · 0 评论 -
ffmpeg结构体(10)之AVCodec及其相关函数
AVCodec是存储编解码器信息的结构体。本文将会详细分析一下该结构体里每个变量的含义和作用。 首先看一下结构体的定义(位于libavcodec\avcodec.h文件中):/** * AVCodec. */typedef struct AVCodec { /** * Name of the codec implementation. * The name is globally unique among encoders and among ...原创 2020-07-29 20:50:27 · 1482 阅读 · 0 评论 -
ffmpeg结构体(9)之AVCodecParameters及其相关函数
上一个章节分析AVStream的时候讲到了AVStream结构中的AVCodecContext指针,这就是AVStream中持有的codec相关的上下文,一个AVStream对应一个AVCodecContext指针。很显然,AVCodecContext就是存储codec上下文相关信息的。与视频或者音频编解码相关的信息都在这个上下文中。#if FF_API_LAVF_AVCTX /** * @deprecated use the codecpar struct inste...原创 2020-07-29 19:26:10 · 6550 阅读 · 1 评论 -
ffmpeg结构体(8)之AVStream及其相关函数
上一章分析了AVFormatContext,其中有两个参数: unsigned int nb_streams; AVStream **streams; nb_streams是当前轨道数,就是流数量,streams是轨道的指针数组。一般而言一个视频文件会有一个视频流和一个音频流,那就是两个AVStream结构。 AVStream在FFmpeg使用过程中关于编解码至关重要的结构体之一,是对流(Stream)的封装和抽象,描述了视频、音频等流的编码格式等基本流信息。此...原创 2020-07-27 22:14:27 · 1427 阅读 · 0 评论 -
ffmpeg结构体(7)之AVPacket及其相关函数
AVPacket是FFmpeg中很重要的一个数据结构,它保存了解复用(demuxer)之后,解码(decode)之前的数据(仍然是压缩后的数据)和关于这些数据的一些附加的信息,如显示时间戳(pts),解码时间戳(dts),数据时长(duration),所在流媒体的索引(stream_index)等等。 对于视频(Video)来说,AVPacket通常包含一个压缩的Frame;而音频(Audio)则有可能包含多个压缩的Frame。并且,一个packet也有可能是空的,不包含任何压缩数据...原创 2020-07-26 21:48:04 · 4589 阅读 · 0 评论 -
ffmpeg结构体(6)之AVFrame及其相关函数
目录一、AVFrame结构体的定义二、AVFrame相关的函数 2.1 av_frame_alloc()2.2 avpicture_fill()2.3 av_frame_free()2.4 av_frame_ref()2.5 av_frame_clone() AVFrame中存储的是经过解码后的原始数据。在解码中,AVFrame是解码器的输出;在编码中,AVFrame是编码器的输入。下图中,"decoded frames"的数据类型就...原创 2020-07-26 09:29:30 · 3319 阅读 · 0 评论 -
ffmpeg结构体(5)之AVOutputFormat及其相关函数
AVOutpufFormat与AVInputFormat类似,是类似COM 接口的数据结构,表示输出文件容器格式,着重于功能函数,位于Avoformat.h文件中。 ffmpeg支持各种各样的输出文件格式,MP4,FLV,3GP等等。而 AVOutputFormat 结构体则保存了这些格式的信息和一些常规设置。flv的封装器的定义如下所示:AVOutputFormat ff_flv_muxer = { .name = "flv", .long...原创 2020-07-21 21:50:21 · 2174 阅读 · 0 评论 -
ffmpeg结构体(4)之AVInputFormat及其相关函数
AVInputFormat是类似COM 接口的数据结构,表示输入文件容器格式,着重于功能函数。AVInputFormat为FFMPEG的解复用器对象,通过调用av_register_all(),一种文件容器格式对应一个AVInputFormat 结构。在程序运行时有多个实例,比如flv的解复用器的定义libavformat\flvdec.c如下所示。AVInputFormat ff_flv_demuxer = { .name = "flv", .lo...原创 2020-07-21 21:49:54 · 2146 阅读 · 0 评论 -
ffmpeg结构体(3)之AVIOContext及其相关函数
这个结构体,是FFmpeg中有关io操作的顶层结构体,是avio的核心。FFmpeg支持打开本地文件路径和流媒体协议的URL。 虽然AVIOContext时avio操作的核心,但AVIOContext中的所有函数指针都不应该直接调用,它们只应在实现自定义I / O时由客户端应用程序设置。 通常这些设置为avio_alloc_context()中指定的函数指针(下一节中的read_packet函数指针)。 AVIOContext的相关调用都是在AVFormatContext...原创 2020-07-21 21:48:01 · 2163 阅读 · 0 评论 -
ffmpeg结构体(2)之AVFormatContext及其相关函数
目录一、AVFormatContext的定义二、AVFormatContext相关的函数2.1avformat_alloc_context()2.2avformat_free_context()一、AVFormatContext的定义AVFormatContext定义在文件libavformat\avformat.h中。/** * Format I/O context. * New fields can be added to the end with minor ve..原创 2020-07-20 22:01:53 · 1684 阅读 · 1 评论 -
ffmpeg结构体(1)最关键的结构体之间的关系
FFMPEG中结构体很多。最关键的结构体可以分成以下几类:a) 解协议(http,rtsp,rtmp,mms) AVIOContext,URLProtocol,URLContext主要存储视音频使用的协议的类型以及状态。URLProtocol存储输入视音频使用的封装格式。每种协议都对应一个URLProtocol结构。(注意:FFMPEG中文件也被当做一种协议“file”)b) 解封装(flv,avi,rmvb,mp4) AVFormatContext主要存储视音频封装格式中包含...原创 2020-07-20 22:01:15 · 404 阅读 · 0 评论