您的位置:首页 > 其它

ffplay相关函数

2016-03-26 18:32 330 查看
av_gettime_relative

int64_t av_gettime_relative(void)

{

#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)

struct timespec ts;

clock_gettime(CLOCK_MONOTONIC, &ts); 从系统启动这一刻起开始计时,不受系统时间被用户改变的影响。

return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000; //秒跟纳秒

#else

return av_gettime();

#endif

}

av_get_channel_layout_nb_channels av_get_default_channel_layout

通过av_get_channel_layout_nb_channels()和av_get_default_channel_layout()这些函数可以得到channels和channellayout的转换。

libavutil中的audioconvert.c定义channellayout和channels的相关map:

channel_layout_map[]

{ "mono",

1, AV_CH_LAYOUT_MONO},

{ "stereo", 2, AV_CH_LAYOUT_STEREO},

{ "2.1", 3, AV_CH_LAYOUT_2POINT1},

{ "3.0", 3, AV_CH_LAYOUT_SURROUND},

{"3.0(back)", 3, AV_CH_LAYOUT_2_1},

{ "4.0", 4, AV_CH_LAYOUT_4POINT0},

{ "quad", 4, AV_CH_LAYOUT_QUAD},

{"quad(side)", 4, AV_CH_LAYOUT_2_2},

{ "3.1", 4, AV_CH_LAYOUT_3POINT1},

{ "5.0", 5, AV_CH_LAYOUT_5POINT0_BACK},

{"5.0(side)", 5, AV_CH_LAYOUT_5POINT0},

{ "4.1", 5, AV_CH_LAYOUT_4POINT1},

{ "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK},

{"5.1(side)", 6, AV_CH_LAYOUT_5POINT1},

{ "6.0", 6, AV_CH_LAYOUT_6POINT0},

{"6.0(front)", 6, AV_CH_LAYOUT_6POINT0_FRONT},

{"hexagonal", 6, AV_CH_LAYOUT_HEXAGONAL},

{ "6.1", 7, AV_CH_LAYOUT_6POINT1},

{ "6.1", 7, AV_CH_LAYOUT_6POINT1_BACK},

{"6.1(front)", 7, AV_CH_LAYOUT_6POINT1_FRONT},

{ "7.0", 7, AV_CH_LAYOUT_7POINT0},

{"7.0(front)", 7, AV_CH_LAYOUT_7POINT0_FRONT},

{ "7.1", 8, AV_CH_LAYOUT_7POINT1},

{"7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE},

{"octagonal", 8, AV_CH_LAYOUT_OCTAGONAL},

{"downmix", 2, AV_CH_LAYOUT_STEREO_DOWNMIX,},

av_q2d

static inline double av_q2d(AVRational a){

return a.num / (double) a.den;

}

av_rescale

int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;;返回 a*b/c。

av_rescale_q

int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);返回 a * bq / cq。

av_sample_get_buffer_size

用来计算音频占用的字节数,音频所占用字节数 = 通道数 * 采用频率(Hz) * 采用位数(byte)。

av_seek_frame

当需要把视频跳转到N秒的时候可以使用下面的方法:

int64_t timestamp = N * AV_TIME_BASE;

av_seek_frame(fmtctx, index_of_video, timestamp, AVSEEK_FLAG_BACKWARD);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: