Added MKV muxing support
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
module.exports = {
|
||||
merge: require('./merge'),
|
||||
stream: require('./stream')
|
||||
};
|
||||
|
||||
39
src/video/merge.js
Normal file
39
src/video/merge.js
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
var childProcess = require('child_process');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var os = require('os');
|
||||
|
||||
/**
|
||||
* Merges the subtitle and video files into a Matroska Multimedia Container.
|
||||
* @param {Object} config
|
||||
* @param {string} rtmpInputPath
|
||||
* @param {string} filePath
|
||||
* @param {function(Error)} done
|
||||
*/
|
||||
module.exports = function(config, rtmpInputPath, filePath, done) {
|
||||
var subtitlePath = filePath + '.' + config.format;
|
||||
var videoPath = filePath + path.extname(rtmpInputPath);
|
||||
childProcess.exec(_command() + ' ' +
|
||||
'-o "' + filePath + '.mkv" ' +
|
||||
'"' + videoPath + '" ' +
|
||||
'"' + subtitlePath + '"', {
|
||||
maxBuffer: Infinity
|
||||
}, function(err) {
|
||||
if (err) return done(err);
|
||||
fs.unlink(videoPath, function(err) {
|
||||
if (err) return done(err);
|
||||
fs.unlink(subtitlePath, done);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines the command for the operating system.
|
||||
* @private
|
||||
* @returns {string}
|
||||
*/
|
||||
function _command() {
|
||||
if (os.platform() !== 'win32') return 'mkvmerge';
|
||||
return path.join(__dirname, '../../bin/mkvmerge.exe');
|
||||
}
|
||||
@@ -23,6 +23,7 @@ module.exports = function(rtmpUrl, rtmpInputPath, swfUrl, filePath, done) {
|
||||
|
||||
/**
|
||||
* Determines the command for the operating system.
|
||||
* @private
|
||||
* @returns {string}
|
||||
*/
|
||||
function _command() {
|
||||
|
||||
Reference in New Issue
Block a user