Node.js 在NodeJS应用程序中使用内置套接字
我设计了一个正常工作的NodeJS应用程序,它正确地使用FFMPEG进行视频转换。我在使用socket.io时运气不太好,所以我想在Node中使用本机socket类。这是迄今为止我的节点应用程序Node.js 在NodeJS应用程序中使用内置套接字,node.js,sockets,Node.js,Sockets,我设计了一个正常工作的NodeJS应用程序,它正确地使用FFMPEG进行视频转换。我在使用socket.io时运气不太好,所以我想在Node中使用本机socket类。这是迄今为止我的节点应用程序具体地说,我需要在('end',function()”上的“中发送套接字事件或消息 var ffmpeg = require('./lib/fluent-ffmpeg'); var express = require('express'), multer = require('multer'
具体地说,我需要在('end',function()”上的“中发送套接字事件或消息
var ffmpeg = require('./lib/fluent-ffmpeg');
var express = require('express'),
multer = require('multer');
var app = express();
//auto save file to uploads folder
app.use(multer({ dest: './uploads/'}))
var temp;
app.post('/', function (req, res) {
console.log(req.body); //contains the variables
console.log("req.files ="+ req.files); //contains the file references
console.log("req.files.Filedata.path ="+ req.files.Filedata.path );
temp=req.files.Filedata.path;
console.log("temp ="+temp);
// make sure you set the correct path to your video file
var proc = ffmpeg('./'+temp)
// set audio bitrate
.audioBitrate('128k')
// set audio codec
.audioCodec('libmp3lame')
// set output format to force
.format('avi')
// setup event handlers
.on('end', function() {
console.log('file has been converted succesfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
// save to file
.save('./converted/converted.avi');
res.send('Thank you for uploading!');
});
app.listen(8080);
你没有在应用程序中使用套接字…你试图与之通信的另一端是什么?在这种情况下,套接字只是网络连接,而不是你可以用来与web浏览器通信的东西,这看起来就像你正在尝试做的。不,我不是与web浏览器通信,而是与桌面通信op(空气)应用。