/**
* This struct describes the properties of an encoded stream.
*
* sizeof(AVCodecParameters) is not a part of the public ABI, this struct must
* be allocated with avcodec_parameters_alloc() and freed with
* avcodec_parameters_free().
*/
typedef struct AVCodecParameters {
/**
* General type of the encoded data.
*/
enum AVMediaType codec_type;
/**
* Specific type of the encoded data (the codec used).
*/
enum AVCodecID codec_id;
/**
* Additional information about the codec (corresponds to the AVI FOURCC).
*/
uint32_t codec_tag; /**
* Extra binary data needed for initializing the decoder, codec-dependent.
*
* Must be allocated with av_malloc() and will be freed by
* avcodec_parameters_free(). The allocated size of extradata must be at
* least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding
* bytes zeroed.
*/
uint8_t *extradata;
/**
* Size of the extradata content in bytes.
*/
int extradata_size; /**
* - video: the pixel format, the value corresponds to enum AVPixelFormat.
* - audio: the sample format, the value corresponds to enum AVSampleFormat.
*/
int format; /**
* The average bitrate of the encoded data (in bits per second).
*/
int64_t bit_rate; int bits_per_coded_sample; /**
* Codec-specific bitstream restrictions that the stream conforms to.
*/
int profile;
int level; /**
* Video only. The dimensions of the video frame in pixels.
*/
int width;
int height; /**
* Video only. The aspect ratio (width / height) which a single pixel
* should have when displayed.
*
* When the aspect ratio is unknown / undefined, the numerator should be
* set to 0 (the denominator may have any value).
*/
AVRational sample_aspect_ratio; /**
* Video only. The order of the fields in interlaced video.
*/
enum AVFieldOrder field_order; /**
* Video only. Additional colorspace characteristics.
*/
enum AVColorRange color_range;
enum AVColorPrimaries color_primaries;
enum AVColorTransferCharacteristic color_trc;
enum AVColorSpace color_space;
enum AVChromaLocation chroma_location; /**
* Video only. Number of delayed frames.
*/
int video_delay; /**
* Audio only. The channel layout bitmask. May be 0 if the channel layout is
* unknown or unspecified, otherwise the number of bits set must be equal to
* the channels field.
*/
uint64_t channel_layout;
/**
* Audio only. The number of audio channels.
*/
int channels;
/**
* Audio only. The number of audio samples per second.
*/
int sample_rate;
/**
* Audio only. The number of bytes per coded audio frame, required by some
* formats.
*
* Corresponds to nBlockAlign in WAVEFORMATEX.
*/
int block_align;
/**
* Audio only. Audio frame size, if known. Required by some formats to be static.
*/
int frame_size; /**
* Audio only. The amount of padding (in samples) inserted by the encoder at
* the beginning of the audio. I.e. this number of leading decoded samples
* must be discarded by the caller to get the original audio without leading
* padding.
*/
int initial_padding;
/**
* Audio only. The amount of padding (in samples) appended by the encoder to
* the end of the audio. I.e. this number of decoded samples must be
* discarded by the caller from the end of the stream to get the original
* audio without any trailing padding.
*/
int trailing_padding;
/**
* Audio only. Number of samples to skip after a discontinuity.
*/
int seek_preroll;
} AVCodecParameters;

enum AVMediaType codec_type:编解码器的类型(视频,音频...)
enum AVCodecID   codec_id:标示特定的编解码器
int format:对于视频来说就是像素格式(参见AVPixelFormat,如0就代表YUV420p),对于音频来说就是采样数据格式(参见AVSampleFormat)。
int bit_rate:平均比特率
uint8_t *extradata; int extradata_size:针对特定编码器包含的附加信息(例如对于H.264解码器来说,存储SPS,PPS等)
int width, height:如果是视频的话,代表视频帧的宽和高
int refs:运动估计参考帧的个数(H.264的话会有多帧,MPEG2这类的一般就没有了)
int sample_rate:采样率(音频)
uint64_t channel_layout:声道格式
int channels:声道数(音频)
int profile:型(H.264里面就有,其他编码标准应该也有)
int level:级(和profile差不太多)

使用方法,可以从 AVStream 上获取 AVCodecParameters  ,例:

for (int i = ; i < ic->nb_streams; i++) {
AVStream *as = ic->streams[i];
if (as->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
LOGI("视频数据");
videoStream = i;
fps = r2d(as->avg_frame_rate);
LOGI("fps = %d, width = %d, height = %d, codecid = %d, pixformat = %d, bit_rate = %lld", fps,
as->codecpar->width,
as->codecpar->height,
as->codecpar->codec_id,
as->codecpar->format,
as->codecpar->bit_rate
);
}
else {
LOGI("音频数据");
audioStream = i;
LOGI("sample_rate = %d, channels = %d, sample_format = %d",
as->codecpar->sample_rate,
as->codecpar->channels,
as->codecpar->format
);
}
}

打印:

2019-04-03 21:16:26.064 29619-29619/? I/xp.chen: 视频数据
2019-04-03 21:16:26.064 29619-29619/? I/xp.chen: fps = 25, width = 1920, height = 1080, codecid = 28, pixformat = 0, bit_rate = 3312568
2019-04-03 21:16:26.064 29619-29619/? I/xp.chen: 音频数据
2019-04-03 21:16:26.064 29619-29619/? I/xp.chen: sample_rate = 44100, channels = 2, sample_format = 8

FFmpeg: AVCodecParameters 结构体分析的更多相关文章

  1. FFmpeg: AVPacket 结构体分析

    AVPacket是FFmpeg中很重要的一个数据结构,它保存了解封装之后,解码之前的数据(注意:仍然是压缩后的数据)和关于这些数据的一些附加信息,如显示时间戳(pts).解码时间戳(dts).数据时长 ...

  2. FFmpeg: AVFormatContext 结构体分析

    AVFormatContext 结构体分析这个结构体描述了一个媒体文件或媒体流的构成和基本信息.这是FFMpeg中最为基本的一个结构,是其他所有结构的根,是一个多媒体文件或流的根本抽象.主要成员释义: ...

  3. FFMPEG结构体分析:AVPacket

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  4. FFMPEG结构体分析:AVStream

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  5. FFMPEG结构体分析:AVCodec

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  6. FFMPEG结构体分析:AVIOContext

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  7. FFMPEG结构体分析:AVCodecContext

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  8. FFMPEG结构体分析:AVFormatContext

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrameFFMPEG结构体分析:AVFormatContextFFMPEG结构体分析:AVCodecContext ...

  9. FFMPEG结构体分析:AVFrame

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrameFFMPEG结构体分析:AVFormatContextFFMPEG结构体分析:AVCodecContext ...

随机推荐

  1. DP-hdu1260

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1260 题目描述: 题目大意:每一个人去电影票买票,有两种买票方法:1.自己单人买:2.与前面的人一起买 ...

  2. 最短路(Bellman)-Hdu1874畅通工程序

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874 题目: 某省自从实行了很多年的畅通工程计划后,终于修建了很多路.不过路多了也不好,每次要从一个城 ...

  3. Linux- Showdown 命令详解

    语法 shutdown(选项)(参数) [选项] -c:当执行"shutdown -h 11:50"指令时,只要按+键就可以中断关机的指令: -f:重新启动时不执行fsck: -F ...

  4. python的random模块(生成验证码)

    python的random模块(生成验证码) random模块常用方法 random.random() #生成0到1之间的随机数,没有参数,float类型 random.randint(1, 3) # ...

  5. kali linux系统配置 避免踩坑

    使用kali一个多月,重新安装kail也三次了,下面是安装完系统后,做如下系统配置,必须要做的配置,让自己以后不要踩坑. kail更新系统 1.添加更新源,前面已经介绍,不再多说 2获取更新数据,命令 ...

  6. VB定义变量

    定义变量可以使用显式或隐式两种方式定义: 1.显式定义:Dim 变量名 As 类型 2.隐式定义:使用类型说明符 类型说明符如下: %——整型 &——长整型 !——单精度浮点数 #——双精度浮 ...

  7. jQuery Ajax -附示例

    jQuery其实就是一个JavaScript的类库,其将复杂的功能做了上层封装,使得开发者可以在其基础上写更少的代码实现更多的功能. jQuery 不是生产者,而是大自然搬运工. jQuery Aja ...

  8. Codeforces.914D.Bash and a Tough Math Puzzle(线段树)

    题目链接 \(Description\) 给定一个序列,两种操作:一是修改一个点的值:二是给一个区间\([l,r]\),问能否只修改一个数使得区间gcd为\(x\). \(Solution\) 想到能 ...

  9. [BZOJ2238]Mst

    [BZOJ2238]Mst 题目大意: 给你一个\(n(n\le50000)\)个点,\(m(m\le10^5)\)条边的无向带权图.\(q(q\le10^5)\)次询问,每次询问去掉一条边后图能否连 ...

  10. Unity枚举和字符串的相互转换

    直接上代码,见下图: public enum enumEx { A, B, C, D, } public class enumTest : MonoBehaviour { void Start () ...