使用 FFMPEG 仅更改其中一个音频通道的音量

Change volume in only one of the audio channels with FFMPEG

我需要在使用 FFmpeg 的 android 应用程序中单独调整 mp3 文件的音量,为两个通道设置两个不同的值。 这是我正在执行的命令:

[-i, 0.mp3, -filter_complex, channelsplit[lpre][rpre];[lpre]volume=0.0[l];
[rpre]volume=1.0[r];[l][r]amix=inputs=2, 0.wav]

例如,在这种情况下,我希望输出具有正常的左声道静音和右声道静音。结果是两个通道上的音量相同。

这是改变通道音量的直接方法:

ffmpeg -i in.mp3 -af "pan=stereo:c0=0*c0|c1=1*c1" out.wav

由于您使用的是基于 linux 的 OS,您可能需要将双引号替换为单引号。

04-13 12:19:41.251: I/mp3 to wav(25097): [-i, /storage/emulated/0/beatmachine/volumi/0.mp3, -af, pan=stereo|c0=0*c0|c1=1*c1, /storage/emulated/0/beatmachine/volumi/0.wav]
04-13 12:19:41.574: I/ffmpeg(25097): successffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
04-13 12:19:41.574: I/ffmpeg(25097):   built with gcc 4.8 (GCC)
04-13 12:19:41.574: I/ffmpeg(25097):   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=
04-13 12:19:41.574: I/ffmpeg(25097):   libavutil      55. 17.103 / 55. 17.103
04-13 12:19:41.574: I/ffmpeg(25097):   libavcodec     57. 24.102 / 57. 24.102
04-13 12:19:41.574: I/ffmpeg(25097):   libavformat    57. 25.100 / 57. 25.100
04-13 12:19:41.574: I/ffmpeg(25097):   libavdevice    57.  0.101 / 57.  0.101
04-13 12:19:41.574: I/ffmpeg(25097):   libavfilter     6. 31.100 /  6. 31.100
04-13 12:19:41.574: I/ffmpeg(25097):   libswscale      4.  0.100 /  4.  0.100
04-13 12:19:41.574: I/ffmpeg(25097):   libswresample   2.  0.101 /  2.  0.101
04-13 12:19:41.574: I/ffmpeg(25097):   libpostproc    54.  0.100 / 54.  0.100
04-13 12:19:41.574: I/ffmpeg(25097): [mp3 @ 0xb5bd7000] Skipping 0 bytes of junk at 417.
04-13 12:19:41.574: I/ffmpeg(25097): Input #0, mp3, from '/storage/emulated/0/beatmachine/volumi/0.mp3':
04-13 12:19:41.574: I/ffmpeg(25097):   Duration: 00:00:00.29, start: 0.000000, bitrate: 139 kb/s
04-13 12:19:41.574: I/ffmpeg(25097):     Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
04-13 12:19:41.574: I/ffmpeg(25097): [Parsed_pan_0 @ 0xb5bdd410] Pure channel mapping detected: M 1
04-13 12:19:41.574: I/ffmpeg(25097): Output #0, wav, to '/storage/emulated/0/beatmachine/volumi/0.wav':
04-13 12:19:41.574: I/ffmpeg(25097):   Metadata:
04-13 12:19:41.574: I/ffmpeg(25097):     ISFT            : Lavf57.25.100
04-13 12:19:41.574: I/ffmpeg(25097):     Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
04-13 12:19:41.574: I/ffmpeg(25097):     Metadata:
04-13 12:19:41.574: I/ffmpeg(25097):       encoder         : Lavc57.24.102 pcm_s16le
04-13 12:19:41.574: I/ffmpeg(25097): Stream mapping:
04-13 12:19:41.574: I/ffmpeg(25097):   Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
04-13 12:19:41.574: I/ffmpeg(25097): Press [q] to stop, [?] for help
04-13 12:19:41.574: I/ffmpeg(25097): size=      50kB time=00:00:00.28 bitrate=1413.4kbits/s speed=31.7x    
04-13 12:19:41.574: I/ffmpeg(25097): video:0kB audio:50kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.153883%