0

I have a 8 audio track mov file which I want to encode to mp4 using ffmpeg BUT take the tracks 7+8 and put them as stereo with 320k and 48KHz to that mp4. My line is this:

ffmpeg -i %source% -map 0:0 -map 0:7 -map 0:8 -c:a:0 aac -ab:1 320k -ar:1 48000 -ac:1 2
-disposition:a:0 default -c:a:1 aac -ab:2 320k -ar:2 48000 -ac:2 1 -disposition:a:1 0
-strict -2 -async 1 -c:v libx264 -b:v 9300k -minrate 9300k -maxrate 9300k -bufsize 2325k
-r 24 -force_fps -s 1920x1080 -aspect 1:1 -pix_fmt yuv420p -profile:v high -preset medium
-level 40 -partitions partb8x8+partp4x4+partp8x8+parti8x8 -b-pyramid 2 -weightb 1 -8x8dct 1
-fast-pskip 1 -direct-pred 1 -x264-params force-cfr=1 -coder ac -trellis 1 -me_method hex
-flags +loop -sc_threshold 40 -keyint_min 24 -g 240 -qmin 3 -qmax 51 -threads 12
-metadata creation_time=now -sn -y %source%_FINAL.mp4

What do I have to change in order to make it stereo instead of 2 mono? I tried adding -filter_complex "[0:7][0:8] amerge=inputs=2" c:a aac -ab 320k at the beginning but it didnt work. What am I doing wrong? Thanks.

and here is the whole log:

R:\tests>ffmpeg -probesize 50M -analyzeduration 100M -i "8chIN.mov" -map 0:0 -an -c:v libx264 -b:v 9300k -minrate 9300k -maxrate 9300k -bufsize 2325k -r 24 -force_fps -vf "setsar=1/1,scale=1920:-1,pad=1920:1080:(1920-iw)/2:(1080-ih)/2" -deblock -1:-1 -pix_fmt yuv420p -profile:v high -preset medium -level 40 -partitions all -b-pyramid 1 -weightb 1 -8x8dct 1 -fast-pskip 1 -direct-pred 1 -x264-params force-cfr=1 -coder 0 -trellis 1 -me_method hex -flags +loop -sc_threshold 40 -keyint_min 24 -g 240 -qmin 3 -qmax 51 -threads 12 -metadata creation_time=now -filter_complex "[0:7][0:8] amerge=inputs=2" -c:a aac -ab 320k -sn -y "OUT.MP4"
ffmpeg version N-91245-g550372d0c4 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 19.105 / 58. 19.105
  libavformat    58. 17.100 / 58. 17.100
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 25.100 /  7. 25.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '8chIN.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2020-03-13T13:01:13.000000Z
    com.apple.quicktime.player.movie.audio.gain: 1.000000
    com.apple.quicktime.player.movie.audio.treble: 0.000000
    com.apple.quicktime.player.movie.audio.bass: 0.000000
    com.apple.quicktime.player.movie.audio.balance: 0.000000
    com.apple.quicktime.player.movie.audio.pitchshift: 0.000000
    com.apple.quicktime.player.movie.audio.mute:
    com.apple.quicktime.player.movie.visual.brightness: 0.000000
    com.apple.quicktime.player.movie.visual.color: 1.000000
    com.apple.quicktime.player.movie.visual.tint: 0.000000
    com.apple.quicktime.player.movie.visual.contrast: 1.000000
    com.apple.quicktime.player.version: 7.6.6 (7.6.6)
    com.apple.quicktime.version: 7.7.3 (2978.8) 0x7738000 (Mac OS X, 10.12.6, 16G2136)
  Duration: 00:01:39.63, start: 0.000000, bitrate: 166832 kb/s
    Stream #0:0(eng): Video: prores (apch / 0x68637061), yuv422p10le(tv, bt709, progressive), 1920x1080, 157532 kb/s, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 24 tbn, 24 tbc (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      encoder         : Apple ProRes 422 HQ
      timecode        : 00:00:00:00
    Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels (FL), s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:2(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels (FR), s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:3(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:4(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels (LFE), s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:5(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels (BL), s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:6(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels (BR), s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:7(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels (DL), s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:8(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels (DR), s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:9(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2020-03-13T13:01:13.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
Stream mapping:
  Stream #0:7 (pcm_s24le) -> amerge:in0 (graph 0)
  Stream #0:8 (pcm_s24le) -> amerge:in1 (graph 0)
  amerge (graph 0) -> Stream #0:0 (aac)
  Stream #0:0 -> #0:1 (prores (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 000001ed540d3cc0] using SAR=1/1
[libx264 @ 000001ed540d3cc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 000001ed540d3cc0] profile High, level 4.0
[libx264 @ 000001ed540d3cc0] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:-1:-1 analyse=0x3:0x133 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=1 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=240 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=9300 ratetol=1.0 qcomp=0.60 qpmin=3 qpmax=51 qpstep=4 vbv_maxrate=9300 vbv_bufsize=2325 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
[Parsed_amerge_0 @ 000001ed530fdc00] No channel layout for input 1
[aac @ 000001ed540d0a80] Unsupported channel layout
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
3
  • What didnt work, exactly? The error message would be more informative. Show the complete log from your command.
    – llogan
    Commented Apr 1, 2020 at 16:40
  • sorry, here is the whole thing above on the question. Thanks!
    – Yannis
    Commented Apr 2, 2020 at 13:24
  • Unrelated suggestions: don't declare the individual libx264 options like it is the year 2006. That's what the -presetoption is for. No need to manually choose the number of threads. Remove -threads 12 and it will automatically choose an optimal value. Get rid of -strict -2: the FFmpeg AAC encoder hasn't been marked experimental since 2015.
    – llogan
    Commented Apr 2, 2020 at 18:32

1 Answer 1

2

Add the -ac 2 output option

Your input channels are labeled as DL (downmix left) and DR (downmix right). When these are combined they create the downmix channel layout. Refer to ffmpeg -layouts for a list of channel names and layouts.

The FFmpeg AAC encoder (-c:a aac) does not support the downmix channel layout, so -ac 2 re-assigns it as stereo. Alternatively, you could also perform the re-assignment via the aresample filter, but that is more complicated.

2
  • Thanks llogan! That -ac2 did the trick! As for the suggestions, I appreciate it but the platform I am delivering to has all these requirements. Do you think some of them can be taken out as they are not making any difference? Thanks again!
    – Yannis
    Commented Apr 3, 2020 at 8:07
  • @Yannis -b-pyramid 2 -weightb 1 -fast-pskip 1 -trellis 1 -me_method hex should already be covered by -preset medium. There are probably more but I didn't take an in-depth look.
    – llogan
    Commented Apr 3, 2020 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .