使用FFmpeg合并2个mp3文件

时间:2015-12-28 14:56:33

标签: android audio ffmpeg mp3

我需要使用ffMpeg合并两个mp3文件 我使用此代码,但它不起作用

我想执行此

ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex amerge -c:a libmp3lame -q:a 4 output.mp3

为什么我的代码没有工作?

和我的完整输出日志,问题未知编码器' libmp3lame'

        01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   built on Oct  7 2014 15:05:17 with gcc 4.8 (GCC)
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   configuration: --target-os=linux --cross-prefix=/home/sb/Source-Code/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/sb/Source-Code/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/sb/Source-Code/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/sb/Source-Code/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/sb/Source-Code/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   libavutil      54.  7.100 / 54.  7.100
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   libavcodec     56.  1.100 / 56.  1.100
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   libavformat    56.  4.101 / 56.  4.101
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   libavdevice    56.  0.100 / 56.  0.100
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   libavfilter     5.  1.100 /  5.  1.100
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   libswscale      3.  0.100 /  3.  0.100
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   libswresample   1.  1.100 /  1.  1.100
01-06 11:48:13.560 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   libpostproc    53.  0.100 / 53.  0.100
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout Input #0, mp3, from '/storage/emulated/0/a.mp3':
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   Metadata:
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     title           : Creep
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     album           : Pablo Honey
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     track           : 2/13
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     disc            : 1/1
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     artist          : Radiohead
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     genre           : Alternative
-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     publisher       : EMI Music Distribution
-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     album_artist    : Radiohead
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     composer        : Colin Greenwood/Ed O'Brien/Jonny Greenwood/Phil Selway/Thom Yorke
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     date            : 1993
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   Duration: 00:03:55.91, start: 0.025057, bitrate: 320 kb/s
01-06 11:48:13.572 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
01-06 11:48:13.573 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     Metadata:
01-06 11:48:13.573 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout       encoder         : LAME3.97 
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout [mp3 @ 0x2b403a90] Estimating duration from bitrate, this may be inaccurate
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout Input #1, mp3, from '/storage/emulated/0/b.mp3':
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   Metadata:
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     title           : This is Love                  
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     artist          : Chirs de Burgh                
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     album           : This Way Up                   
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     date            : 1994
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     comment         :                               
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout   Duration: 00:03:47.67, start: 0.000000, bitrate: 128 kb/s
01-06 11:48:13.577 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout     Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
01-06 11:48:13.579 6119-6472/com.uraroji.garage.android.mp3recvoice D/test: shellout Unknown encoder 'libmp3lame'
01-06 11:48:13.580 6119-6473/com.uraroji.garage.android.mp3recvoice D/dalvikvm: threadid=14: exiting
01-06 11:48:13.580 6119-6473/com.uraroji.garage.android.mp3recvoice D/dalvikvm: threadid=14: bye!
01-06 11:48:13.580 6119-6119/com.uraroji.garage.android.mp3recvoice D/test: processComplete 1
01-06 11:48:13.580 6119-6472/com.uraroji.garage.android.mp3recvoice D/dalvikvm: threadid=13: exiting
01-06 11:48:13.581 6119-6472/com.uraroji.garage.android.mp3recvoice D/dalvikvm: threadid=13: bye!

1 个答案:

答案 0 :(得分:0)

MP3编码器

FFmpeg没有原生MP3编码器,因此您必须使用外部库(libmp3lame或libshine)来支持MP3编码。但是,您的ffmpeg版本未使用--enable-libmp3lame--enable-libshine进行编译。您将不得不重新编译ffmpeg

libmp3lame更常见,但libshine用于定点MP3编码,在ARM设备上可能更快(但我从未进行过任何比较)。

amerge

您的命令使用Explicit Loading过滤器合并两个立体声音频文件。这将产生4通道输出。如果要将输出缩混为立体声,请添加-ac 2