1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
var FFmpeg = require('fluent-ffmpeg');
var audioFile = path.join(__dirname, '/enregistrements_video/', fileName + '.wav'),
videoFile = path.join(__dirname, '/enregistrements_video/', fileName + '.webm'),
mergedFile = path.join(__dirname, '/enregistrements_video/', fileName + '-merged.webm');
new FFmpeg({
source: videoFile
})
.addInput(audioFile)
.on('error', function (err) {
NameSpace
.to("/ProjetTestDeveloppez/Combobox#"+findBy(user.name))
.emit('ffmpeg-error', 'ffmpeg : An error occurred: ' + err.message)
.to("/ProjetTestDeveloppez/Combobox#"+findBy(destination.name))
.emit('ffmpeg-error', 'ffmpeg : An error occurred: ' + err.message);
})
.on('progress', function (progress) {
console.log("progress ffmpeg :"+JSON.stringify(progress));
NameSpace
.to("/ProjetTestDeveloppez/Combobox#"+findBy(user.name))
.emit('ffmpeg-output', {progressVal:progress.frames})
.to("/ProjetTestDeveloppez/Combobox#"+findBy(destination.name))
.emit('ffmpeg-output', {progressVal:progress.frames});
})
.on('end', function () {
NameSpace
.to("/ProjetTestDeveloppez/Combobox#"+findBy(user.name))
.emit('merged finishing', {fichier:fileName + '-merged.webm'})
.to("/ProjetTestDeveloppez/Combobox#"+findBy(destination.name))
.emit('merged finishing', {fichier:fileName + '-merged.webm'});
console.log('fin Merging!');
// supprimer audio(.wav) et video(.webm)
fs.unlink(audioFile);
fs.unlink(videoFile);
})
.saveToFile(mergedFile); |
Partager