17

I need FFmpeg to grab an audio feed and reencode it to 16-Bit FLAC.

How do I force a 16-Bit FLAC output?

./ffmpeg -i http://7359.live.streamtheworld.com:80/CONTINENTALAAC_SC -vn -ac 1 -ar 16000 -acodec flac -map 0 -f segment -segment_list /flac/out.list -segment_time 00:00:12.00 /flac/out%03d.flac
ffmpeg version N-49622-g127ff88 Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb  6 2013 05:11:38 with gcc 4.6 (Debian 4.6.3-1)
  configuration: --prefix=/root/ffmpeg-static/32bit --arch=x86_32 --extra-cflags='-m32 -I/root/ffmpeg-static/32bit/include -static' --extra-ldflags='-m32 -L/root/ffmpeg-static/32bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
  libavutil      52. 17.101 / 52. 17.101
  libavcodec     54. 91.100 / 54. 91.100
  libavformat    54. 61.104 / 54. 61.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 35.101 /  3. 35.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[aac @ 0xa163680] max_analyze_duration 5000000 reached at 5015510 microseconds
[aac @ 0xa163680] Estimating duration from bitrate, this may be inaccurate
Input #0, aac, from 'http://7359.live.streamtheworld.com:80/CONTINENTALAAC_SC':
  Duration: 150:52:44.61, bitrate: 29 kb/s
    Stream #0:0: Audio: aac, 44100 Hz, stereo, fltp, 29 kb/s
[flac @ 0xa16ee40] encoding as 24 bits-per-sample
Output #0, segment, to '/flac/out%03d.flac':
  Metadata:
    encoder         : Lavf54.61.104
    Stream #0:0: Audio: flac, 16000 Hz, mono, s32, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (aac -> flac)
Press [q] to stop, [?] for help
size=N/A time=00:00:19.22 bitrate=N/A    
video:0kB audio:647kB subtitle:0 global headers:0kB muxing overhead -100.003322%

2 Answers 2

30

By default, the FFmpeg FLAC encoder takes the bit depth of the original. The bit depth can be changed with the sample_fmt option, e.g.

ffmpeg -i … -c:a flac -sample_fmt s16 output.flac

Note that not all formats are supported by every encoder.

For a list of all supported sample formats, run:

ffmpeg -sample_fmts

See the chapter Audio Options in the FFmpeg command line documentation.

6
  • This generates output with a bit depth of 4 for me, even when I specify s16 (bit depth 16). Full command: ffmpeg -i newwave.wav -c:a adpcm_ima_qt -sample_fmt s16 -ar 22500 newwave.aiff
    – xjcl
    Sep 19, 2018 at 1:00
  • @xjcl The codec you are using only supports 4 bit.
    – slhck
    Sep 19, 2018 at 5:11
  • What's the difference between e.g. s16 and s16p Nov 2, 2019 at 12:36
  • This does not work for me. I get " Specified sample format s16 is invalid or not supported"
    – Arete
    Dec 29, 2019 at 20:15
  • 1
    @theonlygusti "p" means "planar"; the other formats use "packed" storage. See: en.wikipedia.org/wiki/Packed_pixel (Sorry for the late reply, I missed the comment.)
    – slhck
    Dec 30, 2019 at 15:47
1

To reduce bit depth to 16 with dithering:

ffmpeg -i input.flac -acodec flac -af aresample=osf=s16:dither_method=triangular_hp output.flac

See e.g. https://www.waves.com/audio-dithering-what-you-need-to-know

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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