使用FFmpeg Android错误更改音频音量 [英] Changing Audio Volume using FFmpeg Android Error

查看:52
本文介绍了使用FFmpeg Android错误更改音频音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用FFmpeg,我需要更改 Audio 的音量.

I am using FFmpeg and I need to change the volume of the Audio.

这是应该更改音频音量的命令:

This is the command that should change the volume of the audio :

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

我从某处读取到它必须覆盖文件(如果文件已经存在),因此要么必须删除文件,要么使用 -y .当我尝试不使用 -y 命令执行此操作时,就再也不必使用 onSuccess()或´onFailure()了,但它总是打印出 onStart()消息.

I read from somewhere that it had to overwrite the file if it already existed so either one had to delete the file or use -y. When I tried to do it without the -y command it never got to onSuccess() or ´onFailure(), but it always printed out the onStart() message.

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().

Which clearly states that it does not recognize option i -y, but also as I said earlier then if I remove the -y it never gets to onSuccess() or onFailure().

帮我找到解决方案.谢谢.

help me to find a solution. Thanks.

推荐答案

FFmpeg不执行就地编辑.输入文件必须与输出文件分开.另外, -i 需要一个参数(输入文件名),该参数应紧随其后. -y 会强制覆盖,您可以将其放在第一位.

FFmpeg does NOT perform in-place editing. Input file has to be separate from output file. Also, -i expects an argument (input filename) which should follow next. -y forces overwrites and you can put it first.

所以

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

这篇关于使用FFmpeg Android错误更改音频音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆