Fix and improve voice recording, default to opus

This commit is contained in:
Arne 2025-01-03 15:39:24 +01:00
parent 49d3f2d078
commit c1d317b017
2 changed files with 6 additions and 5 deletions

View file

@ -5328,10 +5328,11 @@ public class ConversationFragment extends XmppFragment
}
final int outputFormat;
if (("opus".equals(userChosenCodec) || ("".equals(userChosenCodec) && Config.USE_OPUS_VOICE_MESSAGES)) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
outputFormat = MediaRecorder.OutputFormat.OGG;
outputFormat = MediaRecorder.OutputFormat.WEBM;
mRecorder.setOutputFormat(outputFormat);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.OPUS);
mRecorder.setAudioEncodingBitRate(32000);
mRecorder.setAudioEncodingBitRate(64000);
mRecorder.setAudioSamplingRate(48000);
} else if ("mpeg4".equals(userChosenCodec) || !Config.USE_OPUS_VOICE_MESSAGES) {
outputFormat = MediaRecorder.OutputFormat.MPEG_4;
mRecorder.setOutputFormat(outputFormat);
@ -5514,8 +5515,8 @@ public class ConversationFragment extends XmppFragment
final String extension;
if (outputFormat == MediaRecorder.OutputFormat.MPEG_4) {
extension = "m4a";
} else if (outputFormat == MediaRecorder.OutputFormat.OGG) {
extension = "oga";
} else if (outputFormat == MediaRecorder.OutputFormat.WEBM) {
extension = "opus";
} else if (outputFormat == MediaRecorder.OutputFormat.THREE_GPP) {
extension = "awb";
} else {

View file

@ -57,7 +57,7 @@
android:key="clear_blocked_media" />
<ListPreference
android:title="@string/voice_message_codec"
android:defaultValue="mpeg4"
android:defaultValue="opus"
android:entries="@array/voice_codec_entries"
android:entryValues="@array/voice_codec_values"
android:key="voice_message_codec"