4

I'm trying to mix all audio tracks from a multi audio track video file. I did it successfully but I noticed that the first is loud, the second is normal and the third is low. I would like to normalise or (best), to set volume manually.

Here is what i've tried, but it doesn't work (parsing error message) so i assume I don't use it in the good way.

$ ffmpeg -i INPUT -c:v libx264 -preset slow -crf 23 -filter_complex "[0:1]volume=0.3;[0:2]volume=0.5;[0:3]volume=0.7 amerge=inputs=3" -c:a libmp3lame OUTPUT

ffmpeg version 2.2.git Copyright (c) 2000-2014 the FFmpeg developers
  built on Jun 13 2014 10:28:46 with gcc 4.8.3 (GCC)
  configuration: --extra-ldflags=-L/usr/local/x86_64-w64-mingw32/lib --prefix=/u
sr/local/x86_64-w64-mingw32 --cross-prefix=x86_64-w64-mingw32- --target-os=mingw
32 --enable-w32threads --enable-memalign-hack --arch=x86_64 --enable-runtime-cpu
detect --disable-debug --enable-static --disable-shared --disable-ffplay --disab
le-ffserver --enable-gpl --enable-version3 --enable-nonfree --enable-libmp3lame
--enable-libfdk-aac --enable-libx264
  libavutil      52. 89.100 / 52. 89.100
  libavcodec     55. 66.100 / 55. 66.100
  libavformat    55. 43.100 / 55. 43.100
  libavdevice    55. 13.101 / 55. 13.101
  libavfilter     4.  8.100 /  4.  8.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
[avi @ 000000000357fee0] non-interleaved AVI
Guessed Channel Layout for  Input Stream #0.1 : stereo
Guessed Channel Layout for  Input Stream #0.2 : stereo
Guessed Channel Layout for  Input Stream #0.3 : stereo
Input #0, avi, from 'hl2 2014-06-14 23-46-14-775.avi':
  Metadata:
    encoder         : DxtoryCore ver2.0.0.114
    ISRC            : Video:Lagarith Lossless Codec Audio0:Line 1 (Virtual Audio
 Cable) Audio1:Line 2 (Virtual Audio Cable) Audio2:Microphone (2- PÚriphÚrique H
igh Definition Audio)
  Duration: 01:04:49.17, start: 0.000000, bitrate: 168913 kb/s
    Stream #0:0: Video: lagarith (LAGS / 0x5347414C), yuv420p, 1920x1080, 164302
 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels,
 s16, 1536 kb/s
    Stream #0:2: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels,
 s16, 1536 kb/s
    Stream #0:3: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels,
 s16, 1536 kb/s
Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_amerge_
3
Appuyez sur une touche pour continuer...

Any help welcome.

2
  • You forgot the complete console output from your command. Commented Jun 15, 2014 at 21:05
  • I didn't think it is useful but here it is : pastebin.com/hTMeUzmp By the way @LordNeckbeard i was reading your reply here and the last part is not so far from my problem. Commented Jun 15, 2014 at 21:38

1 Answer 1

6
ffmpeg -i input -filter_complex \
"[0:a:0]volume=0.3:precision=fixed[a0]; \
 [0:a:1]volume=0.5:precision=fixed[a1]; \
 [0:a:2]volume=0.7:precision=fixed[a2]; \
 [a0][a1][a2]amerge=inputs=3,pan=stereo:FL<c0+c2+c4:FR<c1+c3+c5[a]" \
-map 0:v -map "[a]" -c:v libx264 -preset slow -crf 23 output.mp4

Filtering Steps:

  1. Manually adjust volume. I just copied your values. The precision option determines which input sample formats will be allowed, and fixed is for input sample formats U8, S16 (such as your inputs), and S32. Alternatively, before volume you could use aformat as shown in this answer to use the default float volume precision.

  2. Merge into a 6 channel stream with amerge.

  3. Downmix 6 channels into stereo with pan. I did not test if the input channel order is correct (c0, c1, c2, etc).

Notes:

  • You could try omitting volume to see if pan provides a satisfactory output.
  • You can try using -ac 2 as an output option instead of the complicated pan filter.
3
  • In this command, we never specify libfdk_aac for final audio output but it use it as expected. Why ? Input is pcm. Commented Jun 17, 2014 at 3:33
  • I guess mp4 container force aac for output ? Commented Jun 17, 2014 at 3:40
  • @Scandale If no audio encoder is specified, and if stream copy mode is not used, then ffmpeg will use the default encoder which depends on 1) how ffmpeg was configured, and 2) the output container format. libfdk_aac is a good AAC encoder, and MP4 does not support pcm_s16le. Commented Jun 17, 2014 at 3:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.