Skip to content

Add support for higher audio sample rates. #659

Open

Description

@bradleysepos

88.2/96/176.4/192 kHz encoding/passthrough. See also #483.

This will need some special care, as many devices do not support sample rates higher than 48 kHz. I have some ideas for this but time not permitting, for now this placeholder will have to suffice.

Activity

  1. added this to the Unscheduled milestone on Mar 26, 2017
  2. self-assigned this
    on Mar 26, 2017
  3. bradleysepos commented on Jun 6, 2017

    @bradleysepos
    ContributorAuthor

    Targeting for 1.2.0.

    Here are the device/playback scenarios I'm envisioning we may need to support in one way or another:

    • Support for 44.1/48 kHz only. We should transcode to one or the other based on the input (e.g. 11.025/22.05 kHz to 44.1 kHz; 8/16/24/32 to 48 kHz. This mode could possibly be the default, as it's very similar to what we do now and is the most compatible.
    • Support for all standard sample rates up to 48 kHz. There is some risk that a non-standard or sufficiently unpopular sample rate may not be supported on some devices. I'm not terribly concerned about this, as it's an edge case (never even seen it) that can be worked around with custom presets.
    • Support for 44.1/48 kHz for the first, more compatible track, and support for higher sample rates for supplementary tracks. Continuing with paradigm of the first track is stereo at limited bit rate, second track is surround or similar.
    • Support for higher sample rates for all tracks.

    Making matters more interesting, some devices do not support only certain higher sample rates, such as 176.4 kHz.

    What we need is a concise set of controls on the audio defaults sheet:

    1. Convert sample rates less than 48 kHz to: (radio/select)
      (o) 44.1/48 kHz (Auto)
      ( ) 48 kHz
      ( ) Do not convert
    2. Allow HD sample rates: (checkbox)
      [x] 88.2 kHz [x] 96 kHz [ ] 176.4 kHz [x] 192 kHz
    3. _[x] Limit first encoder for each selected track to 48 kHz (checkbox)

    handbrake-hd-audio

    It's not perfect, but I believe it covers the a high percentage of what people will want, and it fits into the existing paradigm and controls. I'm certainly open to feedback and discussion.

  4. bradleysepos commented on Jun 6, 2017

    @bradleysepos
    ContributorAuthor

    I failed to mention, we could theoretically remove the Samplerate column entirely. But it's probably better to keep it, populated with a selection based on what the other controls make available. This gives the maximum flexibility so the user can select options outside of what these rules provide for.

  5. bradleysepos commented on Jun 6, 2017

    @bradleysepos
    ContributorAuthor

    Another thing that came up in conversation with a friend: enabling "Limit first encoder for each selected track to 48 kHz" should guarantee a compatible audio track, especially when combined with "Convert sample rates less than 48 kHz (to 44.1/48)". These options should probably be default in the official presets.

    I just realized the irony of how this looks given I was and am against the Opus codec's initial enforcement of converting all input to 48 kHz. But I'm not advocating that at all; I'm advocating options to limit sample rate to 48 kHz for compatibility, and to upsample lesser rates to either 44.1 or 48 kHz for compatibility. This is similar to what even an inexpensive non-oversampling DAC with dual crystal oscillators does, and matching this behavior is superior to Opus' method when using one.

  6. bradleysepos commented on Jun 7, 2017

    @bradleysepos
    ContributorAuthor

    Second comp. This integrates some feedback and also shows what the default settings should be.

    handbrake-hd-audio2

  7. modified the milestones: 1.2.0, 1.3.0 on Oct 3, 2018
  8. modified the milestones: 1.3.0, Unscheduled on Jan 1, 2019
  9. fireattack commented on Apr 18, 2020

    @fireattack

    Just want to provide a use case.

    Lately I found 96k/24b audio is more and more common in blu-rays I purchased (mainly live concerts), and I wish to transcode them with the same sample rate (I use FLAC codec, which supports it.)

    Currently I have to convert the audio track manually and then merge it back using mkvmerge, which isn't a big problem but would be great to not need to.

  10. added a commit that references this issue on Oct 16, 2021
  11. Ruzgfpegk commented on Oct 17, 2021

    @Ruzgfpegk

    I had this issue while wanting to do a lossless rip of a game soundtrack on Blu-Ray (96kHz/24b).

    For those who know what they're doing and just want to unlock higher sample rates without any additional GUI settings, you can just add a the missing sample rates in the libhb/common.c file for the relevant version of HandBrake you're using (see the changes).

    For a Windows build, just set up a Ubuntu 20.04 VM with VirtualBox (for a VM dedicated to this task you'll need a minimum of 4GB of memory and 20GB of storage for the process to complete smoothly, for a minimal install of Ubuntu anyway, I'd also recommend 4vCPU) and compile a hb.dll according to the documentation, which alongside the scripts is good enough to make it an "easy" process for a non-developer.

    If you're in this case, after the git clone command and once inside the HandBrake folder you can fetch the version tags using git fetch --all --tags, switch to the version you're using by doing git checkout [tag or branch name] (without the []) and then add the lines locally to the libhb/common.c file before starting the build.
    Then get the hb.dll file from your VM any way you want (Dropbox, network share, passthrough USB key, shared VM folder with the host, SFTP, ...) replace your old hb.dll with it, and you'll have your extended choices at the same place of the interface as before.
    "It just works" for FLAC 24-bit, according to MediaInfo on an encoded file anyway.

  12. w3sip commented on Feb 6, 2023

    @w3sip

    Not sure if it's easy(er), but rather than add higher sample rate options for audio codecs, would it be possible to add a "same as source" one?

  13. bradleysepos commented on Feb 6, 2023

    @bradleysepos
    ContributorAuthor

    Not sure if it's easy(er), but rather than add higher sample rate options for audio codecs, would it be possible to add a "same as source" one?

    That's what "Auto" means in this case. Unfortunately, it's limited to 48 kHz at the moment.

  14. galad87 commented on Apr 11, 2024

    @galad87
    Contributor

    e74b389 introduced some new sample rates, so now FLAC and TrueHD are able to encode at 88.2/96/176.4/192 kHz.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions