[图片]main.zip这有一个参考文件,把回调里面的cncv去掉,需要ffmpeg库支持
问题已解决
//测试函数,保存cncodecFrame图像数据到文件中 void dumpSurfaceData(FILE *file, cncodecFrame *frame) { unsigned int i; unsigned int j; unsigned int planW; unsigned int planLen; unsigned int planeH; cnrtRet_t rtRet; for (i = 0; i < frame->planeNum; ++i) { planW = calc_plane_width(frame->pixelFmt, frame->width, i); planLen = calc_plane_length(frame->pixelFmt, frame->stride[i], frame->height, i); planeH = calc_plane_height(frame->pixelFmt, frame->height, i); if (frame->stride[i] == planW) { // LOG_INFO("frame->stride[i] %u planw %u\n", frame->stride[i], planW); void *cpuAddr; rtRet = (cnrtRet_t)cncodecMap(&cpuAddr, frame->plane[i].addr, frame->plane[i].size); if (rtRet != CNRT_RET_SUCCESS) { LOG_ERROR("call cncodecMap faild\n"); return; } rtRet = (cnrtRet_t)cncodecInvalidateCache(cpuAddr, frame->plane[i].size); if (rtRet != CNRT_RET_SUCCESS) { LOG_ERROR("call cncodecInvalidateCache faild\n"); return; } fwrite(cpuAddr, sizeof(char), planLen, file); rtRet = (cnrtRet_t)cncodecUnmap(cpuAddr, frame->plane[i].size); if (rtRet != CNRT_RET_SUCCESS) { LOG_ERROR("call cncodecUnmap faild\n"); return; } } else { void *tmp_buffer1 = malloc(planLen); char *tmp_buffer2 = (char *)malloc(planW * planeH); cnrtMemcpy(tmp_buffer1, (void *)frame->plane[i].addr, planLen, CNRT_MEM_TRANS_DIR_DEV2HOST); for (j = 0; j < planeH; ++j) { memcpy(tmp_buffer2 + j * planW, tmp_buffer1 + j * frame->stride[i], planW); } fwrite(tmp_buffer2, sizeof(char), planW * planeH, file); free(tmp_buffer1); free(tmp_buffer2); } } }
你好,可以参考:rtsp相关的解析代码,https://github.com/Cambricon/CNStream/tree/master/modules/source/src/data_handler_rtsp.cpp大体流程,通过 ffmpeg的接口,对rtsp码流解析,将码流数据放到内存缓冲区,循环读取该内存缓冲区的数据feed给codec进行解码,后续就是解码流程。展开
可以不通过CNStream来操作嘛?
你好,可以参考:rtsp相关的解析代码,https://github.com/Cambricon/CNStream/tree/master/modules/source/src/data_handler_rtsp.cpp
大体流程,通过 ffmpeg的接口,对rtsp码流解析,将码流数据放到内存缓冲区,循环读取该内存缓冲区的数据feed给codec进行解码,后续就是解码流程。
你好,请参考:https://github.com/Cambricon/CNStream/tree/master/samples/cns_launcher/decode,在filelist中将文件修改为url地址。也可以参考https://github.com/Cambricon/CNStream/tree/master/samples/cns_launcher目录下的例子。rtsp相关的解析代码,https://github.com/Cambricon/CNStream/tree/master/modules/source/src目录下。其他信息参考github上cnstream的doc。或者,通过ffmpeg将rtsp保存,在通过文件方式送入mlu decode进行解码。展开
你好,请参考:https://github.com/Cambricon/CNStream/tree/master/samples/cns_launcher/decode,在filelist中将文件修改为url地址。
也可以参考https://github.com/Cambricon/CNStream/tree/master/samples/cns_launcher目录下的例子。
rtsp相关的解析代码,https://github.com/Cambricon/CNStream/tree/master/modules/source/src目录下。
其他信息参考github上cnstream的doc。
或者,
通过ffmpeg将rtsp保存,在通过文件方式送入mlu decode进行解码。
请登录后评论