我需要在kafka的帮助下实现视频流传输。我能够在node.js的帮助下将视频流传输到浏览器,但是我想知道如何将视频从node.js传输到kafka制作人还有消费者。
我获得了用于发送短信的代码,但是我想发送实时视频。
const Transform = require('stream').Transform;
const ProducerStream = require('./lib/producerStream');
const _ = require('lodash');
const producer = new ProducerStream();
const stdinTransform = new Transform({
objectMode: true,
decodeStrings: true,
transform (text, encoding, callback) {
text = _.trim(text);
console.log(`pushing message ${text} to ExampleTopic`);
callback(null, {
topic: 'ExampleTopic',
messages: text
});
}
});
process.stdin.setEncoding('utf8');
process.stdin.pipe(stdinTransform).pipe(producer);