3
我已創建套接字連接並使用該連接發送二進制流數據到服務器和服務器端我現在使用該數據獲取二進制數據我想創建一個視頻文件並將其保存在服務器上。我成功地到達現在沒有任何方式將二進制數據轉換爲視頻文件。請幫助實現。從套接字連接收集的二進制數據生成視頻文件
服務器端米使用的node.js創建JavaScript
服務器端代碼套接字服務器,並從客戶端:
var server = http.createServer(function(request, response) {
//Creating websocket server
});
server.listen(1337, function() { }); // listen to 1337 port
// create the server
wsServer = new WebSocketServer({
httpServer: server
});
// WebSocket server
wsServer.on('request', function(request) {
var connection = request.accept(null, request.origin);
// all messages from client will receive here.
connection.on('message', function(message) {
if (message.type === 'utf8') {
}else if (message.type === 'binary') {
//here i will get the binary data not want to create the video file using this
}
});
connection.on('close', function(connection) {
});
})
客戶端:
window.WebSocket = window.WebSocket || window.MozWebSocket;
var connection = new WebSocket('ws://localhost:1337');
connection.binaryType = 'arraybuffer';
var options = {
mimeType: 'video/webm;codecs=vp9'
};
mediaRecorder = new MediaRecorder(MediaStream, options);
mediaRecorder.ondataavailable = function(event) {
if (event.data.size > 0) {
recordedChunks.push(event.data);
connection.onopen = function() {
var byteArray = new Uint8Array(event.data);
connection.send(byteArray.buffer);
};
}
};
是從視頻文件中的二進制流? – Sven
沒有我記錄用戶操作使用鉻擴展chrome.tabCapture.capture –