Which audio encoders in FFmpeg support 8 kHz?Split audio feed using FFmpegffmpeg doesn't convert audioHow to encode and split an audio file in FFmpeg using asplitConcatenating multiple 24-bit 96 kHz wav audio files using ffmpeg, shntool, and soxRe-encode AC3 5.1 audio with variable bitrate using FFmpegBatch video convert with FFmpeg: combine image and audioFFMPEG merge two videos which don't have any audioCodec and setting for lowest bitrate ffmpeg outputFFmpeg skip audio filesffmpeg - Encode audio as list of samples

Does the on'yomi of 輪 (リン) have any relation to the English "ring", or is it a coincidence?

If I am just replacing the car engine, do I need to replace the odometer as well?

/etc/shadow permissions security best practice (000 vs. 600 vs. 640)

Creating cryptographic algorithms at runtime

Totally Blind Chess

Is Basalt Monolith a 1-card infinite combo with no payoff?

Is it possible to have a preference relation that is complete but not transitive?

Why is the air inside airliners so dry (low humidity)?

Is this bible in Koine Greek?

How to deal with a 6 year old who was "caught" cheating?

How can I prevent side-channel attacks against authentication?

Why did Google not use an NP problem for their quantum supremacy experiment?

Call local emergency number using a foreign mobile number

How to control the padding below a BarLegend?

How time is defined in astronomical science

Do any Star Trek characters play rock band instruments?

Is a turbocharged piston aircraft the same thing as turboprop?

Body swap, then building it back to health

Trying to find a short story about the representative of a city discovering the "primitive" folk are actually more advanced

Instant coffee melts like chocolate

Why does telnet on a non existent port not directly reject, but time out?

I was mistakenly identified as a criminal, and this has caused rumors. How can I convince my friends that it is all a mistake?

How did composers "test" their music?

Is the "Watchmen" TV series a continuation of the movie or the comics?



Which audio encoders in FFmpeg support 8 kHz?


Split audio feed using FFmpegffmpeg doesn't convert audioHow to encode and split an audio file in FFmpeg using asplitConcatenating multiple 24-bit 96 kHz wav audio files using ffmpeg, shntool, and soxRe-encode AC3 5.1 audio with variable bitrate using FFmpegBatch video convert with FFmpeg: combine image and audioFFMPEG merge two videos which don't have any audioCodec and setting for lowest bitrate ffmpeg outputFFmpeg skip audio filesffmpeg - Encode audio as list of samples






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









8

















I have an old video (made by a Casio Exilim EX-Z40, if it matters), whose audio stream ffprobe reports as pcm_u8, 8000 Hz, mono, u8.



I would like to transcode it into something modern.



Transcoding with FFmpeg defaults fails:




libfaac doesn't support this output format!




So presumably libfaac doesn't support 8 kHz, because -c:a copy works.



Which encoders support an 8 kHz sampling rate?
The list found here barely mentions sampling rates at all.



Can I script something that tries every installed codec, from…



ffmpeg -codecs | grep EA`


…to see directly which ones work?










share|improve this question























  • 4





    Do note that there's absolutely no reason you can't just pick a modern format with a higher sample rate, so that it will be playable by modern devices which expect a higher one. The compression will go a long ways from letting the file sizes get much larger than if you encoded at 8khz. It's not like a 32khz file will be four times larger, in other words.

    – trlkly
    Oct 15 at 8:03











  • Hmm. How about interpolating it up to 32kHz first?

    – pjc50
    Oct 15 at 8:58

















8

















I have an old video (made by a Casio Exilim EX-Z40, if it matters), whose audio stream ffprobe reports as pcm_u8, 8000 Hz, mono, u8.



I would like to transcode it into something modern.



Transcoding with FFmpeg defaults fails:




libfaac doesn't support this output format!




So presumably libfaac doesn't support 8 kHz, because -c:a copy works.



Which encoders support an 8 kHz sampling rate?
The list found here barely mentions sampling rates at all.



Can I script something that tries every installed codec, from…



ffmpeg -codecs | grep EA`


…to see directly which ones work?










share|improve this question























  • 4





    Do note that there's absolutely no reason you can't just pick a modern format with a higher sample rate, so that it will be playable by modern devices which expect a higher one. The compression will go a long ways from letting the file sizes get much larger than if you encoded at 8khz. It's not like a 32khz file will be four times larger, in other words.

    – trlkly
    Oct 15 at 8:03











  • Hmm. How about interpolating it up to 32kHz first?

    – pjc50
    Oct 15 at 8:58













8












8








8


1






I have an old video (made by a Casio Exilim EX-Z40, if it matters), whose audio stream ffprobe reports as pcm_u8, 8000 Hz, mono, u8.



I would like to transcode it into something modern.



Transcoding with FFmpeg defaults fails:




libfaac doesn't support this output format!




So presumably libfaac doesn't support 8 kHz, because -c:a copy works.



Which encoders support an 8 kHz sampling rate?
The list found here barely mentions sampling rates at all.



Can I script something that tries every installed codec, from…



ffmpeg -codecs | grep EA`


…to see directly which ones work?










share|improve this question

















I have an old video (made by a Casio Exilim EX-Z40, if it matters), whose audio stream ffprobe reports as pcm_u8, 8000 Hz, mono, u8.



I would like to transcode it into something modern.



Transcoding with FFmpeg defaults fails:




libfaac doesn't support this output format!




So presumably libfaac doesn't support 8 kHz, because -c:a copy works.



Which encoders support an 8 kHz sampling rate?
The list found here barely mentions sampling rates at all.



Can I script something that tries every installed codec, from…



ffmpeg -codecs | grep EA`


…to see directly which ones work?







ffmpeg audio-conversion






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Oct 14 at 17:31









JakeGould

36.2k10 gold badges114 silver badges155 bronze badges




36.2k10 gold badges114 silver badges155 bronze badges










asked Oct 14 at 17:21









Camille GoudeseuneCamille Goudeseune

9661 gold badge15 silver badges33 bronze badges




9661 gold badge15 silver badges33 bronze badges










  • 4





    Do note that there's absolutely no reason you can't just pick a modern format with a higher sample rate, so that it will be playable by modern devices which expect a higher one. The compression will go a long ways from letting the file sizes get much larger than if you encoded at 8khz. It's not like a 32khz file will be four times larger, in other words.

    – trlkly
    Oct 15 at 8:03











  • Hmm. How about interpolating it up to 32kHz first?

    – pjc50
    Oct 15 at 8:58












  • 4





    Do note that there's absolutely no reason you can't just pick a modern format with a higher sample rate, so that it will be playable by modern devices which expect a higher one. The compression will go a long ways from letting the file sizes get much larger than if you encoded at 8khz. It's not like a 32khz file will be four times larger, in other words.

    – trlkly
    Oct 15 at 8:03











  • Hmm. How about interpolating it up to 32kHz first?

    – pjc50
    Oct 15 at 8:58







4




4





Do note that there's absolutely no reason you can't just pick a modern format with a higher sample rate, so that it will be playable by modern devices which expect a higher one. The compression will go a long ways from letting the file sizes get much larger than if you encoded at 8khz. It's not like a 32khz file will be four times larger, in other words.

– trlkly
Oct 15 at 8:03





Do note that there's absolutely no reason you can't just pick a modern format with a higher sample rate, so that it will be playable by modern devices which expect a higher one. The compression will go a long ways from letting the file sizes get much larger than if you encoded at 8khz. It's not like a 32khz file will be four times larger, in other words.

– trlkly
Oct 15 at 8:03













Hmm. How about interpolating it up to 32kHz first?

– pjc50
Oct 15 at 8:58





Hmm. How about interpolating it up to 32kHz first?

– pjc50
Oct 15 at 8:58










4 Answers
4






active

oldest

votes


















8


















The native FFmpeg AAC encoder (-c:a aac) supports 8000 Hz sample rate:



ffmpeg -h encoder=aac
...
Supported sample rates: 96000 88200 64000 48000 44100 32000 24000 22050 16000 12000 11025 8000 7350


It will automatically choose the sample rate the most closely matches the input, so you don't need to declare -ar:



ffmpeg -i input.mov -c:a aac output.m4a



Which audio encoders in FFmpeg support 8 kHz?




aac, aptx, aptx_hd, dca, flac, g723_1, libfdk_aac, libmp3lame, libopus, libspeex, libvorbis, real_144, wavpack, many pcm variants.



There are probably others, but reporting of supported_samplerates is inconsistent.




I would like to transcode it into something modern.




libfaac has been removed from FFmpeg for years and is not considered to be a modern AAC encoder. Your ffmpeg must be ancient. Update and use the native FFmpeg AAC encoder, or compile and use libfdk_aac.



If you want the most modern use libopus.




But when I tried [aac], compared to the original, the file size increased and some high frequencies were attenuated.




Since I suspect your ffmpeg is very old you are likely missing the major quality updates to the encoder aac. Upgrade and quality will likely improve.






share|improve this answer























  • 1





    Yes, that ffmpeg was years old. So I compiled afresh from today's git snapshot. Still, even at 8 kHz, ac3 and alac make files bigger than legacy pcm_u8; flac has problems playing in my 2 year old vlc; mp3 has horrible artifacts. But at least aac works and is slightly smaller, so I'll use that.

    – Camille Goudeseune
    Oct 14 at 19:21






  • 5





    FFMpeg's AAC compressor supports 8KHz, but many players don't. So by creating an 8KHz AAC you risk it being unplayable on many devices.

    – Eugen Rieck
    Oct 14 at 19:29






  • 1





    @CamilleGoudeseune Depending on where you need it to play, consider one of the high-efficiency codecs such as HE-AAC v1/v2. Or Opus as llogan suggested.

    – Bob
    Oct 15 at 7:10











  • Opus would be a better suggestion, where the top-quality encoder is the free open-source one, and it's good at low bitrate, especially for speech. FFmpeg's native aac encoder is apparently ok, and sometimes beats libfdk_aac though. trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is good, Oh, but @CamilleGoudeseune is using an old FFmpeg, and the native aac encoder was much worse in older FFmpeg.

    – Peter Cordes
    Oct 15 at 15:15












  • Added an answer recommending Opus.

    – Peter Cordes
    Oct 15 at 16:14


















6


















Sampling rate and codec are different parameters. Most likely you want something along the lines of



-ar 48000 -c:a aac


To upsample from 8KHz to 48KHz and the compress to AAC






share|improve this answer


























  • Good idea. But when I tried it, compared to the original, the file size increased and some high frequencies were attenuated. So, worse than -c:a copy.

    – Camille Goudeseune
    Oct 14 at 17:32






  • 3





    No modern compressor is optimized for 8KHz sample rate, so everything modern will have difficulties with 8KHz audio. Depending on the output container format you want, you might or might not have the choice between different codecs. Please append your OQ or comment, then I can help you find the best possible version.

    – Eugen Rieck
    Oct 14 at 17:55











  • Yes, brute force testing of a bunch of modern compressors confirms that they suck at 8 kHz.

    – Camille Goudeseune
    Oct 14 at 19:23


















2


















8 KHz is fairly standard for speech, known as 'narrow band'. If this is speech then you should have plenty of options, although not that many are supported by FFmpeg out-of-the-box. Probably the best options are




  • AMR - you can compile libopencode-amrnb into FFmpeg for support

  • Opus, which will use the Vorbis CELT speech codec

However 8KHz 8-bit PCM isn't a very good source in the first place: most encoders will expect / hope for better input, e.g. 8-bit G.711 mu-law which is effectively 12-bit data encoded as 8-bit floating point. They may not do well with pure 8-bit PCM input as it might not fit speech patterns they're modelled for.



It's also a fairly small file already, and it's possible that your video container won't support more complicated codecs. So I think this is more trouble than it's worth, and I'd leave the audio as-is.






share|improve this answer

































    2


















    Opus is generally considered the best low-bitrate codec available, and doesn't have problems with an 8kHz input sample rate. The resulting opus stream can still be decoded to whatever sample rate is convenient for the decoder. (Like other lossy codecs, it compresses based on frequency bands after doing an FFT. But some other codecs apparently only want to decode to the same sample rate as the input. As other answers point out, you can get FFmpeg to resample the input before giving it to the codec, but you don't need that for Opus.



    Try ffmpeg -c:a libopus -b:a 24k -frame_duration 120 for 24 kbit/s Opus.



    Perhaps worth trying: -application voip to tune for "improved speech intelligibility" instead of the default audio profile.



    Setting -frame_duration to the highest value reduces overhead, I think. You don't care about encoder / decoder latency because you just have files, not real-time 2-way voice chat. So you can let it buffer 120ms of audio and pack together multiple CELT or SILK frames to reduce redundancy of frame headers.




    The best available Opus encoder is the free and open source libopus (https://opus-codec.org) so FFmpeg can just use it, unlike with AAC where the best encoders are closed-source.



    Opus has special modes for very low bitrate speech (like 16kb/s), detecting speech and even switching over to a speech-specific encoder (SILK) at low bitrates.



    Opus's low-bitrate coding tools are similar to what HE-AACv2 can do, see the wikipedia article.





    But when I tried it, compared to the original, the file size increased ...




    Part of the point of lossy compression is that you can choose the output bitrate, trading off against quality. Most codecs can use -b:a 32k for example to choose an audio bitrate of 32 kbit/s.



    (For video, you can also trade off CPU time spent encoding, e.g. -preset veryslow vs. -preset medium. But compressing audio is cheap enough that most codecs don't have a lot of options for spending more CPU time to improve the bitrate vs. quality tradeoff.)



    Mono 8-bit 8kHz PCM has a bitrate of 64 kbit/s = 8 * 8000 so you're aiming for lower than that, otherwise you might as well keep your original files. PCM is just raw samples so bitrate is just a product of sample rate and sample width. Like the audio equivalent of a .bmp bitmap image. That's highly inefficient, and the reason better codecs were invented. (And as you know from listening, saving bitrate for PCM comes at a massive cost to quality and frequency range because bitrate is tied 1:1 with sample rate.
    That's not the case when you quantize in the frequency domain with a lossy codec.)





    and some high frequencies were attenuated. So, worse than -c:a copy




    FFmpeg's native AAC encoder -c:a aac used to be pretty bad, and you were using an old FFmpeg. https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is sometimes better than libfdk_aac for AAC-LC (low-complexity high bitrate). It doesn't mention HE-AAC, though, and that's what you want for low bitrate AAC.



    libfdk_aac used to be the best open-source AAC encoder available, and maybe still is for HE-AAC. AFAIK, neither of them are as good as the best non-free AAC encoders, though.



    For low-bitrate AAC, you really want HE-AAC which adds more coding tools https://en.wikipedia.org/wiki/High-Efficiency_Advanced_Audio_Coding. I'm not sure if -c:a aac can do that.



    https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio lists some recommended settings and ranges of useful bitrates for various encoders.



    But you probably want Opus, or possibly AMR-NB (narrowband) for bitrates like 4 kbit/s. I don't know how old the quality vs. bitrate plot on the Opus wiki article is, but it shows AMR-NB at higher quality than Opus down below 8kb/s.



    With that few bits, you might be able to understand speech but it won't sound nice. It's just a question of which codec is least horrible.






    share|improve this answer





























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "3"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );














      draft saved

      draft discarded
















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1492214%2fwhich-audio-encoders-in-ffmpeg-support-8-khz%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown


























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      8


















      The native FFmpeg AAC encoder (-c:a aac) supports 8000 Hz sample rate:



      ffmpeg -h encoder=aac
      ...
      Supported sample rates: 96000 88200 64000 48000 44100 32000 24000 22050 16000 12000 11025 8000 7350


      It will automatically choose the sample rate the most closely matches the input, so you don't need to declare -ar:



      ffmpeg -i input.mov -c:a aac output.m4a



      Which audio encoders in FFmpeg support 8 kHz?




      aac, aptx, aptx_hd, dca, flac, g723_1, libfdk_aac, libmp3lame, libopus, libspeex, libvorbis, real_144, wavpack, many pcm variants.



      There are probably others, but reporting of supported_samplerates is inconsistent.




      I would like to transcode it into something modern.




      libfaac has been removed from FFmpeg for years and is not considered to be a modern AAC encoder. Your ffmpeg must be ancient. Update and use the native FFmpeg AAC encoder, or compile and use libfdk_aac.



      If you want the most modern use libopus.




      But when I tried [aac], compared to the original, the file size increased and some high frequencies were attenuated.




      Since I suspect your ffmpeg is very old you are likely missing the major quality updates to the encoder aac. Upgrade and quality will likely improve.






      share|improve this answer























      • 1





        Yes, that ffmpeg was years old. So I compiled afresh from today's git snapshot. Still, even at 8 kHz, ac3 and alac make files bigger than legacy pcm_u8; flac has problems playing in my 2 year old vlc; mp3 has horrible artifacts. But at least aac works and is slightly smaller, so I'll use that.

        – Camille Goudeseune
        Oct 14 at 19:21






      • 5





        FFMpeg's AAC compressor supports 8KHz, but many players don't. So by creating an 8KHz AAC you risk it being unplayable on many devices.

        – Eugen Rieck
        Oct 14 at 19:29






      • 1





        @CamilleGoudeseune Depending on where you need it to play, consider one of the high-efficiency codecs such as HE-AAC v1/v2. Or Opus as llogan suggested.

        – Bob
        Oct 15 at 7:10











      • Opus would be a better suggestion, where the top-quality encoder is the free open-source one, and it's good at low bitrate, especially for speech. FFmpeg's native aac encoder is apparently ok, and sometimes beats libfdk_aac though. trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is good, Oh, but @CamilleGoudeseune is using an old FFmpeg, and the native aac encoder was much worse in older FFmpeg.

        – Peter Cordes
        Oct 15 at 15:15












      • Added an answer recommending Opus.

        – Peter Cordes
        Oct 15 at 16:14















      8


















      The native FFmpeg AAC encoder (-c:a aac) supports 8000 Hz sample rate:



      ffmpeg -h encoder=aac
      ...
      Supported sample rates: 96000 88200 64000 48000 44100 32000 24000 22050 16000 12000 11025 8000 7350


      It will automatically choose the sample rate the most closely matches the input, so you don't need to declare -ar:



      ffmpeg -i input.mov -c:a aac output.m4a



      Which audio encoders in FFmpeg support 8 kHz?




      aac, aptx, aptx_hd, dca, flac, g723_1, libfdk_aac, libmp3lame, libopus, libspeex, libvorbis, real_144, wavpack, many pcm variants.



      There are probably others, but reporting of supported_samplerates is inconsistent.




      I would like to transcode it into something modern.




      libfaac has been removed from FFmpeg for years and is not considered to be a modern AAC encoder. Your ffmpeg must be ancient. Update and use the native FFmpeg AAC encoder, or compile and use libfdk_aac.



      If you want the most modern use libopus.




      But when I tried [aac], compared to the original, the file size increased and some high frequencies were attenuated.




      Since I suspect your ffmpeg is very old you are likely missing the major quality updates to the encoder aac. Upgrade and quality will likely improve.






      share|improve this answer























      • 1





        Yes, that ffmpeg was years old. So I compiled afresh from today's git snapshot. Still, even at 8 kHz, ac3 and alac make files bigger than legacy pcm_u8; flac has problems playing in my 2 year old vlc; mp3 has horrible artifacts. But at least aac works and is slightly smaller, so I'll use that.

        – Camille Goudeseune
        Oct 14 at 19:21






      • 5





        FFMpeg's AAC compressor supports 8KHz, but many players don't. So by creating an 8KHz AAC you risk it being unplayable on many devices.

        – Eugen Rieck
        Oct 14 at 19:29






      • 1





        @CamilleGoudeseune Depending on where you need it to play, consider one of the high-efficiency codecs such as HE-AAC v1/v2. Or Opus as llogan suggested.

        – Bob
        Oct 15 at 7:10











      • Opus would be a better suggestion, where the top-quality encoder is the free open-source one, and it's good at low bitrate, especially for speech. FFmpeg's native aac encoder is apparently ok, and sometimes beats libfdk_aac though. trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is good, Oh, but @CamilleGoudeseune is using an old FFmpeg, and the native aac encoder was much worse in older FFmpeg.

        – Peter Cordes
        Oct 15 at 15:15












      • Added an answer recommending Opus.

        – Peter Cordes
        Oct 15 at 16:14













      8














      8










      8









      The native FFmpeg AAC encoder (-c:a aac) supports 8000 Hz sample rate:



      ffmpeg -h encoder=aac
      ...
      Supported sample rates: 96000 88200 64000 48000 44100 32000 24000 22050 16000 12000 11025 8000 7350


      It will automatically choose the sample rate the most closely matches the input, so you don't need to declare -ar:



      ffmpeg -i input.mov -c:a aac output.m4a



      Which audio encoders in FFmpeg support 8 kHz?




      aac, aptx, aptx_hd, dca, flac, g723_1, libfdk_aac, libmp3lame, libopus, libspeex, libvorbis, real_144, wavpack, many pcm variants.



      There are probably others, but reporting of supported_samplerates is inconsistent.




      I would like to transcode it into something modern.




      libfaac has been removed from FFmpeg for years and is not considered to be a modern AAC encoder. Your ffmpeg must be ancient. Update and use the native FFmpeg AAC encoder, or compile and use libfdk_aac.



      If you want the most modern use libopus.




      But when I tried [aac], compared to the original, the file size increased and some high frequencies were attenuated.




      Since I suspect your ffmpeg is very old you are likely missing the major quality updates to the encoder aac. Upgrade and quality will likely improve.






      share|improve this answer
















      The native FFmpeg AAC encoder (-c:a aac) supports 8000 Hz sample rate:



      ffmpeg -h encoder=aac
      ...
      Supported sample rates: 96000 88200 64000 48000 44100 32000 24000 22050 16000 12000 11025 8000 7350


      It will automatically choose the sample rate the most closely matches the input, so you don't need to declare -ar:



      ffmpeg -i input.mov -c:a aac output.m4a



      Which audio encoders in FFmpeg support 8 kHz?




      aac, aptx, aptx_hd, dca, flac, g723_1, libfdk_aac, libmp3lame, libopus, libspeex, libvorbis, real_144, wavpack, many pcm variants.



      There are probably others, but reporting of supported_samplerates is inconsistent.




      I would like to transcode it into something modern.




      libfaac has been removed from FFmpeg for years and is not considered to be a modern AAC encoder. Your ffmpeg must be ancient. Update and use the native FFmpeg AAC encoder, or compile and use libfdk_aac.



      If you want the most modern use libopus.




      But when I tried [aac], compared to the original, the file size increased and some high frequencies were attenuated.




      Since I suspect your ffmpeg is very old you are likely missing the major quality updates to the encoder aac. Upgrade and quality will likely improve.







      share|improve this answer















      share|improve this answer




      share|improve this answer








      edited Oct 14 at 19:19

























      answered Oct 14 at 17:58









      lloganllogan

      29.8k7 gold badges57 silver badges97 bronze badges




      29.8k7 gold badges57 silver badges97 bronze badges










      • 1





        Yes, that ffmpeg was years old. So I compiled afresh from today's git snapshot. Still, even at 8 kHz, ac3 and alac make files bigger than legacy pcm_u8; flac has problems playing in my 2 year old vlc; mp3 has horrible artifacts. But at least aac works and is slightly smaller, so I'll use that.

        – Camille Goudeseune
        Oct 14 at 19:21






      • 5





        FFMpeg's AAC compressor supports 8KHz, but many players don't. So by creating an 8KHz AAC you risk it being unplayable on many devices.

        – Eugen Rieck
        Oct 14 at 19:29






      • 1





        @CamilleGoudeseune Depending on where you need it to play, consider one of the high-efficiency codecs such as HE-AAC v1/v2. Or Opus as llogan suggested.

        – Bob
        Oct 15 at 7:10











      • Opus would be a better suggestion, where the top-quality encoder is the free open-source one, and it's good at low bitrate, especially for speech. FFmpeg's native aac encoder is apparently ok, and sometimes beats libfdk_aac though. trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is good, Oh, but @CamilleGoudeseune is using an old FFmpeg, and the native aac encoder was much worse in older FFmpeg.

        – Peter Cordes
        Oct 15 at 15:15












      • Added an answer recommending Opus.

        – Peter Cordes
        Oct 15 at 16:14












      • 1





        Yes, that ffmpeg was years old. So I compiled afresh from today's git snapshot. Still, even at 8 kHz, ac3 and alac make files bigger than legacy pcm_u8; flac has problems playing in my 2 year old vlc; mp3 has horrible artifacts. But at least aac works and is slightly smaller, so I'll use that.

        – Camille Goudeseune
        Oct 14 at 19:21






      • 5





        FFMpeg's AAC compressor supports 8KHz, but many players don't. So by creating an 8KHz AAC you risk it being unplayable on many devices.

        – Eugen Rieck
        Oct 14 at 19:29






      • 1





        @CamilleGoudeseune Depending on where you need it to play, consider one of the high-efficiency codecs such as HE-AAC v1/v2. Or Opus as llogan suggested.

        – Bob
        Oct 15 at 7:10











      • Opus would be a better suggestion, where the top-quality encoder is the free open-source one, and it's good at low bitrate, especially for speech. FFmpeg's native aac encoder is apparently ok, and sometimes beats libfdk_aac though. trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is good, Oh, but @CamilleGoudeseune is using an old FFmpeg, and the native aac encoder was much worse in older FFmpeg.

        – Peter Cordes
        Oct 15 at 15:15












      • Added an answer recommending Opus.

        – Peter Cordes
        Oct 15 at 16:14







      1




      1





      Yes, that ffmpeg was years old. So I compiled afresh from today's git snapshot. Still, even at 8 kHz, ac3 and alac make files bigger than legacy pcm_u8; flac has problems playing in my 2 year old vlc; mp3 has horrible artifacts. But at least aac works and is slightly smaller, so I'll use that.

      – Camille Goudeseune
      Oct 14 at 19:21





      Yes, that ffmpeg was years old. So I compiled afresh from today's git snapshot. Still, even at 8 kHz, ac3 and alac make files bigger than legacy pcm_u8; flac has problems playing in my 2 year old vlc; mp3 has horrible artifacts. But at least aac works and is slightly smaller, so I'll use that.

      – Camille Goudeseune
      Oct 14 at 19:21




      5




      5





      FFMpeg's AAC compressor supports 8KHz, but many players don't. So by creating an 8KHz AAC you risk it being unplayable on many devices.

      – Eugen Rieck
      Oct 14 at 19:29





      FFMpeg's AAC compressor supports 8KHz, but many players don't. So by creating an 8KHz AAC you risk it being unplayable on many devices.

      – Eugen Rieck
      Oct 14 at 19:29




      1




      1





      @CamilleGoudeseune Depending on where you need it to play, consider one of the high-efficiency codecs such as HE-AAC v1/v2. Or Opus as llogan suggested.

      – Bob
      Oct 15 at 7:10





      @CamilleGoudeseune Depending on where you need it to play, consider one of the high-efficiency codecs such as HE-AAC v1/v2. Or Opus as llogan suggested.

      – Bob
      Oct 15 at 7:10













      Opus would be a better suggestion, where the top-quality encoder is the free open-source one, and it's good at low bitrate, especially for speech. FFmpeg's native aac encoder is apparently ok, and sometimes beats libfdk_aac though. trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is good, Oh, but @CamilleGoudeseune is using an old FFmpeg, and the native aac encoder was much worse in older FFmpeg.

      – Peter Cordes
      Oct 15 at 15:15






      Opus would be a better suggestion, where the top-quality encoder is the free open-source one, and it's good at low bitrate, especially for speech. FFmpeg's native aac encoder is apparently ok, and sometimes beats libfdk_aac though. trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is good, Oh, but @CamilleGoudeseune is using an old FFmpeg, and the native aac encoder was much worse in older FFmpeg.

      – Peter Cordes
      Oct 15 at 15:15














      Added an answer recommending Opus.

      – Peter Cordes
      Oct 15 at 16:14





      Added an answer recommending Opus.

      – Peter Cordes
      Oct 15 at 16:14













      6


















      Sampling rate and codec are different parameters. Most likely you want something along the lines of



      -ar 48000 -c:a aac


      To upsample from 8KHz to 48KHz and the compress to AAC






      share|improve this answer


























      • Good idea. But when I tried it, compared to the original, the file size increased and some high frequencies were attenuated. So, worse than -c:a copy.

        – Camille Goudeseune
        Oct 14 at 17:32






      • 3





        No modern compressor is optimized for 8KHz sample rate, so everything modern will have difficulties with 8KHz audio. Depending on the output container format you want, you might or might not have the choice between different codecs. Please append your OQ or comment, then I can help you find the best possible version.

        – Eugen Rieck
        Oct 14 at 17:55











      • Yes, brute force testing of a bunch of modern compressors confirms that they suck at 8 kHz.

        – Camille Goudeseune
        Oct 14 at 19:23















      6


















      Sampling rate and codec are different parameters. Most likely you want something along the lines of



      -ar 48000 -c:a aac


      To upsample from 8KHz to 48KHz and the compress to AAC






      share|improve this answer


























      • Good idea. But when I tried it, compared to the original, the file size increased and some high frequencies were attenuated. So, worse than -c:a copy.

        – Camille Goudeseune
        Oct 14 at 17:32






      • 3





        No modern compressor is optimized for 8KHz sample rate, so everything modern will have difficulties with 8KHz audio. Depending on the output container format you want, you might or might not have the choice between different codecs. Please append your OQ or comment, then I can help you find the best possible version.

        – Eugen Rieck
        Oct 14 at 17:55











      • Yes, brute force testing of a bunch of modern compressors confirms that they suck at 8 kHz.

        – Camille Goudeseune
        Oct 14 at 19:23













      6














      6










      6









      Sampling rate and codec are different parameters. Most likely you want something along the lines of



      -ar 48000 -c:a aac


      To upsample from 8KHz to 48KHz and the compress to AAC






      share|improve this answer














      Sampling rate and codec are different parameters. Most likely you want something along the lines of



      -ar 48000 -c:a aac


      To upsample from 8KHz to 48KHz and the compress to AAC







      share|improve this answer













      share|improve this answer




      share|improve this answer










      answered Oct 14 at 17:26









      Eugen RieckEugen Rieck

      13.1k2 gold badges28 silver badges33 bronze badges




      13.1k2 gold badges28 silver badges33 bronze badges















      • Good idea. But when I tried it, compared to the original, the file size increased and some high frequencies were attenuated. So, worse than -c:a copy.

        – Camille Goudeseune
        Oct 14 at 17:32






      • 3





        No modern compressor is optimized for 8KHz sample rate, so everything modern will have difficulties with 8KHz audio. Depending on the output container format you want, you might or might not have the choice between different codecs. Please append your OQ or comment, then I can help you find the best possible version.

        – Eugen Rieck
        Oct 14 at 17:55











      • Yes, brute force testing of a bunch of modern compressors confirms that they suck at 8 kHz.

        – Camille Goudeseune
        Oct 14 at 19:23

















      • Good idea. But when I tried it, compared to the original, the file size increased and some high frequencies were attenuated. So, worse than -c:a copy.

        – Camille Goudeseune
        Oct 14 at 17:32






      • 3





        No modern compressor is optimized for 8KHz sample rate, so everything modern will have difficulties with 8KHz audio. Depending on the output container format you want, you might or might not have the choice between different codecs. Please append your OQ or comment, then I can help you find the best possible version.

        – Eugen Rieck
        Oct 14 at 17:55











      • Yes, brute force testing of a bunch of modern compressors confirms that they suck at 8 kHz.

        – Camille Goudeseune
        Oct 14 at 19:23
















      Good idea. But when I tried it, compared to the original, the file size increased and some high frequencies were attenuated. So, worse than -c:a copy.

      – Camille Goudeseune
      Oct 14 at 17:32





      Good idea. But when I tried it, compared to the original, the file size increased and some high frequencies were attenuated. So, worse than -c:a copy.

      – Camille Goudeseune
      Oct 14 at 17:32




      3




      3





      No modern compressor is optimized for 8KHz sample rate, so everything modern will have difficulties with 8KHz audio. Depending on the output container format you want, you might or might not have the choice between different codecs. Please append your OQ or comment, then I can help you find the best possible version.

      – Eugen Rieck
      Oct 14 at 17:55





      No modern compressor is optimized for 8KHz sample rate, so everything modern will have difficulties with 8KHz audio. Depending on the output container format you want, you might or might not have the choice between different codecs. Please append your OQ or comment, then I can help you find the best possible version.

      – Eugen Rieck
      Oct 14 at 17:55













      Yes, brute force testing of a bunch of modern compressors confirms that they suck at 8 kHz.

      – Camille Goudeseune
      Oct 14 at 19:23





      Yes, brute force testing of a bunch of modern compressors confirms that they suck at 8 kHz.

      – Camille Goudeseune
      Oct 14 at 19:23











      2


















      8 KHz is fairly standard for speech, known as 'narrow band'. If this is speech then you should have plenty of options, although not that many are supported by FFmpeg out-of-the-box. Probably the best options are




      • AMR - you can compile libopencode-amrnb into FFmpeg for support

      • Opus, which will use the Vorbis CELT speech codec

      However 8KHz 8-bit PCM isn't a very good source in the first place: most encoders will expect / hope for better input, e.g. 8-bit G.711 mu-law which is effectively 12-bit data encoded as 8-bit floating point. They may not do well with pure 8-bit PCM input as it might not fit speech patterns they're modelled for.



      It's also a fairly small file already, and it's possible that your video container won't support more complicated codecs. So I think this is more trouble than it's worth, and I'd leave the audio as-is.






      share|improve this answer






























        2


















        8 KHz is fairly standard for speech, known as 'narrow band'. If this is speech then you should have plenty of options, although not that many are supported by FFmpeg out-of-the-box. Probably the best options are




        • AMR - you can compile libopencode-amrnb into FFmpeg for support

        • Opus, which will use the Vorbis CELT speech codec

        However 8KHz 8-bit PCM isn't a very good source in the first place: most encoders will expect / hope for better input, e.g. 8-bit G.711 mu-law which is effectively 12-bit data encoded as 8-bit floating point. They may not do well with pure 8-bit PCM input as it might not fit speech patterns they're modelled for.



        It's also a fairly small file already, and it's possible that your video container won't support more complicated codecs. So I think this is more trouble than it's worth, and I'd leave the audio as-is.






        share|improve this answer




























          2














          2










          2









          8 KHz is fairly standard for speech, known as 'narrow band'. If this is speech then you should have plenty of options, although not that many are supported by FFmpeg out-of-the-box. Probably the best options are




          • AMR - you can compile libopencode-amrnb into FFmpeg for support

          • Opus, which will use the Vorbis CELT speech codec

          However 8KHz 8-bit PCM isn't a very good source in the first place: most encoders will expect / hope for better input, e.g. 8-bit G.711 mu-law which is effectively 12-bit data encoded as 8-bit floating point. They may not do well with pure 8-bit PCM input as it might not fit speech patterns they're modelled for.



          It's also a fairly small file already, and it's possible that your video container won't support more complicated codecs. So I think this is more trouble than it's worth, and I'd leave the audio as-is.






          share|improve this answer














          8 KHz is fairly standard for speech, known as 'narrow band'. If this is speech then you should have plenty of options, although not that many are supported by FFmpeg out-of-the-box. Probably the best options are




          • AMR - you can compile libopencode-amrnb into FFmpeg for support

          • Opus, which will use the Vorbis CELT speech codec

          However 8KHz 8-bit PCM isn't a very good source in the first place: most encoders will expect / hope for better input, e.g. 8-bit G.711 mu-law which is effectively 12-bit data encoded as 8-bit floating point. They may not do well with pure 8-bit PCM input as it might not fit speech patterns they're modelled for.



          It's also a fairly small file already, and it's possible that your video container won't support more complicated codecs. So I think this is more trouble than it's worth, and I'd leave the audio as-is.







          share|improve this answer













          share|improve this answer




          share|improve this answer










          answered Oct 15 at 13:09









          RupRup

          7821 gold badge11 silver badges17 bronze badges




          7821 gold badge11 silver badges17 bronze badges
























              2


















              Opus is generally considered the best low-bitrate codec available, and doesn't have problems with an 8kHz input sample rate. The resulting opus stream can still be decoded to whatever sample rate is convenient for the decoder. (Like other lossy codecs, it compresses based on frequency bands after doing an FFT. But some other codecs apparently only want to decode to the same sample rate as the input. As other answers point out, you can get FFmpeg to resample the input before giving it to the codec, but you don't need that for Opus.



              Try ffmpeg -c:a libopus -b:a 24k -frame_duration 120 for 24 kbit/s Opus.



              Perhaps worth trying: -application voip to tune for "improved speech intelligibility" instead of the default audio profile.



              Setting -frame_duration to the highest value reduces overhead, I think. You don't care about encoder / decoder latency because you just have files, not real-time 2-way voice chat. So you can let it buffer 120ms of audio and pack together multiple CELT or SILK frames to reduce redundancy of frame headers.




              The best available Opus encoder is the free and open source libopus (https://opus-codec.org) so FFmpeg can just use it, unlike with AAC where the best encoders are closed-source.



              Opus has special modes for very low bitrate speech (like 16kb/s), detecting speech and even switching over to a speech-specific encoder (SILK) at low bitrates.



              Opus's low-bitrate coding tools are similar to what HE-AACv2 can do, see the wikipedia article.





              But when I tried it, compared to the original, the file size increased ...




              Part of the point of lossy compression is that you can choose the output bitrate, trading off against quality. Most codecs can use -b:a 32k for example to choose an audio bitrate of 32 kbit/s.



              (For video, you can also trade off CPU time spent encoding, e.g. -preset veryslow vs. -preset medium. But compressing audio is cheap enough that most codecs don't have a lot of options for spending more CPU time to improve the bitrate vs. quality tradeoff.)



              Mono 8-bit 8kHz PCM has a bitrate of 64 kbit/s = 8 * 8000 so you're aiming for lower than that, otherwise you might as well keep your original files. PCM is just raw samples so bitrate is just a product of sample rate and sample width. Like the audio equivalent of a .bmp bitmap image. That's highly inefficient, and the reason better codecs were invented. (And as you know from listening, saving bitrate for PCM comes at a massive cost to quality and frequency range because bitrate is tied 1:1 with sample rate.
              That's not the case when you quantize in the frequency domain with a lossy codec.)





              and some high frequencies were attenuated. So, worse than -c:a copy




              FFmpeg's native AAC encoder -c:a aac used to be pretty bad, and you were using an old FFmpeg. https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is sometimes better than libfdk_aac for AAC-LC (low-complexity high bitrate). It doesn't mention HE-AAC, though, and that's what you want for low bitrate AAC.



              libfdk_aac used to be the best open-source AAC encoder available, and maybe still is for HE-AAC. AFAIK, neither of them are as good as the best non-free AAC encoders, though.



              For low-bitrate AAC, you really want HE-AAC which adds more coding tools https://en.wikipedia.org/wiki/High-Efficiency_Advanced_Audio_Coding. I'm not sure if -c:a aac can do that.



              https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio lists some recommended settings and ranges of useful bitrates for various encoders.



              But you probably want Opus, or possibly AMR-NB (narrowband) for bitrates like 4 kbit/s. I don't know how old the quality vs. bitrate plot on the Opus wiki article is, but it shows AMR-NB at higher quality than Opus down below 8kb/s.



              With that few bits, you might be able to understand speech but it won't sound nice. It's just a question of which codec is least horrible.






              share|improve this answer
































                2


















                Opus is generally considered the best low-bitrate codec available, and doesn't have problems with an 8kHz input sample rate. The resulting opus stream can still be decoded to whatever sample rate is convenient for the decoder. (Like other lossy codecs, it compresses based on frequency bands after doing an FFT. But some other codecs apparently only want to decode to the same sample rate as the input. As other answers point out, you can get FFmpeg to resample the input before giving it to the codec, but you don't need that for Opus.



                Try ffmpeg -c:a libopus -b:a 24k -frame_duration 120 for 24 kbit/s Opus.



                Perhaps worth trying: -application voip to tune for "improved speech intelligibility" instead of the default audio profile.



                Setting -frame_duration to the highest value reduces overhead, I think. You don't care about encoder / decoder latency because you just have files, not real-time 2-way voice chat. So you can let it buffer 120ms of audio and pack together multiple CELT or SILK frames to reduce redundancy of frame headers.




                The best available Opus encoder is the free and open source libopus (https://opus-codec.org) so FFmpeg can just use it, unlike with AAC where the best encoders are closed-source.



                Opus has special modes for very low bitrate speech (like 16kb/s), detecting speech and even switching over to a speech-specific encoder (SILK) at low bitrates.



                Opus's low-bitrate coding tools are similar to what HE-AACv2 can do, see the wikipedia article.





                But when I tried it, compared to the original, the file size increased ...




                Part of the point of lossy compression is that you can choose the output bitrate, trading off against quality. Most codecs can use -b:a 32k for example to choose an audio bitrate of 32 kbit/s.



                (For video, you can also trade off CPU time spent encoding, e.g. -preset veryslow vs. -preset medium. But compressing audio is cheap enough that most codecs don't have a lot of options for spending more CPU time to improve the bitrate vs. quality tradeoff.)



                Mono 8-bit 8kHz PCM has a bitrate of 64 kbit/s = 8 * 8000 so you're aiming for lower than that, otherwise you might as well keep your original files. PCM is just raw samples so bitrate is just a product of sample rate and sample width. Like the audio equivalent of a .bmp bitmap image. That's highly inefficient, and the reason better codecs were invented. (And as you know from listening, saving bitrate for PCM comes at a massive cost to quality and frequency range because bitrate is tied 1:1 with sample rate.
                That's not the case when you quantize in the frequency domain with a lossy codec.)





                and some high frequencies were attenuated. So, worse than -c:a copy




                FFmpeg's native AAC encoder -c:a aac used to be pretty bad, and you were using an old FFmpeg. https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is sometimes better than libfdk_aac for AAC-LC (low-complexity high bitrate). It doesn't mention HE-AAC, though, and that's what you want for low bitrate AAC.



                libfdk_aac used to be the best open-source AAC encoder available, and maybe still is for HE-AAC. AFAIK, neither of them are as good as the best non-free AAC encoders, though.



                For low-bitrate AAC, you really want HE-AAC which adds more coding tools https://en.wikipedia.org/wiki/High-Efficiency_Advanced_Audio_Coding. I'm not sure if -c:a aac can do that.



                https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio lists some recommended settings and ranges of useful bitrates for various encoders.



                But you probably want Opus, or possibly AMR-NB (narrowband) for bitrates like 4 kbit/s. I don't know how old the quality vs. bitrate plot on the Opus wiki article is, but it shows AMR-NB at higher quality than Opus down below 8kb/s.



                With that few bits, you might be able to understand speech but it won't sound nice. It's just a question of which codec is least horrible.






                share|improve this answer






























                  2














                  2










                  2









                  Opus is generally considered the best low-bitrate codec available, and doesn't have problems with an 8kHz input sample rate. The resulting opus stream can still be decoded to whatever sample rate is convenient for the decoder. (Like other lossy codecs, it compresses based on frequency bands after doing an FFT. But some other codecs apparently only want to decode to the same sample rate as the input. As other answers point out, you can get FFmpeg to resample the input before giving it to the codec, but you don't need that for Opus.



                  Try ffmpeg -c:a libopus -b:a 24k -frame_duration 120 for 24 kbit/s Opus.



                  Perhaps worth trying: -application voip to tune for "improved speech intelligibility" instead of the default audio profile.



                  Setting -frame_duration to the highest value reduces overhead, I think. You don't care about encoder / decoder latency because you just have files, not real-time 2-way voice chat. So you can let it buffer 120ms of audio and pack together multiple CELT or SILK frames to reduce redundancy of frame headers.




                  The best available Opus encoder is the free and open source libopus (https://opus-codec.org) so FFmpeg can just use it, unlike with AAC where the best encoders are closed-source.



                  Opus has special modes for very low bitrate speech (like 16kb/s), detecting speech and even switching over to a speech-specific encoder (SILK) at low bitrates.



                  Opus's low-bitrate coding tools are similar to what HE-AACv2 can do, see the wikipedia article.





                  But when I tried it, compared to the original, the file size increased ...




                  Part of the point of lossy compression is that you can choose the output bitrate, trading off against quality. Most codecs can use -b:a 32k for example to choose an audio bitrate of 32 kbit/s.



                  (For video, you can also trade off CPU time spent encoding, e.g. -preset veryslow vs. -preset medium. But compressing audio is cheap enough that most codecs don't have a lot of options for spending more CPU time to improve the bitrate vs. quality tradeoff.)



                  Mono 8-bit 8kHz PCM has a bitrate of 64 kbit/s = 8 * 8000 so you're aiming for lower than that, otherwise you might as well keep your original files. PCM is just raw samples so bitrate is just a product of sample rate and sample width. Like the audio equivalent of a .bmp bitmap image. That's highly inefficient, and the reason better codecs were invented. (And as you know from listening, saving bitrate for PCM comes at a massive cost to quality and frequency range because bitrate is tied 1:1 with sample rate.
                  That's not the case when you quantize in the frequency domain with a lossy codec.)





                  and some high frequencies were attenuated. So, worse than -c:a copy




                  FFmpeg's native AAC encoder -c:a aac used to be pretty bad, and you were using an old FFmpeg. https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is sometimes better than libfdk_aac for AAC-LC (low-complexity high bitrate). It doesn't mention HE-AAC, though, and that's what you want for low bitrate AAC.



                  libfdk_aac used to be the best open-source AAC encoder available, and maybe still is for HE-AAC. AFAIK, neither of them are as good as the best non-free AAC encoders, though.



                  For low-bitrate AAC, you really want HE-AAC which adds more coding tools https://en.wikipedia.org/wiki/High-Efficiency_Advanced_Audio_Coding. I'm not sure if -c:a aac can do that.



                  https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio lists some recommended settings and ranges of useful bitrates for various encoders.



                  But you probably want Opus, or possibly AMR-NB (narrowband) for bitrates like 4 kbit/s. I don't know how old the quality vs. bitrate plot on the Opus wiki article is, but it shows AMR-NB at higher quality than Opus down below 8kb/s.



                  With that few bits, you might be able to understand speech but it won't sound nice. It's just a question of which codec is least horrible.






                  share|improve this answer
















                  Opus is generally considered the best low-bitrate codec available, and doesn't have problems with an 8kHz input sample rate. The resulting opus stream can still be decoded to whatever sample rate is convenient for the decoder. (Like other lossy codecs, it compresses based on frequency bands after doing an FFT. But some other codecs apparently only want to decode to the same sample rate as the input. As other answers point out, you can get FFmpeg to resample the input before giving it to the codec, but you don't need that for Opus.



                  Try ffmpeg -c:a libopus -b:a 24k -frame_duration 120 for 24 kbit/s Opus.



                  Perhaps worth trying: -application voip to tune for "improved speech intelligibility" instead of the default audio profile.



                  Setting -frame_duration to the highest value reduces overhead, I think. You don't care about encoder / decoder latency because you just have files, not real-time 2-way voice chat. So you can let it buffer 120ms of audio and pack together multiple CELT or SILK frames to reduce redundancy of frame headers.




                  The best available Opus encoder is the free and open source libopus (https://opus-codec.org) so FFmpeg can just use it, unlike with AAC where the best encoders are closed-source.



                  Opus has special modes for very low bitrate speech (like 16kb/s), detecting speech and even switching over to a speech-specific encoder (SILK) at low bitrates.



                  Opus's low-bitrate coding tools are similar to what HE-AACv2 can do, see the wikipedia article.





                  But when I tried it, compared to the original, the file size increased ...




                  Part of the point of lossy compression is that you can choose the output bitrate, trading off against quality. Most codecs can use -b:a 32k for example to choose an audio bitrate of 32 kbit/s.



                  (For video, you can also trade off CPU time spent encoding, e.g. -preset veryslow vs. -preset medium. But compressing audio is cheap enough that most codecs don't have a lot of options for spending more CPU time to improve the bitrate vs. quality tradeoff.)



                  Mono 8-bit 8kHz PCM has a bitrate of 64 kbit/s = 8 * 8000 so you're aiming for lower than that, otherwise you might as well keep your original files. PCM is just raw samples so bitrate is just a product of sample rate and sample width. Like the audio equivalent of a .bmp bitmap image. That's highly inefficient, and the reason better codecs were invented. (And as you know from listening, saving bitrate for PCM comes at a massive cost to quality and frequency range because bitrate is tied 1:1 with sample rate.
                  That's not the case when you quantize in the frequency domain with a lossy codec.)





                  and some high frequencies were attenuated. So, worse than -c:a copy




                  FFmpeg's native AAC encoder -c:a aac used to be pretty bad, and you were using an old FFmpeg. https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio says that as of 2017, aac is sometimes better than libfdk_aac for AAC-LC (low-complexity high bitrate). It doesn't mention HE-AAC, though, and that's what you want for low bitrate AAC.



                  libfdk_aac used to be the best open-source AAC encoder available, and maybe still is for HE-AAC. AFAIK, neither of them are as good as the best non-free AAC encoders, though.



                  For low-bitrate AAC, you really want HE-AAC which adds more coding tools https://en.wikipedia.org/wiki/High-Efficiency_Advanced_Audio_Coding. I'm not sure if -c:a aac can do that.



                  https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio lists some recommended settings and ranges of useful bitrates for various encoders.



                  But you probably want Opus, or possibly AMR-NB (narrowband) for bitrates like 4 kbit/s. I don't know how old the quality vs. bitrate plot on the Opus wiki article is, but it shows AMR-NB at higher quality than Opus down below 8kb/s.



                  With that few bits, you might be able to understand speech but it won't sound nice. It's just a question of which codec is least horrible.







                  share|improve this answer















                  share|improve this answer




                  share|improve this answer








                  edited Oct 15 at 22:03

























                  answered Oct 15 at 16:11









                  Peter CordesPeter Cordes

                  3,07317 silver badges24 bronze badges




                  3,07317 silver badges24 bronze badges































                      draft saved

                      draft discarded















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1492214%2fwhich-audio-encoders-in-ffmpeg-support-8-khz%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown









                      Popular posts from this blog

                      Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                      Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                      Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367