我试图连接两个mp3文件,一个在几秒钟之后用另一个用FFmpeg安装在Android应用程序中。我正在使用this library
为了达到这个目的,我用 aevalsrc 创建了一个音频静音,然后连接到第二个输入。之后,使用 amix ,我将结果与第一个输入合并。这是命令:
String[] cmd = {"-i", "/storage/emulated/0/input1.mp3", "-i", "/storage/emulated/0/input2.mp3", "-filter_complex", "aevalsrc=0:d=8[s1]; [s1][1:a]concat=n=2:a=1:v=0[a2]; [0:a][a2]amix=inputs=2:duration=longest", "-c:a", "libmp3lame", "/storage/emulated/0/finito.mp3"};
输出mp3已创建,但它只包含第一个输入,就像它只是制作副本一样。 FFMpeg版本是3.0.1。显示的输出是:
I/ffmpeg(27265): [mp3 @ 0xb5bdf000] Skipping 0 bytes of junk at 4513.
I/ffmpeg(27265): Input #0, mp3, from '/storage/emulated/0/input1.mp3':
I/ffmpeg(27265): Metadata:
I/ffmpeg(27265): track : 0
I/ffmpeg(27265): TYER : 0
I/ffmpeg(27265): Duration: 00:00:01.75, start: 0.000000, bitrate: 148 kb/s
I/ffmpeg(27265): Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
I/ffmpeg(27265): [mp3 @ 0xb5bdf600] Skipping 0 bytes of junk at 4513.
I/ffmpeg(27265): Input #1, mp3, from '/storage/emulated/0/input2.mp3':
I/ffmpeg(27265): Metadata:
I/ffmpeg(27265): track : 0
I/ffmpeg(27265): TYER : 0
I/ffmpeg(27265): Duration: 00:00:00.37, start: 0.000000, bitrate: 226 kb/s
I/ffmpeg(27265): Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
I/ffmpeg(27265): Output #0, mp3, to '/storage/emulated/0/finito.mp3':
I/ffmpeg(27265): Metadata:
I/ffmpeg(27265): TRCK : 0
I/ffmpeg(27265): TYER : 0
I/ffmpeg(27265): TSSE : Lavf57.25.100
I/ffmpeg(27265): Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp (default)
I/ffmpeg(27265): Metadata:
I/ffmpeg(27265): encoder : Lavc57.24.102 libmp3lame
I/ffmpeg(27265): Stream mapping:
I/ffmpeg(27265): Stream #0:0 (mp3) -> amix:input0
I/ffmpeg(27265): Stream #1:0 (mp3) -> concat:in1:a0
I/ffmpeg(27265): amix -> Stream #0:0 (libmp3lame)
I/ffmpeg(27265): Press [q] to stop, [?] for help
I/ffmpeg(27265): size= 18kB time=00:00:01.09 bitrate= 133.0kbits/s speed=2.18x
I/ffmpeg(27265): Error while filtering: Out of memory
I/ffmpeg(27265): size= 28kB time=00:00:01.75 bitrate= 131.1kbits/s speed=2.43x
I/ffmpeg(27265): video:0kB audio:28kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.999261%
答案 0 :(得分:0)
您收到此错误:
I/ffmpeg(27265): Error while filtering: Out of memory
改用adelay。
String[] cmd = {"-i", "/storage/emulated/0/input1.mp3", "-i", "/storage/emulated/0/input2.mp3", "-filter_complex", "[1]adelay=8000|8000[a2];[0:a][a2]amix=inputs=2:duration=longest", "-c:a", "libmp3lame", "/storage/emulated/0/finito.mp3"};