HydrogenAudio

Lossy Audio Compression => Ogg Vorbis => Ogg Vorbis - General => Topic started by: EekWit on 2017-07-07 20:52:44

Title: libvorbis and sample rate
Post by: EekWit on 2017-07-07 20:52:44
I am using libvorbis via ffmpeg to encode high sample rate flacs in vorbis "-q 3".

The flacs have a sample rate of 192 kHz. Feeding these straight to the libvorbis encoder via ffmpeg results in very noticeable artifacts during playback. Resampling to 48k using "-ar 48k" in ffmpeg removes these very noticeable artifacts.

Since 48k was an arbitrary choice I am interested to know whether 44.1k or some other sample rate would result in better quality encodes. What is the ideal sample rate for the libvorbis encoder?
Title: Re: libvorbis and sample rate
Post by: lithopsian on 2017-07-07 21:02:52
Is it just trying too hard to maintain the high sample-rate data and effectively encoding at too low a bitrate? Hence artifacts. Does it sound better at a higher quality setting, obviously with larger files? q3 is borderline for transparency anyway, anything might tip it over the edge.

Just for background, Vorbis supports sample rates from 8-192 kHz, none any more ideal than another. So really the question needs to be what is the ideal sample rate for your application.
Title: Re: libvorbis and sample rate
Post by: EekWit on 2017-07-07 21:32:07
The bit rate allocated by the encoder seems flexible. Without resampling (192 kHz) the average bit rate is around 145k. With resampling (to 48 kHz) the average bit rate is around 112k. The encoder seems to be using more bits to cope with the higher sample rate. I will need to check to see if a higher quality setting + high sample rate sounds better than q3 + reduced sample rate. I originally decided to use q3 because I can't abx it.

Regarding playback, 48k sample rate is the highest sample rate which my USB sound card supports so that would be preferable.

I am curious though as to why the quality of the output file is worse when preserving the original sample rate of 192 kHz, even though the encoder makes use of more bits.
Title: Re: libvorbis and sample rate
Post by: Deathcrow on 2017-07-08 08:38:12
I think it's a good idea to remove frequencies that you can't hear if you intend to exclusively listen to those vorbis files. If you want to (probably marginally) improve your processing chain you can use sox with ffmpeg (if your version has support for sox). Something like this:

Code: [Select]
-af aresample=resampler=soxr:precision=28:osr=48

Quote
I am curious though as to why the quality of the output file is worse when preserving the original sample rate of 192 kHz, even though the encoder makes use of more bits.

I'm no expert, but it seems obvious that - depending on how much high frequency audio is in your file - it needs a lot more bits for 4 times the frequency range. Vorbis though is only increasing its bitrate to ~120% instead of 400%. No idea how vorbis works in this mode and what it discards (no psychoaccustics I guess? Since all of that is inaudible anyway). I'd bet money on it that the encoder is just not properly tuned for sampling rates like this.
Title: Re: libvorbis and sample rate
Post by: EekWit on 2017-07-08 17:40:40
This may be a silly question, but would there be an advantage to using the SoX resampler even when downsampling to 48 kHz which is an integer factor of 192 kHz?
Title: Re: libvorbis and sample rate
Post by: saratoga on 2017-07-08 18:17:46
Resampling by an integer ratio is not meaningfully different than resampling by any rational number ratio.

Sox is a good resampler which is unlikely to have artifacts. If there is an advantage depends on the accuracy of the alternative resampler.