Programmable Media

Optimize audio files

Last updated: Oct-30-2024

Overview

Optimizing your audio files is important for improving performance of your website or application. Compression techniques used on audio files reduce the size of files, speed up download times and reduce the amount of bandwidth required.

This guide focuses on pure audio files. For information on addressing audio components of video files, see the Video optimization guide.

How to optimize audio format

Some audio formats use more compression than others, and some use no compression at all. The quality of compressed audio may not be as perfect as the uncompressed equivalent, but for many purposes it is acceptable and the difference is not perceivable by most people.

You can change the format of an audio file that you've uploaded to Cloudinary by changing the delivery URL extension to one of the audio formats that is supported for delivery by Cloudinary.

Note
Audio files are uploaded to Cloudinary as video asset types.

For example, the asset in the demo product environment with public ID docs/fireflywav is a WAV file (not compressed). You can deliver it as an MP3 file (compressed) by using the .mp3 extension in the delivery URL:

Use the HTML audio tag

The main audio formats supported by web browsers are AAC, OGG, WAV and MP3.

AAC, OGG and MP3 are compressed formats, so they download faster and use less bandwidth than WAV files. WAV files provide the highest quality, but depending on your application, the sound quality of ACC, OGG and MP3 are likely to be sufficient.

This table shows the file size of the fireflywav audio snippet when delivered in each of the different formats:

Format File Size
AAC 126 KB
OGG 147 KB
MP3 191 KB
WAV 889 KB

If you use the <audio> tag on your site, you can set the src in each of the <source> tags to different formats in your preferred order. The browser picks the first one that it supports. Therefore, to prioritize optimization over quality, design your <audio> tag as follows:

How to optimize audio quality

Certain compressed audio formats can be compressed further by reducing the bitrate.

Use the bit_rate parameter (br in URLs) for advanced control of the bitrate.

bit_rate can take one of the following values (corresponding to the maximum bitrate):

  • An integer e.g. 120000.
  • A string supporting 'k' and 'm' (kilobits and megabits respectively) e.g. 250k or 2m.

For example, setting the maximum bitrate of the uploaded fireflywav audio snippet to 50k, and delivering it as an MP3, reduces the file size to 61 KB:

See the Transformation URL API reference for further syntax details.

Automatic quality for audio

When using automatic quality (q_auto in URLs) on video files, the audio is not affected. However, when used on audio-only MP3 files, the delivered file uses an optimal encoding to reduce the size without impacting audio quality.

Using automatic quality on the bubbles MP3 file results in a file size of 858 KB (reduced from 1.1 MB):

Related topics

Learn about other audio transformations.

✔️ Feedback sent!

Rate this page: