Introduction: As you are likely aware, the FDK-AAC encoder was removed from Handbrake (https://www.videohelp.com/software/HandBrake) from version 0.10.5 onwards, as it can no longer be publicly distributed due to GPL licensing issues (see: https://forum.handbrake.fr/viewtopic.php?f=33&t=34143).
The default AAC encoder Libav (https://www.videohelp.com/software/Libav) is lacking in quality compared to FDK (especially at lower bitrates) as its only a basic AAC encoder, however from version 1.2.0 onwards, HandBrake uses the FFmpeg AAC encoder which is better than Libav but still not as good as FDK (see this website for more info about AAC encoders: http://wiki.hydrogenaud.io/index.php?title=AAC_encoders). The Mac version of HandBrake uses Apple’s Core Audio AAC encoder, which is better than FDK but cannot be provided on Windows as its a proprietary library.
Fortunately, you can still compile HandBrake from source and enable FDK as an optional compile-time option, this guide will tell you how this can be done for the Windows version of HandBrake:
Warning: This process is not easy and is only recommended to more advanced users!
Note: This also works with VidCoder since it uses HandBrake as its encoding engine!
1. Fresh install Ubuntu (18.04.3 LTS is recommended due to a known set of packages and is easier for new users who want to attempt this process, later versions and other distros may work as well!), either on a PC via dual booting (or on a separate PC!), or on a Virtual Machine through software such as VirtualBox or VMware (recommended HDD space: 20-25GB with an allocated 2GB or more of RAM).
Ubuntu download: https://www.ubuntu.com/download/desktop
VirtualBox download: https://www.virtualbox.org/wiki/Downloads
See this guide if you need help installing Ubuntu in VirtualBox: https://linus.nci.nih.gov/bdge/installUbuntu.html
Alternatively, if you have the Windows 10 Creators update installed, you can complete this build process using the Windows Subsystem for Linux (WSL), however it is command line only and is only recommended for more advanced users, its also much slower due to the way it handles disk access! (See: https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/)
Obvious note: Don’t forget to press ‘enter’ after typing/pasting each terminal command to execute it!
2. Open a Terminal Window (Ctrl + Alt + T) and maximise it if you want to see all the text go by more clearly, you should start in your "Home" directory, which is: user@computer:~$ (it should already be in the “Home” directory by default).
3. Enter (or copy/paste the following commands into the terminal, WITHOUT quotes):
“sudo apt-get update” (this installs the latest updates in Ubuntu)
“sudo apt-get install automake autoconf autopoint build-essential cmake gcc git intltool libtool libtool-bin m4 make nasm ninja-build patch pkg-config python tar zlib1g-dev”
This will install/upgrade these required packages/dependencies to the latest versions (Some of these will likely already be installed).
“sudo apt-get install meson” (only enter this command if you are running Ubuntu 19.10)
If you are running Ubuntu 18.04 LTS, the meson package is too old, you therefore need to install a newer version provided by the Python Package Index with the following commands:
“sudo apt-get install python3-pip”
“sudo pip3 install meson”
You also need to install these additional dependencies required to build the MinGW-w64 toolchain: “sudo apt-get install bison bzip2 curl flex g++ gzip pax”
Note: You may be asked to enter your administrative password for Ubuntu after these commands, type it in, press enter, then press ‘y‘ and press enter again to confirm.
OPTIONAL: After the above commands, if you see some sort of message about packages no longer being required, enter:
“sudo apt autoremove” to delete them. These are usually old system kernels left over from software updates, and can/should be removed. The Ubuntu desktop uses System Settings->Details (the "gear" icon) to perform much the same function as Windows Update.
If you are running Ubuntu 16.04 LTS, the NASM version in the base repository is too old (2.11.08), so compile from source with the following command instead:
“curl -O https://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2
sudo tar -xf nasm-2.13.02.tar.bz2
cd nasm-2.13.02
sudo ./configure --prefix=/usr/local --enable-sections --enable-lto
sudo make -j$(nproc)
sudo make install
source ~/.bashrc
cd ..”
Then enter “cd” to return back to the "Home" directory.
See: https://handbrake.fr/docs/en/latest/developer/build-windows.html for more info.
4. Enter:
“git clone https://github.com/HandBrake/HandBrake.git && cd HandBrake”
This will download the entire HandBrake source code (repository) and place it in a directory called "HandBrake". Note that this is the NIGHTLY "master" code, not the latest "stable" release.
The Nightly builds are generally quite stable PROVIDED that you avoid cloning it during periods of intensive (i.e. multiple daily) developmental commits. (See: https://github.com/HandBrake/HandBrake/commits/master)
Check out the most recent release in the 1.3 series with the following commands:
“git tag --list”
“git tag --list | grep ^1\.3\.”
“git checkout refs/tags/$(git tag -l | grep -E '^1\.3\.[0-9]+$' | tail -n 1)”
OPTIONAL: If you want an older specific stable release of HandBrake, enter the following commands:
“cd HandBrake”
(this changes the directory to HandBrake)
“git tag”
(this lists the tags)
“git checkout tags/1.2.0”
(or whichever version you want from the list), this will pull that specific version of HandBrake from the repository you just downloaded, then enter “cd” to return back to the “Home” directory.
5. Depending on whether you’re using the 32 or 64-bit version of HandBrake in Windows, enter one of the following commands to build the MinGW-w64 toolchain where “username” is your Ubuntu username, feel free to use a different output path if desired:
32-bit (versions 1.0.7 or earlier only!):
“scripts/mingw-w64-build i686 /home/username/toolchains/”
64-bit:
“scripts/mingw-w64-build x86_64 /home/username/toolchains/”
Remember: all folder/file names are CASE-SENSITIVE! This will take around 40 minutes (possibly much longer depending on your PC setup!) to download the MinGW compiler and build it inside the "toolchains" directory (around 3-4GB).
6. When Step 5 is finished, you'll see a message very much like:
run the following command and add it to your shell startup script
(e.g., .bashrc or .bash_profile) to make persistent across sessions:
export PATH="/home/user/toolchains//x86_64/bin${PATH}"
7. Use your mouse to copy the export PATH= ...etc... (whole line), and paste it into the Terminal. You might have to use the right-mouse context menu to copy/paste. This adds the MinGW compiler into the command search path.
8. Enter (optional):
32-bit (versions 1.0.7 or earlier only!):
“i686-w64-mingw32-gcc -v”
or
64-bit:
“x86_64-w64-mingw32-gcc -v”
to make sure Linux can find the compiler. If you see some "not installed" messages, go back to Step 6 and check carefully. There is no error message for adding a non-existent path string to ${PATH}.
9. Finally, enter:
“cd HandBrake”
(to change to the HandBrake directory), then enter one of the following commands to execute the build process:
32-bit (versions 1.0.7 or earlier only!):
“./configure --cross=i686-w64-mingw32 --enable-x265 --enable-qsv --enable-fdk-aac -- launch-jobs=$(nproc) --launch”
64-bit:
“./configure --cross=x86_64-w64-mingw32 --enable-fdk-aac --enable-qsv --enable-vce --enable-nvenc --launch-jobs=$(nproc) --launch”
10. After around 30 minutes or more (again depends on your PC setup) and mind-boggling walls of text, you should get a SUCCESS message. If you do have persistent problems with the build process, your best chance of success is to use a fresh Ubuntu install, use the File Manager to delete any existing “HandBrake” and “toolchains” directories you might have, only installing the packages from Step 3, and not go fiddling about too much with your Ubuntu setup.
11. Use the File Manager to copy the HandBrake/build/HandBrakeCLI.exe (no longer used by the HandBrake GUI in Windows from version 1.0.x) and HandBrake/build/libhb/hb.dll files to a location that Windows can access (e.g. through a shared folder if on a Virtual Machine).
See this guide for setting up a shared folder between Ubuntu guests and Windows host machines in VirtualBox (requires Guest Additions to be installed first): https://www.howtogeek.com/187703/how-to-access-folders-on-your-host-machine-from-an-ub...in-virtualbox/
12. Copy the file(s) from Step 11 into your HandBrake (or VidCoder) installation directory in Windows, overwriting the old ones. (Make sure that the version you built corresponds to the version you have installed, this also applies to which version of HandBrake that VidCoder is based on as well and whether its 32 or 64-bit!)
Note: You should backup your existing \Program Files\HandBrake directory, and definitely export your presets. There's a good chance a new version may wipe out your user presets.
13. Load up HandBrake or VidCoder in Windows and see if it works (do some test encodes/check the logs!), FDK-AAC should now be available to select as an audio codec in the dropdown list!
Note: The first time running it may result in missing UI elements or options. Exit & restart HandBrake, and all should be good. Sometimes, to fix crashing on startup, you also need to delete the "Users\(you)\AppData\Roaming\HandBrake" directory in your Windows drive, so that HandBrake can create a fresh configuration.
Warning: Doing this counts as a custom build of HandBrake and there is no support for it on their forum if you experience any issues, you are also NOT allowed to distribute custom builds of HandBrake with FDK enabled as its no longer GPL compatible.
Remember: Updating HandBrake (or VidCoder) through the GUI will overwrite the hb.dll file in their respective Windows installation directories, therefore losing FDK, you therefore need to repeat this process if you want to continue using newer versions of HandBrake or VidCoder with FDK-AAC!
Thanks to ‘WhatZit’ and ‘rwatt’ for original posts on the HandBrake forum: https://forum.handbrake.fr/viewtopic.php?f=11&t=34953
Thanks also to ‘CH_JC’ for an online Reddit guide focusing on building HandBrake in WSL: https://www.reddit.com/r/handbrake/comments/bnadr6/guide_how_to_custom_build_handbrake_eg_fdk_aac/
Thanks also to another online guide (originally in Japanese): https://translate.google.co.uk/translate?hl=en&sl=ja&u=https://www.apollomaniacs.com/i...tm&prev=search
I have also made this guide into a Word document and have attached it to this post along with some screenshots!
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 30 of 60
Thread
-
Last edited by AntW93; 24th May 2020 at 13:33. Reason: Updated and tested with HandBrake 1.3.x (Jan 2020)
-
I did not try ... but if it works: Congratulations! This guide looks promising.
Remember: According to the license restrictions, you may build this software from sources for yourself. But do not distribute. Keep it for yourself. Or, at least, don't tell in public if you gave anyone a copy. -
Without wanting to threadjack, does this also offer a way to incorporate e.g. the free Nero AAC encoder? It seems to be decent quality and not particularly slow, with the advantage of seemingly more compatible with fussy hardware players.
(certainly it causes far fewer lockups with a certain mp3 player of mine!)
At the present time if I want to incorporate it into handbrake-encoded video I have to rip the audio and convert it separately in e.g. Foobar then mux it back in as an additional step.
NB I'm not even familiar with FDK so it may well be the exact same thing for all I know.
EDIT: yes I'm aware that this would also be a violation of the GPL conditions (whilst Ahead freely give their codec away, they haven't released the source), and I would like to make the point that I really don't care so long as the damn thing works
Two additional dumb questions:
* Don't you need to restart the computer/VM, or at least close and reopen the terminal, after adding the path setting to the startup script, given that it's, well, a startup script? I expect there's some way to reconfigure it "live" much like there is in MS-DOS, but that doesn't seem to appear here.
* Is there no way to get hold of the source and a Windows compiler and just compile it straight up on the target platform, if you want the Windows rather than Linux version? Last time I tried to install Ubuntu in a VM in order to use a stubbornly Linux-only application, it gave me botulism and ran over my cat. Which was especially galling given that I didn't even HAVE a cat until then. (That effort actually failed, fwiw) ... I can't imagine that there aren't any options for compiling (presumably) C++ under the Windows environment, or for downloading the Handbrake source.Last edited by EddyH; 4th May 2017 at 04:44.
-= She sez there's ants in the carpet, dirty little monsters! =-
Back after a long time away, mainly because I now need to start making up vidcapped DVDRs for work and I haven't a clue where to start any more! -
No. NeroAacEnc is a separate application; Handbrake won't use this kind of additional encoders, it can only use libraries included in the ffmpeg core of itself.
-
No, this build guide is only for enabling the FDK-AAC encoder within HandBrake, the Nero AAC encoder is commercial and therefore not GPL compatible, and so has not/will not be included with HandBrake, and so there is no way to build HandBrake with the Nero AAC encoder inside it, the same issues also apply to the QAAC encoder!
See: https://forum.handbrake.fr/viewtopic.php?f=26&t=36195&p=170274
No, you don't need to restart the computer/VM, otherwise I would have mentioned that in the guide!
As far as I know, HandBrake for Windows can only be cross-compiled, not natively compiled, it even says in its online documentation that building HandBrake for Windows requires Linux and a recent MinGW-w64 toolchain, see: https://handbrake.fr/docs/en/1.0.0/developer/build-windows.html
I would love to be proved wrong though and shown that HandBrake can be compiled under the Windows environment, but I don't think it can, unfortunately!Last edited by AntW93; 4th May 2017 at 13:27.
-
This article would be useful before last year, but FFmpeg's internal AAC encoder has been much improved since last year, at least at 128kbps.
Listening test report last year (Japanese):
http://d.hatena.ne.jp/kamedo2/20160215/1455552816
I guess this is the reason for HB dropping fdk encoder
(the license issue has been there a long time)
For the compiling part, i have not tried that myself, but the Linux Subsystem on Win10(after Creator Update) may do the job, sparing the trouble to setup a VM. After all, FFmpeg can be cross-compiled in the Linux SubsystemStopping development until someone save me from poverty or get me out of Hong Kong...
Twitter @MaverickTse -
I know that significant improvements have been made to FFmpeg's internal AAC encoder, but these improvements have not yet been merged into LibAV which HandBrake uses, and we don't know if they even will, see: http://wiki.hydrogenaud.io/index.php?title=AAC_encoders and https://forum.handbrake.fr/viewtopic.php?f=26&t=34793
I therefore recommend using the FDK-AAC encoder in HandBrake for the time being, if you are able to compile it from source!
Interesting, I shall look into using the Linux Subsystem on Win10 for compiling HandBrake to save having to use a VM! -
Apologies for the slight necroposting. I was able to successfully build on WSL following your instructions.
However in step 3 I had to add the g++ package in, the MinGW build required it, and later I had to add packages specified in these walkthroughs:
https://mattgadient.com/2016/06/20/working-around-hiccups-when-compiling-handbrake-on-linux/
https://handbrake.fr/docs/en/latest/developer/build-windows.html
Since WSL is command line only (for the time being), the kosher way to copy the built files is to specify the destination path simply as
cp hb.dll /mnt/c/{path} (Replace c with *NTFS* drive letter of your choice).
Accessing the files directly through the Windows Explorer will corrupt the WSL filesystem.
Other caveats: archive extraction and build is SLOW on WSL. WSL uses a "worst of both worlds" approach to disk access (and the linux store is hosted on my SSD). My computer was more than likely also a bottleneck, so whichever was the bigger factor, Step 5 took me almost 2 hours.
After building, I did a few test converts and was satisfied with the results. TBH I don't find libav to sound much different from FDK, but I can appreciate a better compression algorithm. -
-
-
Try
Code:export PATH="/usr/bin:$PATH"
Code:rm -r /home/user/toolchains
Also, anybody know what to do if you encounterCode:ERROR: fdk-aac not found.
-
Thank you Tom!! So the variable WAS messing up the sequence! I had to run
Code:sudo apt install gcc-mingw-w64-x86-64
I have not updated Python or messed with it - what version is it looking for?
Thank you again! And I hope you are able to get WSL working! -
It looks like you didn't press 'enter' to execute the required command from Step 5 (HandBrake/scripts/mingw-w64-build x86_64), after typing/pasting it in, it can take a while to download and build MinGW (2-3GB!) depending on your PC setup, it should come up with walls of text detailing the download/extraction process!
-
-
-
Thank you for all this info!
I have a quick question - after I've done all the above steps, I have the exe for the CLI after compiling.
How did u get the GUI working? I used ver 1.0.7 -
Copy and paste the hb.dll file from the HandBrake/build/libhb folder in Ubuntu (its in amongst a lot of other files within this folder once you've completed the build process!) into HandBrake's installation folder in Windows, overwriting the old/previous hb.dll file!
Then load up the GUI and see if it works! -
OMG! Thank you so much AntW93
That did the trick. In my desperation I did a couple of encodes via the CLI and it was so tedious. hehehe
-
Thanks alot for this great step by step guidance to handbrake with FDK aac - works like a charm (nightly build 20171107)
I am so happy with it... took me some time to get things straight (was a bit tricky to copy the hb.dll from Ubuntu into Windows since Guest Additions for Ubuntu seem to be buggy atm.), but was worth it - perfect solution now!
Last edited by NeoRider; 10th Nov 2017 at 12:25.
-
Hello,
I stumbled upon this thread looking to acquire FDK AAC in handbrake. I'm very new to Linux and Ubuntu and I'm not sure what I was doing. I first started off installing Ubuntu 16.04.3 LTS on a boot drive, and logged in as guest. I entered the command
"sudo apt-get install cmake curl gcc git intltool libtool m4 bison flex pax make patch python tar wget yasm automake "
and it said it was unable to locate yasm. I then tried to figure out how to install yasm manually, and I've went and downloaded the source files off of the site and tried to compile, build and install yasm. However for the life of me, I wasn't able to get yasm to install through the method.
Is there any way I can get yasm to install without compiling it? Ubuntu for some reason is not able to find yasm and install it.
Sorry, for my newbish questions. -
I'm not sure, you should try logging in as an administrator/primary user (with a password) and see if that works with the above command, or try fresh installing Ubuntu in a Virtual Machine in VirtualBox instead and try again!
yasm is one of the essential packages for compiling/building Handbrake and will not function without it! -
I don’t know where to begin. After spending an entire day trying to figure it out, I’ve succesfully got AAC FDK in Handbrake! I did a full reinstall on a SSD (instead of a USB) and turned down any overclocks I’ve had as it was unstable when using Ubuntu (constant freeze, lockups...etc). Everything worked flawlessly as the guide was written. Thank you so much for the guide and apologies for my question.
-
-
Thanks AntW93, Just got to find time now to compile the hb.dll file, wish me luck !
-
Guide is not working for me. I got an error "nasm missing" after executing the ./configure --cross=x86_64-w64-mingw32 --enable-x265 --enable-qsv --enable-fdk-aac --enable-libav-aac --launch-jobs=1 --force --launch command.
I'm a complete linux noob so i don't know what to do. I reinstalled ubuntu 3 times, but I get the same error message every time. I'm using vmware workstation player.
[Attachment 44372 - Click to enlarge] -
Previously, YASM was a good enough assembler to compile modern video encoders like x265; but now, since x265 also wants to support AVX512 instructions, the NASM assembler is required.
Reinstalling an operating system is not sufficient if it doesn't install all the required packages immediately. You will have to add the NASM assembler by installing its package. Did you notice paragraph 3. in the guide above? There is nasm missing now, since this was posted. Try to run this in addition:
Code:sudo apt-get install nasm
-
-
A pity your system was unable to detect the version correctly.
You may now need to discover if there are any similar related packages (you could e.g. install "Synaptic" and search for any "nasm" related packages with a newer version), or read about how to compile nasm from its sources.
But both attempts may be a challenge for a "complete Linux noob"...
Similar Threads
-
Handbrake without FDK-AAC, new FFMPEG AAC encoder viable alternative?
By jaggy in forum Video ConversionReplies: 15Last Post: 27th Apr 2017, 10:31 -
Ac3 to fdk-aac
By Mildragon in forum AudioReplies: 8Last Post: 4th Jan 2016, 13:06 -
[AAC] AAC (avcodec), AAC (FDK) or HE-AAC (FDK)
By yopmail in forum AudioReplies: 10Last Post: 3rd Feb 2015, 21:17 -
Whats the difference between AAC (avcodec) and AAC Passthru in Handbrake?
By Nazomon in forum Newbie / General discussionsReplies: 1Last Post: 13th Dec 2014, 16:49 -
Handbrake - AC3 5.0 Ch - Can't maintain 5.0 Ch to AAC or AC3(ffmpeg)
By kingaddi in forum DVD RippingReplies: 30Last Post: 26th Aug 2012, 19:27