Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: libvorbis and sample rate (Read 9138 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

libvorbis and sample rate

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?

Re: libvorbis and sample rate

Reply #1
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.

Re: libvorbis and sample rate

Reply #2
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.

Re: libvorbis and sample rate

Reply #3
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.

Re: libvorbis and sample rate

Reply #4
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?

Re: libvorbis and sample rate

Reply #5
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.