【发布时间】:2016-12-14 07:59:51
【问题描述】:
我想从摄像头接收视频流,使用 openCV 处理它(用于测试 - 绘制红色矩形)和实时流结果。
我已经可以读取相机帧,转换为 openCV Mat 并将它们改回 AVFrame。
从控制台即时启动 rtsp 服务器,使用:ffplay -rtsp_flags listen -i rtsp://127.0.0.1:8765/live.sdp 当我尝试调用 avio_open(); 时出现问题;
av_register_all();
avformat_network_init();
avcodec_register_all();
(...)
avformat_alloc_output_context2(&outputContext, NULL, "rtsp", outputPath.c_str());
outputFormat = outputContext->oformat;
cout << "Codec = " << avcodec_get_name(outputFormat->video_codec) << endl;
if (outputFormat->video_codec != AV_CODEC_ID_NONE) {
videoStream = add_stream(outputContext, &outputVideoCodec, outputFormat->video_codec);
}
char errorBuff[80];
int k = avio_open(&outputContext->pb, outputPath.c_str(), AVIO_FLAG_WRITE);
if (k < 0) {
cout << "code: " << k << endl;
fprintf(stderr, "%s \n", av_make_error_string(errorBuff, 80, k));
}
if (avformat_write_header(outputContext, NULL) < 0) {
fprintf(stderr, "Error occurred when writing header");
}
}
其中 outputPath = "rtsp://127.0.0.1:8765/live.sdp" avformat_alloc_output_context2 返回 0,但 avio_open
代码:-1330794744
未找到协议
我不知道出了什么问题。我正在使用来自https://ffmpeg.zeranoe.com/builds/ 64-bit Dev 的 ffmpeg 构建
【问题讨论】: