使用FFmpeg修改Android音频文件音量出错

3

我是使用FFmpeg,需要改变音频的音量。

这是应该改变音频音量的命令

ffmpeg -i input.wav -filter:a "volume=1.5" output.wav

我从某个地方读到,如果文件已经存在,就必须覆盖该文件,所以要么删除文件,要么使用-y。当我尝试在没有-y命令的情况下执行它时,它从未到达onSuccess()onFailure(),但它总是打印出onStart()消息。

String[] cmdy = { "-i -y" , pcmtowavTempFile.toString(),  "-af", "volume=5", pcmtowavTempFile.toString()};
    ffmpeg.execute(cmdy, new ExecuteBinaryResponseHandler() {

        @Override
        public void onStart() {
            System.out.println("ayy: onStart");
        }

        @Override
        public void onSuccess(String message) {
            System.out.println("ayy: onSuccess");
            super.onSuccess(message);
        }
        @Override
        public void onFailure(String message) {
            System.out.println("ayy: onFailure " + message);
            super.onFailure(message);
        }
});

目前我遇到了这个错误:

ffmpeg version n4.0-39-gda39990 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.9.x (GCC) 20150123 (prerelease)
  configuration: --target-os=linux --cross-prefix=/root/bravobit/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/root/bravobit/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-ffprobe --enable-libopus --enable-libvorbis --enable-libfdk-aac --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-libvpx --enable-libass --enable-yasm --enable-pthreads --disable-debug --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-linux-perf --disable-doc --disable-shared --enable-static --enable-runtime-cpudetect --enable-nonfree --enable-network --enable-avresample --enable-avformat --enable-avcodec --enable-indev=lavfi --enable-hwaccels --enable-ffmpeg --enable-zlib --enable-gpl --enable-small --enable-nonfree --pkg-config=pkg-config --pkg-config-flags=--static --prefix=/root/bravobit/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/root/bravobit/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/root/bravobit/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-cxxflags=
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Unrecognized option 'i -y'.

这明确说明它不认可选项i -y,但正如我之前所说的那样,如果我删除-y,它就永远无法到达onSuccess()onFailure()

请帮我找到解决方案。谢谢。

1个回答

1

FFmpeg不支持原地编辑。输入文件必须与输出文件分开。此外,-i需要一个参数(输入文件名),该参数应该紧随其后。使用-y可以强制覆盖,并且您可以将其放在第一位。

因此,

{ "-y -i " , pcmtowavTempFile.toString(),  "-af", "volume=5", pcmtoSOMEOTHERTempFile.toString()};

这就是我刚刚想出来的...你需要将它放到另一个文件中才能让它工作,而且不必使用"-y" - Richard

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接