On Saturday, July 21, 2018 at 11:19:55 AM UTC-7, Timothy B. Terriberry wrote:
> raycarino--- via dev-media wrote:
> > I have a follow on question. What's the best way to determine an Ogg Opus 
> > file's encoded sample rate?
> 
> Opus is a lossy codec. The sample rate is something that is lost as part 
> of the lossy encoding. The original sample rate in the header gives you 
> a hint as to the best sample rate to run the decoder at to get all of 
> the information that was encoded, but it is perfectly possible to run it 
> any supported rate (8 kHz, 12 kHz, 16 kHz, 24 kHz, and 48 kHz), 
> regardless of how it was encoded.
> 
> You _could_ get some idea of the content of the audio by looking at the 
> TOC byte in each of the packets (c.f. RFC 6716 Section 3.1). NB implies 
> 8 kHz, MB implies 12 kHz, WB implies 16 kHz, SWB implies 24 kHz, and FB 
> implies 48 kHz. But this is allowed to change on a packet-by-packet 
> basis, and the encoder may in fact change it based on the content of the 
> audio that was fed to it and the requested bitrate (regardless of what 
> sampling rate the encoder was running at). I'm not aware of a tool that 
> actually inspects and reports on this information, either.

Thank you again Timothy! That all makes sense.

Hopefully these are my last follow-up questions. In general, I'm wondering 
whether there will be audio artifacts present when decoding at a different 
sample rate than what was encoded. Questions:
1. How does a high sample rate decoded at a lower sample rate behave? Example: 
will decode(48kHz.ogg 16kHz) === decode(16kHz.ogg, 16kHz), or can audio 
artifacts be expected?
2. Similarly, how does a low sample rate decoded at a higher sample rate 
behave? Example: will decode(16kHz.ogg, 48kHz) === decode(16kHz.ogg, 16kHz), or 
can audio artifacts be expected?

I'm hopeful that decoding with a different sample rate either has no 
distortion, or minimal distortion because:
(a) Firefox always seems to decode at 48kHz 
https://github.com/mozilla/gecko-dev/blob/f822a0b61631cbb38901569e69b4967176314aa8/dom/media/ogg/OpusParser.cpp#L46
(b) Chrome also seems to always decode at 48kHz 
https://github.com/chromium/chromium/blob/d196d28f53d37bad65feac0c0fb87a3b2c9480e9/remoting/codec/audio_decoder_opus.cc#L25
_______________________________________________
dev-media mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-media

Reply via email to