From b581e7946f39cfaee681211302dc33a2c47ba759 Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Sun, 14 Sep 2025 17:43:09 -0400 Subject: [PATCH 1/2] fix: Remove Extra Bytes Added By Discord Before OPUS Decoding --- discord/voice_client.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/discord/voice_client.py b/discord/voice_client.py index cb475a96ff..a36a81fa67 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -652,9 +652,10 @@ def _decrypt_aead_xchacha20_poly1305_rtpsize(self, header, data): nonce[:4] = data[-4:] data = data[:-4] - return self.strip_header_ext( - box.decrypt(bytes(data), bytes(header), bytes(nonce)) - ) + r = box.decrypt(bytes(data), bytes(header), bytes(nonce)) + # Discord adds 8 bytes of data before the opus data. + # This can be removed, and at this time, discarded as it is unclear what they are for. + return r[8:] @staticmethod def strip_header_ext(data): @@ -774,7 +775,7 @@ def unpack_audio(self, data): data: :class:`bytes` Bytes received by Discord via the UDP connection used for sending and receiving voice data. """ - if data[1] != 0x78: + if data[1] & 0x78 != 0x78: # We Should Ignore Any Payload Types We Do Not Understand # Ref RFC 3550 5.1 payload type # At Some Point We Noted That We Should Ignore Only Types 200 - 204 inclusive. From 8f0cf4b1b0255b86684720917cbfcbedb4e5dce0 Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Sun, 14 Sep 2025 17:59:46 -0400 Subject: [PATCH 2/2] chore: Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb928d9d80..3098be39c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2916](https://github.com/Pycord-Development/pycord/pull/2916)) - Fixed a crash when processing message edit events while message cache was disabled. ([#2924](https://github.com/Pycord-Development/pycord/pull/2924)) +- Fixed OPUS Decode Error when recording audio. + ([#2925](https://github.com/Pycord-Development/pycord/pull/2925)) ### Removed