Use OPUS instead of AAC for audio files

I think audio files could have a lower size maintaining a good quality at lower bitrates (and sample rates but with lower changes) using OPUS format (with opus extension or ogg container) instead of AAC.

I made a test to support this using as basic information the constants here https://github.com/deltachat/deltachat-android/blob/master/src/org/thoughtcrime/securesms/audio/AudioCodec.java

I have used WAV and FLAC (without compression and lossless compression) as base files due a problem with audacity to export directly OPUS files.

Information about all audio files except base files, which only include the encoding pcm, are included in the name. I have made some others combinations specially since OPUS does not support 44100 hz of sample rate.

I have used 25kb as bitrate instead of 24 or 32 because I am still using the 0.304 version of Delta Chat Android whose audio files in my case are about 25 kb. 6kb is only to compare at lower bitrates and is officially supported by OPUS (and I would use it).

3 Likes

yip, in general, opus offers a better audio quality than aac at the same bitrates, this is known and was discussed eg. at https://github.com/deltachat/deltachat-android/issues/481

however, nevertheless, for now, aac is the better option for delta chat as it is supported natively on all platforms we’re targeting. this is not true for opus which would result in larger maintenance efforts then.

in the future, however, of course, we’d like to optimize that - maybe even going beyond opus then, eg. http://www.rowetel.com/?p=5373 :slight_smile:

https://developer.android.com/guide/topics/media/media-formats

For a future. It’s only supported the decoder from Android 5.0 natively.

Is it not possible embeded a library to supoort encode and decode the format? It is already made by Call Recorder: https://gitlab.com/axet/android-call-recorder/tree/HEAD

The developer has his own library on other repository https://gitlab.com/axet/android-audio-library/tree/master/src/main/java/com/github/axet/audiolibrary/encoders

sure it is possible, and we know how this can be done etc. we also know about the table.

however, it is effort (5 platforms …) and needs time that would be not available for maybe even more important things then. it’s all about resources and prioritisation :slight_smile:

One thing I think is really important, despite if we keep acc or not, is somehow (with lower quality ex. phone call quality) when media quality is set to worse quality, smaller size, the audio, videos, png images, should reduce their quality to get smaller size (png could be converted to jpg, or webp)

I dont think on much effort on all platforms even it is a good reason on the only case I dont know, IOS (hey, I have no problem about time but I think it would be possible in a near future)

Electron ships his own ffmpeg version bundled with him. (And I linked you the case on an Android library used in Call Recorder)

Also, if you check the test I have got a good enough quality for audio files with opus over 6Kbits and the final file size IS ABOUT LOWER THAN 1 KByte per second where AAC lose on quality.

1 Like

in fact, “outgoing media quality” not only changes image quality but the following settings:

  • jpg compression (balanced: 1280px 85%, worse: 640px 75%)
  • voice messages (balanced: 32kbit, worse: 16kbit)
  • videos: (balanced: 1500kbit-500kbit, depending on length, worse: always 500kbit)