I would like to ask why ffmpeg's libfdk_aac encoder is automatically downsampling my audio's bit depth when encoding and I want to know how to stop it.

My encoding is as such (all data is there, except for metadata & file paths):

ffmpeg -i "/Path/To/Input.flac" -c:a libfdk_aac -b:a 192k -ar 48000 -map_metadata -1 -metadata title="Title" -metadata artist="Artist" -metadata date="Date" "/Path/To/Output.m4a"
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.10.44.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-opencl --enable-videotoolbox --enable-nonfree
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, flac, from '/Path/To/Input.flac':
  Duration: 00:31:31.71, start: 0.000000, bitrate: 4721 kb/s
    Stream #0:0: Audio: flac, 192000 Hz, stereo, s32 (24 bit)
Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
Output #0, ipod, to '/Path/To/Output.m4a':
    title           : Title
    artist          : Artist
    date            : Date
    encoder         : Lavf58.20.100
    Stream #0:0: Audio: aac (libfdk_aac) (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 192 kb/s
      encoder         : Lavc58.35.100 libfdk_aac
[NULL @ 0x7fb747801000] sample/frame number mismatch in adjacent frames
size=   44686kB time=00:31:31.71 bitrate= 193.5kbits/s speed=22.2x    
video:0kB audio:44338kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.784360%

No problems with encoding... (I simply encode to AAC, set bitrate to 192kbps, and downsample to 48000 kHz) except that for some reason, the bit depth is downsampled to 16 bit when encoding from a 24 bit source. I know the libfdk_aac encoder supports 24 bit, but for some reason, the encoder auto-downsamples. I have attempted to force 24 bit, with -sample_fmt s32 but that returned with this error:

[libfdk_aac @ 0x7fc58100b200] Specified sample format s32 is invalid or not supported
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!

If anyone knows, I'd greatly appreciate a response.


I'm afraid not. The encoded output will decode to floating-point samples but the library only accepts 16-bit samples as input.

  • This answer is seemingly off topic; the question is why is the libfdk_aac encoder downsampling the bit depth to 16-bit and how do I solve it? I am aware that there is no issue with ffmpeg's built-in aac encoder. I just want to know if it's possible to encode 24-bit AAC with libfdk_aac. – Henry7720 Dec 8 '18 at 4:17
  • FDK isn't downsampling anything - the library only accepts 16-bit PCM samples as input. What is unclear? – Gyan Dec 8 '18 at 4:33
  • ffmpeg's command line is nicely confusing. But I've checked and it seems the file actually is 24-bit. Thank you for your help. – Henry7720 Dec 8 '18 at 4:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.