Skip to content

Commit d21a309

Browse files
committed
options added to the mergeToFile process with addOption are applied on the intermediate files
1 parent fe2e162 commit d21a309

File tree

6 files changed

+36
-1
lines changed

6 files changed

+36
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
lib-cov
44
*.swp
55
.idea
6+
*.iml

lib/processor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,11 @@ exports = module.exports = function Processor(command) {
137137
'-i', _mergeSource,
138138
'-qscale:v',1,
139139
fname
140-
].join(' ')
140+
]
141141
];
142+
143+
command[1] = self.options.additional.concat(command[1]).join(' ');
144+
142145
exec(command.join(' '),function(err, stdout, stderr) {
143146
if(err)throw err;
144147
_callback(fname);

test/assets/testaudio-one.wav

86.2 KB
Binary file not shown.

test/assets/testaudio-three.wav

86.2 KB
Binary file not shown.

test/assets/testaudio-two.wav

86.2 KB
Binary file not shown.

test/processor.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,37 @@ describe('Processor', function() {
216216
});
217217
});
218218

219+
describe('mergeToFile', function() {
220+
221+
it('should merge multiple files', function(done) {
222+
var testFile = path.join(__dirname, 'assets', 'testMergeAddOption.wav');
223+
var srcFile = path.join(__dirname, 'assets', 'testaudio-one.wav');
224+
var src1File = path.join(__dirname, 'assets', 'testaudio-two.wav');
225+
var src2File = path.join(__dirname, 'assets', 'testaudio-three.wav');
226+
227+
new Ffmpeg({source: srcFile, nolog: true})
228+
.mergeAdd(src1File)
229+
.mergeAdd(src2File)
230+
.mergeToFile(testFile, function(stdout, stderr, err) {
231+
assert.ok(!err);
232+
fs.exists(testFile, function(exist) {
233+
exist.should.true;
234+
// check filesize to make sure conversion actually worked
235+
fs.stat(testFile, function(err, stats) {
236+
assert.ok(!err && stats);
237+
stats.size.should.above(0);
238+
stats.isFile().should.true;
239+
// unlink file
240+
fs.unlinkSync(testFile);
241+
done();
242+
});
243+
});
244+
});
245+
246+
});
247+
248+
});
249+
219250
describe('writeToStream', function() {
220251
it('should save the output file properly to disk using a stream', function(done) {
221252
var testFile = path.join(__dirname, 'assets', 'testConvertToStream.flv');

0 commit comments

Comments
 (0)