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 deltachat-android/AudioCodec.java at master · deltachat/deltachat-android · GitHub

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).

7 Likes

yip, in general, opus offers a better audio quality than aac at the same bitrates, this is known and was discussed eg. at use lower bitrate for aac voice-messages · Issue #481 · deltachat/deltachat-android · GitHub

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. Codec 2 700C – Rowetel :slight_smile:

1 Like

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

1 Like

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)

I would like to know if at least the mimetype could be added to the clients to be able to play it as some audio files already supported, f.e. wav is already supported. In this case as optional someone could send an audio file in opus using *.oga standard extension by choosing the “Audio” option in the extended dialog for attached files.

as part of the “safe traffic” effort, it would be useful if a more aggressive option is added to the “outgoing media quality” that produce audio and video with a lot less quality, currently audio is too big for a few seconds, and a “phone call like” quality will be useful, and current video size is unacceptable for my budget :wink:

the “outgoing media quality” already affects the audio bitrate (24kbit instead of 32kbit), maybe we could lower this a bit more, but everything else seems to be out of scope at least for the nearest future.

@r10s check @anon93826752 is tests, there are better compression rates, the current is too much, it could be about 1KB per second or so, for voice messages

i know, see also the links i have posted above. but this requires changing the codec and the maybe require additional libraries or checking them out - on all supported systems - and this is a bit out of scope for now - unless, of course, some volunteer pushes that forward :slight_smile:

@r10s please I need you to reply my new question. Could the mimetype be added for sending audio files? When I use the audio dialog to choose a file only a few formats are allowed. At least it would be great if the mimetype for that and the player are added. In such cases, phones which have the decoder by default (Android 5+ for example) wouldn’t have to download and play the audio file manually.

adding a mimetype seems to be easy. which mimetype is missing exactly?

audio/ogg and audio/opus

I could not choose files using opus codec with the standarized .oga nor extensions the other day. I am not sure but I think the seems apply for vorbis codec.

Has this issue been revisited lately? AAC files are three times size of same audio track encoded with OPUS in my experience. At least enable it for platforms that already support it, why does it have to be all or nothing? For example my desktop delta chat client will already play the opus files no problem, but the iOS client will not at present.

1 Like

because it is not about your current platform supporting it but the platforms of the peers you are reaching, and you don’t know what they will use to read your email, could be that they don’t even use Delta Chat

that aside, I would also love to use OPUS