mp3 audio merging with -itsoffset using ffmpeg: no effect

℡╲_俬逩灬. 提交于 2019-12-04 23:55:20

问题


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


回答1:


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.

  • First audio : No silent audio
  • Second audio : Append 10 sec silent audio to the beginning
  • Third audio : Append (10 sec) x 2 silent audio to the beginning

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!



来源:https://stackoverflow.com/questions/31941140/mp3-audio-merging-with-itsoffset-using-ffmpeg-no-effect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!