Skip to content
/ opus Public

Add Support for 44.1 kHz #43

@GregSlazinski

Description

@GregSlazinski

I'm a passionate music listener, and a game developer, so I deal with a lot of music and sound files.
99.9% of the content that I encountered in my life is in 44.1 kHz sampling rate, but Opus does not support that. I'm really concerned about the resampling.

From the documentation https://wiki.xiph.org/OpusFAQ#But_won.27t_the_resampler_hurt_the_quality.3F_Isn.27t_it_better_to_use_44.1_kHz_directly.3F

The Opus encoder is heavily tuned for 48 kHz now and using it at 44.1 kHz will cause it to make sub-optimal decisions.

Isn't the better solution, is to add a special mode for the 44.1, and tune that mode the same way as 48 is tuned?
Because right now when trying to use Opus with 44.1, we have resampling + lossy compression on top of that. So 2 lossy operations.
If you would provide a tuned version of the encoder for 44.1 mode, then we would have only one lossy operation, which is the encoding, without having to do resampling. I think that would be the best solution.

I strongly believe that if you would add native support for 44.1 sampling rate, then Opus would become much more popular. Because, like I said at the start, at least in my experience, 44.1 is the 99.9% of the audio content flying on the internet, and because of the resampling needed, Opus doesn't seem like a perfect solution, for which I'm still sticking with Vorbis.

Activity

rillian

rillian commented on May 12, 2017

@rillian
Contributor

A mode tuned for 44.1 kHz (pretending it's actually 48 kHz) could be added, but it would be a lot of work without benefit. You needn't be concerned about resampling. There are many transparent (without audible artefacts) resamplers which will do a fine job converting 44.1 kHz input to 48 kHz for encoding in Opus.

Put another way, if you have an application where resampling causes quality loss, you should use a lossless compressor like FLAC instead of Opus.

gcp

gcp commented on May 12, 2017

@gcp
Contributor

I'm really concerned about the resampling...So 2 lossy operations....for which I'm still sticking with Vorbis.

The losses introduced by resampling are below audible thresholds. The whole workings of a lossy codec are a stack of lossy operations! Why focus on the one that has about the least loss of all of them? You're worrying about it in Opus, when in reality the quality loss due to it is far below the quality loss you get from Vorbis('s stack of lossy operations) as compared to Opus's.

Opus gives better quality at 44.1kHz than Vorbis does. And Opus does support 44.1kHz, unlike the bug title implies. Using a resampler doesn't mean it's not supported, on the contrary.

jmvalin

jmvalin commented on May 31, 2017

@jmvalin
Member

From a compatibility perspective, a 44.1 kHz Opus would be like a new codec and it would be incompatible with existing deployment. Breaking compatibility because of a thought experiment (assuming that resampling degrades quality despite no evidence existing) is not something we're going to do.

deleted a comment from on Aug 17, 2017
deleted a comment from on Aug 17, 2017
deleted a comment from on Aug 17, 2017
deleted a comment from on Aug 17, 2017
alexchandel

alexchandel commented on May 11, 2020

@alexchandel

Existing OPUS decoders can't follow a 44100 instruction? If not, adding 44.1 kHz output wouldn't break compatibility.

gmaxwell

gmaxwell commented on May 11, 2020

@gmaxwell
Contributor

They could not play it, which is exactly what breaking compatibility means. Worse, the quality would almost certainly be worse as a result of losing the benefit of the careful tuning of the codec. Not better. With a good resampler the conversion to 48kHz is essentially lossless, far far more so than the codec itself (technically a matched 44.1>48>44.1 conversion set could be made actually lossless if anyone cared to ever create such a thing). Opus doesn't do 44.1k because there is literally no point to do so, and supporting different rates makes life harder for decoders (especially ones that have to deal with streams from multiple sources simultaneously).

guest271314

guest271314 commented on May 27, 2020

@guest271314

Existing OPUS decoders can't follow a 44100 instruction? If not, adding 44.1 kHz output wouldn't break compatibility.

They could not play it, which is exactly what breaking compatibility means.

What does --raw-rate do?

  parec -v --raw -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | opusenc --raw-rate 44100 - $HOME/localscripts/output.opus
  mkvmerge -w --enable-durations -o $HOME/localscripts/output.webm $HOME/localscripts/output.opus

Firefox 76, Nightly 78, Chromium 81, mpv, ffplay each play the file.

mkvinfo -t output.webm

+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ Maximum EBML ID length: 4
|+ Maximum EBML size length: 8
|+ Document type: webm
|+ Document type version: 4
|+ Document type read version: 1
+ Segment: size 618781
|+ Seek head (subentries will be skipped)
|+ EBML void: size 4029
|+ Segment information
| + Timestamp scale: 22674
| + Multiplexing application: libebml v1.3.10 + libmatroska v1.5.2
| + Writing application: mkvmerge v46.0.0 ('No Deeper Escape') 32-bit
| + Duration: 00:01:00.784753962
| + Date: Wed May 27 03:32:52 2020 UTC
|+ Tracks
| + Track
|  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
|  + Track UID: 7354171215355932620
|  + Track type: audio
|  + Codec ID: A_OPUS
|  + Seek pre-roll: 00:00:00.080000000
|  + Codec's private data: size 19
|  + Language: und
|  + Codec-inherent delay: 00:00:00.006500000
|  + Audio track
|   + Sampling frequency: 44100
|   + Channels: 2
$ mkvmerge -J output.opus

{
  "attachments": [],
  "chapters": [],
  "container": {
    "properties": {
      "container_type": 23,
      "is_providing_timestamps": true
    },
    "recognized": true,
    "supported": true,
    "type": "Ogg/OGM"
  },
  "errors": [],
  "file_name": "output.opus",
  "global_tags": [],
  "identification_format_version": 12,
  "track_tags": [],
  "tracks": [
    {
      "codec": "Opus",
      "id": 0,
      "properties": {
        "audio_channels": 2,
        "audio_sampling_frequency": 44100,
        "number": 833194209,
        "tag_encoder": "opusenc from opus-tools 0.1.10"
      },
      "type": "audio"
    }
  ],
  "warnings": []
}
$ mediainfo output.opus

General
Complete name                            : output.opus
Format                                   : Ogg
File size                                : 560 KiB
Duration                                 : 1 min 0 s
Overall bit rate                         : 75.4 kb/s
Writing application                      : opusenc from opus-tools 0.1.10

Audio
ID                                       : 833194209 (0x31A988E1)
Format                                   : Opus
Duration                                 : 1 min 0 s
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 kHz
Compression mode                         : Lossy
Writing library                          : libopus 1.1.2
ffplay output.opus 

[ogg @ 0x9d200600] 693 bytes of comment header remain    0B f=0/0   
Input #0, ogg, from 'output.opus':
  Duration: 00:01:00.78, start: 0.000000, bitrate: 75 kb/s
    Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
    Metadata:
      ENCODER         : opusenc from opus-tools 0.1.10
ffprobe output.opus

[ogg @ 0x156b7a0] 693 bytes of comment header remain
Input #0, ogg, from 'output.opus':
  Duration: 00:01:00.78, start: 0.000000, bitrate: 75 kb/s
    Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
    Metadata:
      ENCODER         : opusenc from opus-tools 0.1.10
$ mpv output.opus

Playing: output.opus
 (+) Audio --aid=1 (opus 2ch 48000Hz)
AO: [pulse] 48000Hz stereo 2ch float
A: 00:01:00 / 00:01:00 (98%)
bezdelny

bezdelny commented on Feb 25, 2021

@bezdelny

ะะต, ะฝัƒ ั‘ะฟั‚ะฐ, ะฟะฐั†ะฐะฝั‹. ะ—ะฐั‡ะตะผ ะฒะฐะผ 48000 ะฒะพะพะฑั‰ะต ะธะทะฝะฐั‡ะฐะปัŒะฝะพ ะฒ ัั‚ะพะผ ะบะพะดะตะบะต? ะ’ั‹ ะดะตะปะฐะตั‚ะต ะตะณะพ ะฒ ะฟะตั€ะฒัƒัŽ ะพั‡ะตั€ะตะดัŒ ะดะปั ะฟะตั€ะตะดะฐั‡ะธ ั€ะตั‡ะธ? ะขะพะณะดะฐ ั‚ะฐะบ ะธ ะพั‚ะฒะตั‚ัŒั‚ะต ะฐะฒั‚ะพั€ัƒ ั‚ะพะฟะธะบะฐ, ั‡ั‚ะพะฑั‹ ะผัƒะทั‹ะบัƒ ัะฒะพัŽ ะบะพะดะธั€ะพะฒะฐะป ะฒะพ ั‡ั‚ะพ-ั‚ะพ ะดั€ัƒะณะพะต, ั‚.ะบ. ะพั‡ะตั€ะตะดะฝะพะน ะผะตะณะฐ-ััƒะฟะตั€-ะบะพะดะตะบ, ะบะพั‚ะพั€ั‹ะน ะผะฝะพะณะธะต ัะบัะฟะตั€ั‚ั‹ ะพะฟั€ะพะฑะพะฒะฐะฒ ั ะฟะพะผะพั‰ัŒัŽ ัะฒะพะธั… ะฝะตะฒะตั€ะพัั‚ะฝะพ ั‡ัƒะฒัั‚ะฒะธั‚ะตะปัŒะฝั‹ั… ัƒัˆะตะน ะธ ัƒะบะฐะทะฐะปะธ ะฝะฐ ะตะณะพ ะฝะตะพัะฟะพั€ะธะผะพะต ะฟั€ะตะฒะพัั…ะพะดัั‚ะฒะพ ะฝะฐะด ะดั€ัƒะณะธะผะธ, ะฟะพะฟั€ะพัั‚ัƒ ะฝะต ะฟั€ะตะดะฝะฐะทะฝะฐั‡ะตะฝ ะดะปั ะผะตะปะพะผะฐะฝะพะฒ.
ะ‘ั€ะพ, ะบะพะฝะฒะตั€ั‚ะธั€ัƒะน ะฒัั‘ ะฒ AAC ั‡ะตั€ะตะท iTunes ะธ ะฑะพะปัŒัˆะต ะฝะต ะฟะฐั€ัŒัั ะฝะธ ะพ ั‡ั‘ะผ, ะฒัั‘ ั€ะฐะฒะฝะพ ะฟะพะดะตะปะธั ะฒ ะฒะธะดะต Vorbis ะธ Opus ะฝะต ะฟะพะดะดะตั€ะถะธะฒะฐัŽั‚ัั ั‚ะฐะบะธะผ ะฑะพะปัŒัˆะธะผ ะฟะตั€ะตั‡ะฝะตะผ ะถะตะปะตะทะฐ, ะบะฐะบ MP3 ะธ AAC, ั‡ั‚ะพ ั‚ั€ะตะฑัƒะตั‚ ะดะพะฟะพะปะฝะธั‚ะตะปัŒะฝั‹ั… ั€ะตััƒั€ัะพะฒ ะดะปั ะธั… ะดะตะบะพะดะธั€ะพะฒะฐะฝะธั.
ะฃะดะฐั‡ะธ.

petterreinholdtsen

petterreinholdtsen commented on Feb 25, 2021

@petterreinholdtsen
rillian

rillian commented on Feb 26, 2021

@rillian
Contributor

According to Google's translation service, the Russian comment recommends MPEG codecs as better for music because they are more broadly supported and don't require resampling to/from 44.1 kHz.

silverbacknet

silverbacknet commented on Nov 24, 2022

@silverbacknet
Contributor

If you'd like to discuss the objective, testable and measurable merits of resampling, you want HydrogenAudio.

If you'd like to start an opinionated flame war, there's Reddit, AVSForum, etc.

If there's a bug in the code or an entirely overlooked feature you've noticed, then Github is the right place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rillian@jmvalin@alexchandel@petterreinholdtsen@gmaxwell

        Issue actions

          Add Support for 44.1 kHz ยท Issue #43 ยท xiph/opus