Forums

    4 posts

  • avatar
    884 sounds
    73 posts
    Using Opus codec for sound previews?


    I was wondering if Freesound's previews could be slowly migrating towards using Opus instead of MP3 encoding.

    That would provide significant sound quality improvement with the same bitrate, because Opus is a much more modern and advanced codec.

    I don't think re-generating the preview files at once would be possible or even make sense, but maybe the newly uploaded sounds could start using that, and then maybe each week the top N most popular sounds's previews could be encoded to the new coded to improve preview quality until all are processed eventually? (maybe excluding sounds below a certain popularity threshold which would I guess limit the workload that'd provide hardly any visible benefit to the site users).

    I believe the Opus Codec is widely supported by all web browsers already.

    More information: https://opus-codec.org/

    What do you think?

    Wanna learn about music proudction? YouTube
  • avatar
    249 sounds
    580 posts


    I've done a quick test on a song for which I have the wav and a cbr 128kb/s mp3.

    I've used opusenc from the opus-tools package, and obtained a cbr 128kb/s opus which is half the size of the mp3.

    The result shows 2 side effects, one unavoidable but not necessarily too relevant for the preview use case (source was 44.1kHz, output is 48kHz), and one not controllable via opusenc options (source peaks at -0.1dB, output peaks at +0.675dB) which may be an issue with hot recordings; even though the output doesn't sound badly distorted, Audacity shows a lot of clipping.

    That said, mp3 conversion also tends to boost the gain, so maybe that's already accounted for by the preview creation (haven't checked the code atm).

    As for the complete substitution, it could be throttled down not to hog too many resources, no matter how long it takes, and ordering/filtering by popularity as you suggest would make it useful since the beginning of the whole process.

    All in all, I like the idea.

  • avatar
    884 sounds
    73 posts


    As for the issues with clipping after encoding - I usually see people recommending to master your music to -1 dBFS True Peak (inter-sample peaks taken into account).

    I guess `sox` could be used to perform limiting if necessary, to avoid clipped previews before they are encoded. Probably something like that is already used done.

    Wanna learn about music proudction? YouTube
  • avatar
    249 sounds
    580 posts


    Yes, -1dB is my usual target, I've had to go to -1.5dB only for some very busy mixes.

    Anyway I've taken a peek at the code, and the preview creation does no gain adjustment at all on the source; since it hasn't been an issue so far with the mp3 previews, I guess it'd be the same with opus ones.

    4 posts