Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

recordrtc

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recordrtc - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

static/RecordRTC.js

156

handlers.js

@@ -1,4 +0,4 @@

// 2013, Muaz Khan - www.MuazKhan.com
// MIT License - www.WebRTC-Experiment.com/licence
// Experiments - github.com/muaz-khan/WebRTC-Experiment
// Muaz Khan - www.MuazKhan.com
// MIT License - www.WebRTC-Experiment.com/licence
// Experiments - github.com/muaz-khan/WebRTC-Experiment

@@ -36,74 +36,5 @@ var config = require('./config'),

if (isWin) {
// following command tries to merge wav/webm files using ffmpeg
var merger = __dirname + '\\merger.bat';
var audioFile = __dirname + '\\uploads\\' + files.audio.name;
var videoFile = __dirname + '\\uploads\\' + files.video.name;
var mergedFile = __dirname + '\\uploads\\' + files.audio.name.split('.')[0] + '-merged.webm';
// if a "directory" has space in its name; below command will fail
// e.g. "c:\\dir name\\uploads" will fail.
// it must be like this: "c:\\dir-name\\uploads"
var command = merger + ', ' + videoFile + " " + audioFile + " " + mergedFile + '';
var cmd = exec(command, function(error, stdout, stderr) {
if (error) {
console.log(error.stack);
console.log('Error code: ' + error.code);
console.log('Signal received: ' + error.signal);
response.statusCode = 404;
response.end();
} else {
response.statusCode = 200;
response.writeHead(200, { 'Content-Type': 'application/json' });
response.end(files.audio.name.split('.')[0] + '-merged.webm');
// removing audio/video files
fs.unlink(audioFile);
fs.unlink(videoFile);
// auto delete file after 1-minute
setTimeout(function() {
fs.unlink(mergedFile);
}, 60 * 1000);
}
});
} else { // its probably *nix, assume ffmpeg is available
var audioFile = __dirname + '/uploads/' + files.audio.name;
var videoFile = __dirname + '/uploads/' + files.video.name;
var mergedFile = __dirname + '/uploads/' + files.audio.name.split('.')[0] + '-merged.webm';
var util = require('util'),
exec = require('child_process').exec;
//child_process = require('child_process');
var command = "ffmpeg -i " + videoFile + " -i " + audioFile + " -map 0:0 -map 1:0 " + mergedFile;
var child = exec(command, function(error, stdout, stderr){
stdout ? util.print('stdout: ' + stdout) : null;
stderr ? util.print('stderr: ' + stderr) : null;
if (error) {
console.log('exec error: ' + error);
response.statusCode = 404;
response.end();
} else {
response.statusCode = 200;
response.writeHead(200, { 'Content-Type': 'application/json' });
response.end(files.audio.name.split('.')[0] + '-merged.webm');
// removing audio/video files
fs.unlink(audioFile);
fs.unlink(videoFile);
// auto delete file after 1-minute
setTimeout(function() {
fs.unlink(mergedFile);
}, 60 * 1000);
}
});
ifWin(response, files);
} else {
ifMac(response, files);
}

@@ -159,4 +90,79 @@ }

function ifWin(response, files) {
// following command tries to merge wav/webm files using ffmpeg
var merger = __dirname + '\\merger.bat';
var audioFile = __dirname + '\\uploads\\' + files.audio.name;
var videoFile = __dirname + '\\uploads\\' + files.video.name;
var mergedFile = __dirname + '\\uploads\\' + files.audio.name.split('.')[0] + '-merged.webm';
// if a "directory" has space in its name; below command will fail
// e.g. "c:\\dir name\\uploads" will fail.
// it must be like this: "c:\\dir-name\\uploads"
var command = merger + ', ' + videoFile + " " + audioFile + " " + mergedFile + '';
var cmd = exec(command, function(error, stdout, stderr) {
if (error) {
console.log(error.stack);
console.log('Error code: ' + error.code);
console.log('Signal received: ' + error.signal);
} else {
response.statusCode = 200;
response.writeHead(200, { 'Content-Type': 'application/json' });
response.end(files.audio.name.split('.')[0] + '-merged.webm');
// removing audio/video files
fs.unlink(audioFile);
fs.unlink(videoFile);
// auto delete file after 1-minute
setTimeout(function() {
fs.unlink(mergedFile);
}, 60 * 1000);
}
});
}
function ifMac(response, files) {
// its probably *nix, assume ffmpeg is available
var audioFile = __dirname + '/uploads/' + files.audio.name;
var videoFile = __dirname + '/uploads/' + files.video.name;
var mergedFile = __dirname + '/uploads/' + files.audio.name.split('.')[0] + '-merged.webm';
var util = require('util'),
exec = require('child_process').exec;
//child_process = require('child_process');
var command = "ffmpeg -i " + videoFile + " -i " + audioFile + " -map 0:0 -map 1:0 " + mergedFile;
var child = exec(command, function(error, stdout, stderr){
stdout ? util.print('stdout: ' + stdout) : null;
stderr ? util.print('stderr: ' + stderr) : null;
if (error) {
console.log('exec error: ' + error);
response.statusCode = 404;
response.end();
} else {
response.statusCode = 200;
response.writeHead(200, { 'Content-Type': 'application/json' });
response.end(files.audio.name.split('.')[0] + '-merged.webm');
// removing audio/video files
fs.unlink(audioFile);
fs.unlink(videoFile);
// auto delete file after 1-minute
setTimeout(function() {
fs.unlink(mergedFile);
}, 60 * 1000);
}
});
}
exports.home = home;
exports.upload = upload;
exports.serveStatic = serveStatic;
{
"name": "recordrtc",
"preferGlobal": true,
"version": "0.0.4",
"version": "0.0.5",
"author": {

@@ -30,3 +30,9 @@ "name": "Muaz Khan",

"ffmpeg",
"audio/video recording"
"audio-recording",
"video-recording",
"gif-recording",
"audio/video recording",
"webp",
"webm",
"wav"
],

@@ -43,4 +49,4 @@ "analyze": false,

"homepage": "https://github.com/muaz-khan/WebRTC-Experiment",
"_id": "recordrtc@0.0.4",
"_id": "recordrtc@0.0.5",
"_from": "recordrtc@"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc