使用FFMPEG对视频进行音量调节和通道合并

时间:2015-11-04 22:36:10

标签: audio video ffmpeg aac x264

我正在尝试将录制的AVI(1个视频流,2个音频流[1st is stereo,2nd is mono])视频文件转换为H264 / AAC。

我希望第二个音频流的音量为60%,第一个音频流为100%。

我还想合并第一和第二音频流。

输出应该是带有AAC音频的H264。

我尝试使用的命令是:

"ffmpeg.exe" 
  -i "input.avi" 
  -filter_complex " 
    [0:a:0]aformat=channel_layouts=stereo,volume=1.0[a1]; 
    [0:a:1]aformat=channel_layouts=mono,volume=0.6[a2]; 
    [a1][a2]amerge,pan=stereo|c0<c0+c2|c1<c1+c2[out]
  " 
  -map 0:v 
  -map "[out]" 
  -c:v libx264 -preset slow -crf 26 
  -c:a aac -strict experimental -ab 128000 -ac 2 -ar 48000 
  "output.mp4"

但我收到错误: [AVFilterGraph @ 0000000ceb630c00]以下过滤器无法选择其格式:Parsed_amerge_4 考虑在其输入或输出附近插入(a)格式过滤器。 配置复杂过滤器出错。 发生错误编号-5

我做错了什么以及如何解决?

完整的控制台日志:

ffmpeg version N-76456-g6df2c94 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      55.  5.100 / 55.  5.100
  libavcodec     57. 14.100 / 57. 14.100
  libavformat    57. 14.100 / 57. 14.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 14.101 /  6. 14.101
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
[avi @ 000000b1cfa6bc20] non-interleaved AVI
Guessed Channel Layout for  Input Stream #0.1 : stereo
Guessed Channel Layout for  Input Stream #0.2 : mono
Input #0, avi, from 'input.avi':
  Metadata:
    encoder         : DxtoryCore ver2.0.0.122
    ISRC            : Video:Lagarith Lossless Codec Audio0:Lautsprecher (2- USB Audio CODEC ) Audio1:Mikrofon (2- USB Audio CODEC )
  Duration: 00:27:55.60, start: 0.000000, bitrate: 181780 kb/s
    Stream #0:0: Video: lagarith (LAGS / 0x5347414C), rgb24, 1920x1017, 179663 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
    Stream #0:2: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
[Parsed_amerge_4 @ 000000b1cfaf3200] No channel layout for input 1
Last message repeated 1 times
[AVFilterGraph @ 000000b1cfa70c00] The following filters could not choose their formats: Parsed_amerge_4
Consider inserting the (a)format filter near their input or output.
Error configuring complex filters.
Error number -5 occurred

1 个答案:

答案 0 :(得分:3)

似乎可以通过先将所有音频流分成不同的通道然后将其反馈到amerge过滤器来解决这个问题。

"ffmpeg.exe" 
  -i "input.avi" 
  -filter_complex "
    [0:a:0]volume=1.0,channelsplit=channel_layout=stereo[a1][a2];
    [0:a:1]volume=0.6,channelsplit=channel_layout=mono[a3];
    [a1][a2][a3]amerge=inputs=3,pan=stereo|c0<c0+c2|c1<c1+c2[out]
  " 
  -map 0:v 
  -map "[out]" 
  -c:v libx264 -preset slow -crf 26 
  -c:a aac -strict experimental -ab 128000 -ac 2 -ar 48000 
  "output.mp4"