我正在尝试从我的 ar 无人机流式传输视频,但它无法正常工作。我已经安装了 ffmpeg 2.6 版,正在使用 Ubuntu 14.04、node.js 和 ar-drone npm 模块。我也在使用 1.0 版的 ar 无人机。有人告诉我我需要使用 2.0,因为这是构建模块所使用的,但如果我不需要,我宁愿不购买新的。下面是我正在使用的代码
var arDrone = require('ar-drone');
var http = require('http');
console.log('Connecting png stream ...');
var pngStream = arDrone.createClient().getPngStream();
var lastPng;
pngStream
.on('error', console.log)
.on('data', function(pngBuffer) {
lastPng = pngBuffer;
});
var server = http.createServer(function(req, res) {
if (!lastPng) {
res.writeHead(503);
res.end('Did not receive any png data yet.');
return;
}
res.writeHead(200, {'Content-Type': 'image/png'});
res.end(lastPng);
});
server.listen(8080, function() {
console.log('Serving latest png on port 8080 ...');
});
当我运行它并在浏览器中访问http://localhost:8080/时,我收到错误消息“尚未收到任何 png 数据”。这是因为我使用的是 1.0 版的无人机吗?