函数原型 AVIOContext *avio_alloc_context( unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t (*seek)(void *opaque, int64_t offset, int whence)) { //创建一个AVIOContext结构体 AVIOContext *s = av_mallocz(sizeof(AVIOContext)); if (!s) return NULL; //初始化AVIOContext结构体 ffio_init_context(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); return s; } #define BUF_SIZE 1024*16 AVIOContext* pAVIOContext = avio_alloc_context(pAVIOContext, BUF_SIZE, 0, this, ReadInputData, NULL, NULL); ReadInputData函数将赋值给read_packet,当调用avcodec_send_packet函数,将会从ReadInputData读取指定的的BUF_SIZE 来进行分帧解析 疑问 设置FFmpeg读缓存区的大小,应该怎么设置比较合理
本文转自fengyuzaitu 51CTO博客,原文链接:http://blog.51cto.com/fengyuzaitu/2055849,如需转载请自行联系原作者