I use ffmpeg to merge mp3's in my node server. It works but the offset doesn't have any effect.. I can't see what is wrong then i'd like to get your help :)
var command = "ffmpeg -i "+ input1+ " -itsoffset 40 -i " + input2 +" -filter_complex amerge -c:a libmp3lame -q:a 4 "+ output;
exec(command, function (error, stdout, stderr) {
if (stdout) console.log(stdout);
if (stderr) console.log(stderr);
if (error) {
console.log('exec error: ' + error);
response.statusCode = 404;
response.end();
} else {
// Do something
}
});
I tried it also on my computer just in the terminal and it also works with the same problem..
Thanks, Itzhak
Instead of using itsoffset
you can append a silent audio to the beginning of the audio. Assume we have three audios to be merged each of 10 sec long. So you can append silent audio as follows.
There after you can mix all these audios together. To create a silent audio you can use aevalsrc
filter with filter_complex
. Following will work for the above example.
ffmpeg -i 0.mp3 -i 1.mp3 -i 2.mp3 -filter_complex
"aevalsrc=0:d=10[s1];
aevalsrc=0:d=20[s2];
[s1][1:a]concat=n=2:v=0:a=1[ac1];
[s2][2:a]concat=n=2:v=0:a=1[ac2];
[0:a][ac1][ac2]amix=3[aout]" -map [aout] out.mp3
Here [s1]
and [s2]
are the corresponding silent audio source for second and third input audio streams. Then each silent source will be concatenated with there corresponding audio streams using concat
filter. Finally all concatenated audios will be mixed using amix
filter.
Else you can try amerge
and adelay
where doc itself has a clear explanation.
Hope this helps!