Often our servers, with their immense CPU horsepower, sit idle. Like an army without a war, they languish in want of action. When the Roman legions weren't expanding the Empire, they were far from idle; they continued to work to improve the logistics of the Roman Empire by building a road system that spanned from Britain to Jerusalem. What if we could do the same with the idle cores of our AMD Epyc Rome processors?

Enter HandBrake. HandBrake is a utility that can be used to compress video files by encoding/compressing them to a more optimal format (i.e. x265/HEVC). By implementing HandBrake into our servers' workflows, using tools such as Tdarr and HBBatchBeast, we not only conserve storage, but we can also save our precious bandwidth since those files are smaller when we stream them through Plex. That 15+ minutes saved when you're trying to sync from Plex before your board your plane at the airport can make all the difference. In this tutorial, I will show you how to install HandBrake and resolve the various errors you're likely to come across if you're using a newer Ubuntu distro. Perhaps even more importantly, I will show you how to troubleshoot and resolve broken dependencies, as I have done before, and update your repository to a previous Ubuntu distribution.

At the time of this post, the HandBrake repositories are broken on newer versions of Ubuntu (Disco Dingo 19.04 and Eoan Ermine 19.10). If you follow the standard directions for installing HandBrake, you'll likely be met with the following errors:

The following packages have unmet depedencies:
	handbrake-cli : Depends: libx264-152 but it is not installable
    handbrake-gtk : Depends: libx264-152 but it is not installable
E: Unable to correct problems, you have held broken packages
libx264-152 dependency missing from Disco Dingo and later
E: Unable to locate package handbrake-gtk
handbrake-gtk missing from HandBrake PPA repository

The latter is because handbrake-gtk is missing from the HandBrake PPA repository. We'll start here, but before we do so, I'll assume you've completed the following steps:

Normal Installation Method for Installing HandBrake on Ubuntu:

1. Add the HandBrake repository (PPA):

sudo add-apt-repository ppa:stebbins/handbrake-releases

2. Update your repository list:

sudo apt-get update

3. Install the HandBrake Command Line (handbrake-cli) and GUI (handbrake-gtk):

sudo apt-get install handbrake-cli handbrake-gtk

Update Repository List to a Working Distribution:

Now, ideally this should be all you have to do to install HandBrake, but as I said before, currently the PPA is broken for newer Ubuntu versions and until this is fixed, you'll likely see the following error:

E: Unable to locate package handbrake-gtk

To fix this, we simply need to update the PPA to a distribution that we know has handbrake-gtk. I am going to use the latest LTS version, Bionic Beaver ("bionic").

4. Launch "Software & Updates" and then navigate to the "Other Software" tab.

In case you forgot, this is what the "Software & Updates" app looks like.

5. Find the HandBrake PPA and click "Edit":

HandBrake PPA in "Other Software"

6. Update the PPA's distribution to bionic:

Update PPA repository's distribution

7. After that you'll be prompted to update/refresh your repository list. If not, run it manually afterward:

sudo apt-get update

8. And attempt to install HandBrake again:

sudo apt-get install handbrake-cli handbrake-gtk

Install the Missing Dependencies:

At this point, handbrake-gtk should at least be found and attempt installation, but you'll receive the following message:

The following packages have unmet depedencies:
	handbrake-cli : Depends: libx264-152 but it is not installable
    handbrake-gtk : Depends: libx264-152 but it is not installable
E: Unable to correct problems, you have held broken packages

It appears that our newest versions of Ubuntu are missing libx264-152 and don't have the dependency available to them for our package manager to handle automatically. We'll need to install the dependency manually. So opening up a Google search for "libx264-152 ubuntu", we find the following page:

Site: https://packages.ubuntu.com/search?keywords=libx264-152

I'm going to go with the cosmic distribution simply because it's the latest one and therefore closest to ours. Clicking that link brings us to the download page. Select the download appropriate for your architecture (which is almost assuredly amd64 for the vast majority of modern CPUs):

Source: https://packages.ubuntu.com/cosmic/libx264-152

9. Install the libx264-152 package:

From there, you'll be brought to a mirror page. Select a mirror to start your download. (Or just click here to download libx264-152). A .deb file will download. Simply double click it to launch it and install.

10. Now that we've finally resolved all of our error messages for missing packages and dependencies, we can finally install HandBrake with the following command:

sudo apt-get install handbrake-cli handbrake-gtk