You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For supported sample rates other than 48k (i.e. 8k, 12k, 16k, 24k), OggOpusWriter generates an incorrectly reported duration, which causes bizarre behaviors depending on the audio player.
This generates left-right-demo-5s.wav.opus with an incorrect duration (ffmpeg reports 1.26s; opusinfo reports 2.149s), which will confuse various tools and audio players (e.g. VLC and Totem cut off early; pyogg throws an exception on open.)
Initially, I thought this was because OggOpusWriter always writes a sample rate of 0 (unspecified) in the Opus header. However, specifying the original sample rate in the header does not correct this duration issue:
importpyoggsr=12000encoder=pyogg.OpusBufferedEncoder()
encoder.set_application("audio")
encoder.set_sampling_frequency(sr)
encoder.set_channels(1)
encoder.set_frame_size(20)
writer=pyogg.OggOpusWriter("should_be_1s.opus", encoder)
# HACK: Get OggOpusWriter to specify the sample rate in the header.pyogg.OggOpusWriter._make_identification_header.__defaults__= (sr,)
bytes_per_sample=2samples=bytearray(sr*bytes_per_sample)
writer.write(samples)
writer.close()
Running opusinfo on should_be_1s.opus correctly reports "Original sample rate: 12000Hz", but still reports a playback length of .25 seconds.
Any idea what's going wrong?
The text was updated successfully, but these errors were encountered:
ijc8
changed the title
OggOpusWriter: Write sample rate in Opus header.
OggOpusWriter: Incorrect duration when sample rate is not 48kHz.
Sep 19, 2021
For supported sample rates other than 48k (i.e. 8k, 12k, 16k, 24k), OggOpusWriter generates an incorrectly reported duration, which causes bizarre behaviors depending on the audio player.
To reproduce:
examples/left-right-demo-5s.wav
to 12k (e.g.sox left-right-demo-5s.wav -r 12k 12k.wav; mv 12k.wav left-right-demo-5s.wav
)examples/03-write-ogg-opus.py
left-right-demo-5s.wav.opus
with an incorrect duration (ffmpeg reports 1.26s; opusinfo reports 2.149s), which will confuse various tools and audio players (e.g. VLC and Totem cut off early; pyogg throws an exception on open.)Initially, I thought this was because OggOpusWriter always writes a sample rate of 0 (unspecified) in the Opus header. However, specifying the original sample rate in the header does not correct this duration issue:
Running
opusinfo
onshould_be_1s.opus
correctly reports "Original sample rate: 12000Hz", but still reports a playback length of .25 seconds.Any idea what's going wrong?
The text was updated successfully, but these errors were encountered: