注:写了一系列的结构体的分析的文章,在这里列一个列表:
FFMPEG结构体分析:AVFrame
FFMPEG结构体分析:AVFormatContext
FFMPEG结构体分析:AVCodecContext
FFMPEG结构体分析:AVIOContext
FFMPEG结构体分析:AVCodec
FFMPEG结构体分析:AVStream
FFMPEG结构体分析:AVPacket
FFMPEG有几个最重要的结构体,包含了解协议,解封装,解码操作,此前已经进行过分析:
在此不再详述,其中AVPacket是存储压缩编码数据相关信息的结构体。本文将会详细分析一下该结构体里重要变量的含义和作用。
首先看一下结构体的定义(位于avcodec.h文件中):
/* 雷霄骅 * 中国传媒大学/数字电视技术 * leixiaohua1020@126.com * */ typedef struct AVPacket { /** * Presentation timestamp in AVStream->time_base units; the time at which * the decompressed packet will be presented to the user. * Can be AV_NOPTS_VALUE if it is not stored in the file. * pts MUST be larger or equal to dts as presentation cannot happen before * decompression, unless one wants to view hex dumps. Some formats misuse * the terms dts and pts/cts to mean something different. Such timestamps * must be converted to true pts/dts before they are stored in AVPacket. */ int64_t pts; /** * Decompression timestamp in AVStream->time_base units; the time at which * the packet is decompressed. * Can be AV_NOPTS_VALUE if it is not stored in the file. */ int64_t dts; uint8_t *data; int size; int stream_index; /** * A combination of AV_PKT_FLAG values */ int flags; /** * Additional packet data that can be provided by the container. * Packet can contain several types of side information. */ struct { uint8_t *data; int size; enum AVPacketSideDataType type; } *side_data; int side_data_elems; /** * Duration of this packet in AVStream->time_base units, 0 if unknown. * Equals next_pts - this_pts in presentation order. */ int duration; void (*destruct)(struct AVPacket *); void *priv; int64_t pos; ///< byte position in stream, -1 if unknown /** * Time difference in AVStream->time_base units from the pts of this * packet to the point at which the output from the decoder has converged * independent from the availability of previous frames. That is, the * frames are virtually identical no matter if decoding started from * the very first frame or from this keyframe. * Is AV_NOPTS_VALUE if unknown. * This field is not the display duration of the current packet. * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY * set. * * The purpose of this field is to allow seeking in streams that have no * keyframes in the conventional sense. It corresponds to the * recovery point SEI in H.264 and match_time_delta in NUT. It is also * essential for some types of subtitle streams to ensure that all * subtitles are correctly displayed after seeking. */ int64_t convergence_duration; } AVPacket;
在AVPacket结构体中,重要的变量有以下几个:
uint8_t *data:压缩编码的数据。
例如对于H.264来说。1个AVPacket的data通常对应一个NAL。
注意:在这里只是对应,而不是一模一样。他们之间有微小的差别:使用FFMPEG类库分离出多媒体文件中的H.264码流
因此在使用FFMPEG进行视音频处理的时候,常常可以将得到的AVPacket的data数据直接写成文件,从而得到视音频的码流文件。
int size:data的大小
int64_t pts:显示时间戳
int64_t dts:解码时间戳
int stream_index:标识该AVPacket所属的视频/音频流。
这个结构体虽然比较简单,但是非常的常用。
相关推荐
本文对在使用ffmpeg进行音视频编解码时使用到的一些函数做一个简单介绍,我当前使用的ffmpeg版本为:0.8.5,因为本人发现在不同的版本中,有些函数名称会有点小改动,所以在此有必要说明下ffmpeg的版本号。
【FFmpeg4Android:视频播放】包含视频jni层播放(原生播放)与java层播放。分别人提供不同的使用需求。
FFmpeg4Android:视频文件推流到nginx服务器(源码) RTMP推流器(Streamer)的在流媒体系统中的作用可以用下图表示。首先将视频数据以RTMP的形式发送到流媒体服务器端(Server,比如FMS,Red5,Wowza等),然后...
opencv4.1.0使用cmake编译时,提示FFMPEG: Download failed: 6;"Couldn't resolve host name
用于将FFMPEG2.0中的结构体初始化代码转换为vs2008形式的
该解决方案包含了使用FFmpeg进行封装格式处理的各种例子: simplest ffmpeg demuxer:视音频分离器 simplest ffmpeg demuxer simple:视音频分离器(简化版) simplest ffmpeg muxer:视音频复用器 simplest ...
ffmpeg-streamerstream local media files to streaming media server (Use RTMP as example).本例子实现了推送本地视频至流媒体服务器(以RTMP为例)。是使用FFmpeg进行流媒体推送最简单的教程。simplest_ffmpeg_...
最早学习ffmpeg的一个资源,现在已经下不到了,重新上传下
c++实现基于ffmpeg实现了解析rtsp视频为cv:Mat格式,将Mat数据推送到rtmp服务。。。
Maven坐标:org.bytedeco:ffmpeg:4.3.2-1.5.5; 标签:bytedeco、ffmpeg、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码...
ffmpeg.js 该库提供了使用将FFmpeg构建移植到JavaScript的功能。 生成针对浏览器内部使用进行了优化:最小的大小可加快加载速度,asm.js,性能调整等。尽管它们也可在Node中使用。 建物 当前可用的版本(将来可能会...
参考MSYS2: ://www.msys2.org/ 吃豆人镜像: : pacman代理: : FFmpeg: : MinGW / FFmpeg安装指南: : VSCode: ://code.visualstudio.com/ VSCode的C / C ++: ://code.visualstudio.com/docs/languages/cpp ...
该解决方案包含了使用FFmpeg进行封装格式处理的各种例子: simplest_ffmpeg_demuxer:视音频分离器。 simplest_ffmpeg_demuxer_simple:视音频分离器(简化版)。 simplest_ffmpeg_muxer:视音频复用器。 simplest_...
本程序使用opencv3.2+ffmpeg3.4编译,实现Mat到mp4的无缓冲,并可以设置比特率、帧率,实现高质量图片与高质量视频的转换,说明请查看https://blog.csdn.net/weixin_39212021
ffmpeg标准化 :headphone: 使用ffmpeg进行音频响度标准化。安装npm install ffmpeg-normalize用法埃布R128 const normalize = require ( 'ffmpeg-normalize' ) ;normalize ( { input : 'input.mp4' , output : '...
ffmpeg常用结构体树状图
ffmpeg构建脚本 在Mac OS上使用android NDK构建ffmpeg 。 跑步: $ ./build.sh ffmpeg: : NDK: :
导入这个jar包后就可以使用ffmpeg的音频转码 mvn install:install-file -Dfile=E:\jave-1.0.2.jar //包的输入路径 -DgroupId=jave -DartifactId=jave -Dversion=1.0.2 -Dpackaging=jar //执行完成后 ...
simplest_ffmpeg_player:标准版,FFmpeg学习的开始。 simplest_ffmpeg_player_su:SU(SDL Update)版,加入了简单的SDL的Event。 simplest_ffmpeg_decoder:一个包含了封装格式处理功能的解码器。使用了libavcodec...
基于ffmpeg实现了解析rtsp视频为cv::Mat格式,此时可以对cv::Mat进行处理,然后再将cv::Mat数据推送到rtmp流媒体服务。处理、转码一条龙。另外,工程中关于OpenCV、ffmpeg的库和头文件的路径需要自己根据实际路径...