Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Incorrect duration when sample rate is not 48kHz #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyogg/opus_buffered_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ def buffered_encode(self,
)
pcm_ctypes = Buffer.from_buffer(pcm_bytes)

samples_multiplier = 48000 // self._samples_per_second
# Either store the encoded packet to return at the end of the
# method or immediately call the callback with the encoded
# packet.
def store_or_callback(encoded_packet: memoryview,
samples: int,
end_of_stream: bool = False) -> None:
# As far as the audio is decoded in 48kHz, the position in a stream should be stored
# according to this rate, not the original one
samples *= samples_multiplier
if callback is None:
# Store the result
results.append((
Expand Down