ffmpeg使用android将多个音频文件合并为单个音频文件


1

我使用以下命令合并多个音频文件:

String s="-i "+mFileTemp.getPath()+" -i "+mFileTemp2.getPath()+" -i "+mFileTemp3.getPath()+" -filter_complex [0:0][1:0][2:0]concat=n=3:v=0:a=1[out] -map [out] "+originalFile.getPath();

其中mFileTemp,mFileTemp2,mFileTemp3是输入音频文件的路径,其中originalFile是输出音频文件路径。

在这里我附上分裂后的传递方式:

ffmpeg分裂后传递参数

收到以下错误:

ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-
prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-
android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --
enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-
android/toolchain-android/sysroot --enable-pic --enable-libx264 --
enable-libass --enable-libfreetype --enable-libfribidi --enable-
libmp3lame --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/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --
prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --
extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-
android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-
overflow -fstack-protector-all' --extra-ldflags='-
L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-
z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-
cxxflags=
libavutil      55. 17.103 / 55. 17.103
libavcodec     57. 24.102 / 57. 24.102
libavformat    57. 25.100 / 57. 25.100
libavdevice    57.  0.101 / 57.  0.101
libavfilter     6. 31.100 /  6. 31.100
libswscale      4.  0.100 /  4.  0.100
libswresample   2.  0.101 /  2.  0.101
libpostproc    54.  0.100 / 54.  0.100
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, wav, from '/storage/emulated/0/AudioRecorder/cello.wav':
Duration: 00:00:03.75, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2
channels, s16, 1411 kb/s
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, wav, from '/storage/emulated/0/AudioRecorder/strings.wav':
Duration: 00:00:05.00, bitrate: 1411 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2
channels, s16, 1411 kb/s
Guessed Channel Layout for  Input Stream #2.0 : stereo
Input #2, wav, from
'/storage/emulated/0/AudioRecorder/ChillingMusic.wav':
Duration: 00:00:27.41, bitrate: 1411 kb/s
Stream #2:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2
channels, s16, 1411 kb/s
[AVFilterGraph @ 0xf6e49040] No such filter: ''
Error initializing complex filters.
Invalid argument

请有人帮助我,我做错了什么? 这个问题可能重复,但我找不到任何好的解决方案。


你的concat选项令人困惑。您有3个输入,每个输入1个流,但concat的输入标签将是3个输入,每个输入3个流。你需要添加 v=0 到你的concat,因为默认是 v=1,但你没有任何视频流。你的concat有3个输出标签,但我假设你想要一个。至于 No such filter: '' 我猜这是由于脚本中的命令分割,引用或执行不正确而不是问题 ffmpeg 命令本身。在尝试将命令添加到脚本之前,先获取命令。
llogan

@LordNeckbeard:谢谢你的回复。我找到了解决方案:String s =“ - i”+ mFileTemp.getPath()+“ - i”+ mFileTemp2.​​getPath()+“ - i”+ mFileTemp3.getPath()+“ - filter_complex [0:0] [ 1:0] [2:0] concat = n = 3:v = 0:a = 1 [out] -map [out]“+ originalFile.getPath();这对我有用
Myself

Answers:


2

我找到了上述问题的解决方案。我已经在问题中编辑了,

        String s="-i "+mFileTemp.getPath()+" -i "+mFileTemp2.getPath()+" -i "+mFileTemp3.getPath()+" -filter_complex [0:0][1:0][2:0]concat=n=3:v=0:a=1[out] -map [out] "+originalFile.getPath();

        String[] cmd= s.split(" ");

并将此字符串数组传递给:

         ffmpeg.execute(cmd...)

请注意 :我提到了 http://writingminds.github.io/ffmpeg-android-java/ 。与android集成

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.