-
-
Notifications
You must be signed in to change notification settings - Fork 40
Conversation
Opus codec supports low latency and high quality audio recording. I think we should make more reasonable defaults and allow more fine grained control for people who know what they are doing. Another stab at fixing you-apps#193. Since you-apps#235 as an addition to disabling sample rate control setting up the bitrate is no longer working for opus file recordings. These sample rates are natively supported by the opus encoder with no resampling involved: 8, 12, 16, 24, or 48 kHz. See this FAQ answer and a few follow up answers https://wiki.xiph.org/OpusFAQ#What_is_Opus_Custom? When not specifying the sample rate at all resulting files have some kind of default sample rate that severely degrades audio quality. When inspecting files with ffmpeg the sample rate is always displayed as 48000. I have verified that setting the sample rate it increases audio quality though. Changes based off of this: * Again respect bitrate setting when recording into opus. Bitrate of 32000, 40000 or 48000 sound very goot for casual recordings sampled at 48000 Hz. * Allow setting sample rate for opus encoding when specifying one of the supported values.
if (audioFormat.codec != MediaRecorder.AudioEncoder.OPUS) { | ||
Preferences.prefs.getInt(Preferences.audioSampleRateKey, -1).takeIf { it > 0 } | ||
?.let { | ||
Preferences.prefs.getInt(Preferences.audioSampleRateKey, -1).takeIf { it > 0 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should extract this and the bitrate preference to variables first, that would make things cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitrate preference is exactly as all the other preferences even before the issue with opus recording was discovered so I haven't yet touched that one. If you insist I will change that of course.
As for the sample rate I have extracted it to a variable but I am not sure it's the way you would like to have it. I don't want to introduce more conditions so the change is just minimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just pushed some minor code simplifications.
Thanks!
Opus codec supports low latency and high quality audio recording. I think we should make more reasonable defaults and allow more fine grained control for people who know what they are doing. Another stab at fixing #193.
Since #235 as an addition to disabling sample rate control setting up the bitrate is no longer working for opus file recordings.
These sample rates are natively supported by the opus encoder with no resampling involved: 8, 12, 16, 24, or 48 kHz. See this FAQ answer and a few follow up answers https://wiki.xiph.org/OpusFAQ#What_is_Opus_Custom?
When not specifying the sample rate at all resulting files have some kind of default sample rate that severely degrades audio quality. When inspecting files with ffmpeg the sample rate is always displayed as 48000. I have verified that setting the sample rate it increases audio quality though. Changes based off of this: