oxen-io / session-android

A private messenger for Android.
https://getsession.org
GNU General Public License v3.0
1.87k stars 171 forks source link

Regarding voice notes in Session... #873

Open tuqueque opened 2 years ago

tuqueque commented 2 years ago

Hello…

I've noticed you compress and save voice notes in Session with the .aac format, mono channel, with an average bitrate of 32k, a sampling rate of 44.100Hz and AAC-LC codec…

I hope you're aware of the OPUS codec, a free, open source and better compression/quality audio format than AAC ( https://opus-codec.org/comparison/ ) … In my years of testing audio codecs and compression parameters, I'm very confident in what I'm saying, not to mention the Open Source nature of OPUS that should make it a much more compelling alternative than the proprietary AAC.

I can also confidently say that you are overshooting with the audio quality of something as simple as voice notes; even Whatsapp developers use OPUS codec and better (lower) compression parameters than you, their voice note files are half the size of yours… and people are perfectly happy with the quality of Whatsapp voice notes.

You could go even further than Whatsapp and compress a little bit more your voice note files, bringing them effectively to 1/3 of your current file sizes with a perfectly serviceable audio quality… and thus, increase the time limit of voice notes in Session to e.g. 3 minutes with the exact same current load to the servers.

BTW, Opus, being an open source codec and being established since 2012, is pretty much ubiquitous in all Android devices; remember, is the audio format used even by the evil villains of Facebook/Whatsapp.

Finally, my suggestion for OPUS codec parameters in Session's voice notes would be: OPUS codec, mono channel, sampling rate 24000Hz, 12k bitrate.

You can do your own testing and confirm my statements using the über popular FFMPEG with the following parameters:

ffmpeg -i "INPUT_AUDIO" -c:a libopus -map 0:a -map_metadata -1 -ac 1 -ar 24000 -vbr on -compression_level 10 -frame_duration 60 -application voip -b:a 12k -f opus "OUTPUT_AUDIO.opus"

I really hope you consider my suggestions (and consider increasing the time limit of voice notes in Session to a much more sensible time like 3 minutes).

Cheers.

hjubb commented 2 years ago

Thanks for the thorough details @tuqueque

This is definitely something that would improve the overall application. The voice notes feature may have been carried over at the time of forking from Signal and has a lot of potential improvements exactly like this, I'll try to get this in as soon as possible and make sure that the other clients (desktop, iOS) don't need any changes to support it, I'm fairly certain they should support it fine :+1:

tuqueque commented 2 years ago

Great! Thank you for the positive feedback!… I'm also confident everything will go fairly smooth when you implement this improvement.

The 1-minute limit for voice notes has been a "deal breaker" for a lot of people when I tell them to move to Session. Increasing that voice note limit to something like 5 minutes would convince all of them to do the switch.

tuqueque commented 2 years ago

hey, I don't want to be annoying, but... Any news about this feature/improvement?

I'm desperate to move to Session and leave Whatsapp, but the 1 minute limit in voice notes is a dealbreaker for me and my friends (we'd love to have something like 5 minutes).

hjubb commented 2 years ago

Hey @tuqueque I took a look into how difficult it would be to change to the suggested audio codec and settings and it seems like it require a bit more than just swapping out parameters. From what I could read it seemed like there might need to be some native libraries to ensure support across all the API levels as well as integrating them to the application possibly redoing how all of the current voice recording works, which wouldn't be impossible but just a lot more difficult than originally though. We would also need to ensure that those libraries and codecs are supported on the other platforms so that it didn't break anything for the other platforms as well. Will continue investigating and chat to the other platforms to see if it can be added shortly across all the clients, I'd love to see if there's some quality sliders to play around with in the meantime to try and see if there's a good middle ground for now to raise the allowed recording time. I'll keep you updated here