diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/codecs/OpusCodecBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/codecs/OpusCodecBytecodePatch.kt
new file mode 100644
index 000000000..c14c29b5d
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/youtube/misc/codecs/OpusCodecBytecodePatch.kt
@@ -0,0 +1,8 @@
+package app.revanced.patches.youtube.misc.codecs
+
+import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
+import app.revanced.patches.shared.opus.BaseOpusCodecsPatch
+
+object OpusCodecBytecodePatch : BaseOpusCodecsPatch(
+ "$MISC_PATH/OpusCodecPatch;->enableOpusCodec()Z"
+)
diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/codecs/OpusCodecPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/codecs/OpusCodecPatch.kt
new file mode 100644
index 000000000..62d899d45
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/youtube/misc/codecs/OpusCodecPatch.kt
@@ -0,0 +1,33 @@
+package app.revanced.patches.youtube.misc.codecs
+
+import app.revanced.patcher.data.ResourceContext
+import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
+import app.revanced.patches.youtube.utils.settings.SettingsPatch
+import app.revanced.util.patch.BaseResourcePatch
+
+@Suppress("unused")
+object OpusCodecPatch : BaseResourcePatch(
+ name = "Enable OPUS codec",
+ description = "Adds an options to enable the OPUS audio codec if the player response includes.",
+ dependencies = setOf(
+ OpusCodecBytecodePatch::class,
+ SettingsPatch::class
+ ),
+ compatiblePackages = COMPATIBLE_PACKAGE
+) {
+ override fun execute(context: ResourceContext) {
+
+ /**
+ * Add settings
+ */
+ SettingsPatch.addPreference(
+ arrayOf(
+ "PREFERENCE_CATEGORY: MISC_EXPERIMENTAL_FLAGS",
+ "SETTINGS: ENABLE_OPUS_CODEC"
+ )
+ )
+
+ SettingsPatch.updatePatchStatus(this)
+
+ }
+}
diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml
index 58f2ce887..8113c28c3 100644
--- a/src/main/resources/youtube/settings/host/values/strings.xml
+++ b/src/main/resources/youtube/settings/host/values/strings.xml
@@ -1433,6 +1433,9 @@ Tap on the continue button and disable battery optimizations."
Disable QUIC protocol
"Disable CronetEngine's QUIC protocol."
+ Enable OPUS codec
+ Enable the OPUS codec if the player response includes the OPUS codec.
+
Spoof player parameter
"Spoofs player parameters to prevent playback issues.
diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
index 7323f220d..b3f5e9678 100644
--- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml
+++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
@@ -599,6 +599,9 @@
+
+
@@ -674,6 +677,7 @@
+