VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker or buy a VSO converter software :)
+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. Introduction: As many of you may know, the FDK-AAC encoder was removed from HandBrake (from version 0.10.5 onwards) due to GPL licensing issues (see: https://forum.handbrake.fr/viewtopic.php?f=33&t=34143), the default AAC encoder (LibAV) is lacking in quality compared to FDK as its only a basic AAC encoder, 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:

    1. Fresh install Ubuntu (16.0.4 LTS is recommended), either on a PC via dual booting (or on its own!) or on a virtual machine through software such as VirtualBox or VMware (recommended HDD space: 15-20GB).

    Ubuntu download: https://www.ubuntu.com/download/desktop
    VirtualBox download: https://www.virtualbox.org/wiki/Downloads

    Note: The 16.10 version of Ubuntu causes issues with the build process of HandBrake which have not been resolved as far as I know (there are obviously proper workarounds!).

    Update (26/04/17): I believe these build issues which were related to hardened GCC (GNU Compiler Collection) in Ubuntu 16.10 have now been resolved as the changelog for HandBrake version 1.0.7 included the following:

    Build system
    - Updated MinGW-w64 build script for improved compatibility with hardened GCC.

    It should therefore be safe to use Ubuntu 16.10 or higher to build HandBrake, but I have yet to test this for myself!


    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).

    Note: This goes without saying really, but don't forget to press 'enter' after typing or pasting in each terminal command to execute it!

    3. Enter (or copy/paste the following commands into the terminal): sudo apt-get install cmake curl gcc git intltool libtool m4 bison flex pax make patch python tar wget yasm

    This will install/upgrade these required dependencies to the latest versions.

    Note: You will be asked to enter your administrative password for Ubuntu after this command, type it in, press enter, then press ‘y‘ and press enter again to confirm.

    OPTIONAL: After the above command, 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.

    4. Enter: git clone https://github.com/HandBrake/HandBrake.git This will download HandBrake from the 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.

    OPTIONAL: If you want a specific stable release of HandBrake, enter the following commands, after the above command: cd HandBrake (this changes the directory to HandBrake), git tag (this lists the tags), git checkout tags/1.0.3 (or whichever version you want from the list), this will pull that specific version of HandBrake from the repository you just downloaded.

    5. If you went for a specific version of HandBrake, enter cd (or close and re-open the terminal window) to return to the “Home” directory, then enter: HandBrake/scripts/mingw-w64-build x86_64

    Remember: all folder/file names are CASE-SENSITIVE! This will take around 10-20 minutes to download MinGW and build it inside the "toolchains" directory (around 2-3GB).

    6. When Step 5 is finished, you'll see a message very much like:
    add to your shell startup script (usually .bashrc or .bash_profile):
    export PATH="/home/user/toolchains/mingw-w64-5.0-0-gcc-5.4.0/mingw-w64-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: 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 the following command to execute the build process:
    ./configure --cross=x86_64-w64-mingw32 --enable-x265 --enable-qsv --enable-fdk-aac --launch-jobs=1 --force –launch

    10. After around 10-20 minutes (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 newer versions of the HandBrake GUI in Windows) 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, you can then shut down the Virtual Machine as its no longer required!).

    See this excellent guide for setting up a shared folder in VirtualBox between Ubuntu guests and Windows host machines: 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 installation directory in Windows, overwriting the old ones. (Make sure that the version you built corresponds to the version you have installed, if you want a specific stable release!)

    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 in Windows and see if it works (do some test encodes!), 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.


    Thanks to ‘WhatZit’ and ‘rwatt’ for original posts on the HandBrake forum: https://forum.handbrake.fr/viewtopic.php?f=11&t=34953&sid=c6ac32dc3242cc17e283d83a5c5e18b0

    I have also made this guide into a Word document and attached it to this post (along with 2 screenshots) for your convenience!

    Note: 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.


    If any of you attempt this, let me know how you get on in this thread, and if you have any questions about this guide/build process, please let me know in this thread or send me a PM and I will do my best to answer them!
    Image Attached Thumbnails Click image for larger version

Name:	HandBrake-VBox Build.png
Views:	131
Size:	1.28 MB
ID:	41215  

    Click image for larger version

Name:	HandBrake-Windows GUI (FDK).png
Views:	211
Size:	1.08 MB
ID:	41216  

    Image Attached Files
    Last edited by AntW93; 28th Apr 2017 at 09:52. Reason: Added some extra info
    Quote Quote  
  2. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    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.
    Quote Quote  
  3. Far too goddamn old now EddyH's Avatar
    Join Date
    Jan 2003
    Location
    Soul sucking suburbia! But a different part since I last logged on.
    Search Comp PM
    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!
    Quote Quote  
  4. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Originally Posted by EddyH View Post
    Without wanting to threadjack, does this also offer a way to incorporate e.g. the free Nero AAC encoder?
    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.
    Quote Quote  
  5. Originally Posted by EddyH View Post
    Without wanting to threadjack, does this also offer a way to incorporate e.g. the free Nero AAC encoder?
    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


    Originally Posted by EddyH View Post
    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.
    No, you don't need to restart the computer/VM, otherwise I would have mentioned that in the guide!

    Originally Posted by EddyH View Post
    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? I can't imagine that there aren't any options for compiling (presumably) C++ under the Windows environment, or for downloading the Handbrake source.
    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.
    Quote Quote  
  6. 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 Subsystem
    Stopping development until someone save me from poverty or get me out of Hong Kong...
    Twitter @MaverickTse
    Quote Quote  
  7. Originally Posted by MaverickTse View Post
    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.

    I guess this is the reason for HB dropping fdk encoder
    (the license issue has been there a long time)
    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!

    Originally Posted by MaverickTse View Post
    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 Subsystem
    Interesting, I shall look into using the Linux Subsystem on Win10 for compiling HandBrake to save having to use a VM!
    Quote Quote  
  8. Member
    Join Date
    Aug 2017
    Location
    Canada
    Search Comp PM
    Originally Posted by AntW93 View Post
    Originally Posted by MaverickTse View Post
    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 Subsystem
    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.
    Quote Quote  



Similar Threads