首页 > 其他 > 详细

ffmpeg从内存读取文件

时间:2016-09-16 21:10:21      阅读:194      评论:0      收藏:0      [点我收藏+]

正常情况,ffmpeg直接从文件读取

AVFormatContext * _ctx = NULL;
avformat_open_input(&_ctx, _filePath, 0, 0);

 我们也可以自定义从内存读取,这样,可以用于读取一些加密的视频文件

    int fill_iobuffer(void * opaque,uint8_t *buf, int bufsize){  
        if(!feof(fp_open)){  
            int true_size=fread(buf,1,bufsize,fp_open);  
            return true_size;  
        }else{  
            return -1;  
        }  
    }



AVFormatContext * _ctx = NULL;
unsigned char* _iobuffer = (unsigned char*)av_malloc(32768);
AVIOContext* _avio = avio_alloc_context(_iobuffer , 32768 , 0 , NULL,fill_iobuffer,NULL,NULL);
_ctx->pb = _avio;

fp_open=fopen(_filename,"rb+");  

if ((ret = avformat_open_input(&_ctx, "nothing", 0, 0)) < 0) {
	printf( "Could not open input file.");
}

 

ffmpeg从内存读取文件

原文:http://www.cnblogs.com/IWings/p/5877066.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!