Skip to content

Commit

Permalink
improve voice message quality
Browse files Browse the repository at this point in the history
first it was tried with sampling rate 44100 but this showed an error on safari when try to playback.

by direct comparison to 44100, 22050 has lower quality but it's totally okay compared to the quality before when no sampling rate was set. I'm not sure why it failed on safari, because the iOS app also uses 44100.

see #2714

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
  • Loading branch information
mahibi authored and backportbot-nextcloud[bot] committed Jan 25, 2023
1 parent 4863f84 commit fe3aa9c
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,9 @@ class ChatController(args: Bundle) :
setOutputFile(file)
setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
setAudioEncoder(MediaRecorder.AudioEncoder.AAC)
setAudioSamplingRate(VOICE_MESSAGE_SAMPLING_RATE)
setAudioEncodingBitRate(VOICE_MESSAGE_ENCODING_BIT_RATE)
setAudioChannels(VOICE_MESSAGE_CHANNELS)

try {
prepare()
Expand Down Expand Up @@ -3461,6 +3464,11 @@ class ChatController(args: Bundle) :
private const val VOICE_RECORD_CANCEL_SLIDER_X: Int = -50
private const val VOICE_MESSAGE_META_DATA = "{\"messageType\":\"voice-message\"}"
private const val VOICE_MESSAGE_FILE_SUFFIX = ".mp3"
// Samplingrate 22050 was chosen because somehow 44100 failed to playback on safari when recorded on android.
// Please test with firefox, chrome, safari and mobile clients if changing anything regarding the sound.
private const val VOICE_MESSAGE_SAMPLING_RATE = 22050
private const val VOICE_MESSAGE_ENCODING_BIT_RATE = 32000
private const val VOICE_MESSAGE_CHANNELS = 1
private const val FILE_DATE_PATTERN = "yyyy-MM-dd HH-mm-ss"
private const val VIDEO_SUFFIX = ".mp4"
private const val SHORT_VIBRATE: Long = 20
Expand Down

0 comments on commit fe3aa9c

Please sign in to comment.