Handbrake moves to FFmpeg: improve AAC audio quality?

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
jacop89
Novice
Posts: 64
Joined: Sat Dec 01, 2012 9:11 am

Handbrake moves to FFmpeg: improve AAC audio quality?

Post by jacop89 »

Description of problem or question:
Bad AAC audio quality in Handbrake.
Now the program move from LibaV to FFmpeg; any plan to improve AAC audio quality encoding?



Steps to reproduce the problem (If Applicable):

Convert any video with AAC (avcodec) in Handbrake Windows GUI


HandBrake version (e.g., 1.0.0):

HandBrake Nightly 20180616150159-1dac209-master (2018061701)

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):

Windows 10 64bit Redstone 4


HandBrake Activity Log ***required*** (see How-to get an activity log)

Code: Select all

HandBrake Nightly 20180616150159-1dac209-master (2018061701)
OS: Microsoft Windows NT 10.0.17134.0
CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Ram: 16342 MB, 
GPU Information:
  NVIDIA GeForce GTX 1070 - 24.21.13.9811
Screen: 1920x1080
Temp Dir: C:\Users\User\AppData\Local\Temp\
Install Dir: C:\Program Files\HandBrake Nightly
Data Dir: C:\Users\User\AppData\Roaming\HandBrake Team\HandBrake\1.2.0.0

-------------------------------------------


# Starting Encode ...

[14:56:21] hb_init: starting libhb thread
[14:56:21] 1 job(s) to process
[14:56:21] json job:
{
  "Audio": {
    "AudioList": [
      {
        "Bitrate": 128,
        "DRC": 0.0,
        "Encoder": 65536,
        "Gain": 0.0,
        "Mixdown": 4,
        "NormalizeMixLevel": false,
        "Samplerate": 48000,
        "Track": 0,
        "DitherMethod": 0
      }
    ],
    "CopyMask": [
      1073807360,
      1073743872,
      1074003968,
      1073750016,
      1090519040,
      1074790400,
      1074266112,
      1107296256
    ],
    "FallbackEncoder": 2048
  },
  "Destination": {
    "ChapterList": [],
    "ChapterMarkers": false,
    "AlignAVStart": true,
    "File": "D:\\Video\\Handbrake\\Esrb Cyberpunk 2077 Teaser Trailer-1.mp4",
    "Mp4Options": {
      "IpodAtom": false,
      "Mp4Optimize": true
    },
    "Mux": 131072
  },
  "Filters": {
    "FilterList": [
      {
        "ID": 11,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "800",
          "width": "1920"
        }
      },
      {
        "ID": 6,
        "Settings": {
          "mode": "1"
        }
      }
    ]
  },
  "PAR": {
    "Num": 1,
    "Den": 1
  },
  "Metadata": {},
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "chapter",
      "Start": 1,
      "End": 1
    },
    "Title": 1,
    "Path": "D:\\Video\\Cyberpunk2077\\Videos\\Cyberpunk 2077 Teaser Trailer\\ESRB_Cyberpunk 2077 Teaser Trailer.mp4"
  },
  "Subtitle": {
    "Search": {
      "Burn": false,
      "Default": false,
      "Enable": false,
      "Forced": false
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": 65536,
    "TwoPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "ref=4:bframes=4:b-adapt=2:direct=auto:me=umh:subme=9:merange=24:analyse=all:trellis=2:psy-rd=1.0,0.15:deblock=-1,-1",
    "Quality": 22.0,
    "HWDecode": false,
    "QSV": {
      "Decode": false,
      "AsyncDepth": 0
    }
  }
}
[14:56:21] CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
[14:56:21]  - Intel microarchitecture Kaby Lake
[14:56:21]  - logical processor count: 8
[14:56:21] Intel Quick Sync Video support: no
[14:56:21] hb_scan: path=D:\Video\Cyberpunk2077\Videos\Cyberpunk 2077 Teaser Trailer\ESRB_Cyberpunk 2077 Teaser Trailer.mp4, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:323: failed opening UDF image D:\Video\Cyberpunk2077\Videos\Cyberpunk 2077 Teaser Trailer\ESRB_Cyberpunk 2077 Teaser Trailer.mp4
src/libbluray/disc/disc.c:424: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:424: error opening file BDMV\BACKUP\index.bdmv
[14:56:21] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.3
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[14:56:21] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\Video\Cyberpunk2077\Videos\Cyberpunk 2077 Teaser Trailer\ESRB_Cyberpunk 2077 Teaser Trailer.mp4':
  Metadata:
    major_brand     : M4V
    minor_version   : 1
    compatible_brands: M4V mp42isom
    creation_time   : 2013-01-08T12:23:12.000000Z
  Duration: 00:02:20.25, start: 0.000000, bitrate: 8160 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv), 1920x800 [SAR 1:1 DAR 12:5], 8001 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2013-01-08T12:23:12.000000Z
      handler_name    : Mainconcept MP4 Video Media Handler
      encoder         : AVC Coding
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 157 kb/s (default)
    Metadata:
      creation_time   : 2013-01-08T12:23:12.000000Z
      handler_name    : Mainconcept MP4 Sound Media Handler
[14:56:21] scan: decoding previews for title 1
[14:56:21] scan: audio 0x1: aac, rate=48000Hz, bitrate=157391 English (AAC LC) (2.0 ch)
[14:56:21] scan: 10 previews, 1920x800, 25.000 fps, autocrop = 0/0/0/0, aspect 2.40:1, PAR 1:1
[14:56:21] scan: supported video decoders: avcodec qsv
[14:56:22] libhb: scan thread found 1 valid title(s)
[14:56:22] starting job
[14:56:22] work: track 1, dithering not supported by codec
[14:56:22] job configuration:
[14:56:22]  * source
[14:56:22]    + D:\Video\Cyberpunk2077\Videos\Cyberpunk 2077 Teaser Trailer\ESRB_Cyberpunk 2077 Teaser Trailer.mp4
[14:56:22]    + title 1, chapter(s) 1 to 1
[14:56:22]    + container: mov,mp4,m4a,3gp,3g2,mj2
[14:56:22]    + data rate: 8160 kbps
[14:56:22]  * destination
[14:56:22]    + D:\Video\Handbrake\Esrb Cyberpunk 2077 Teaser Trailer-1.mp4
[14:56:22]    + container: MPEG-4 (libavformat)
[14:56:22]      + optimized for HTTP streaming (fast start)
[14:56:22]      + align initial A/V stream timestamps
[14:56:22]  * video track
[14:56:22]    + decoder: h264
[14:56:22]      + bitrate 8001 kbps
[14:56:22]    + filters
[14:56:22]      + Framerate Shaper (mode=1)
[14:56:22]        + frame rate: 25.000 fps -> constant 25.000 fps
[14:56:22]      + Crop and Scale (width=1920:height=800:crop-top=0:crop-bottom=0:crop-left=0:crop-right=0)
[14:56:22]        + source: 1920 * 800, crop (0/0/0/0): 1920 * 800, scale: 1920 * 800
[14:56:22]    + Output geometry
[14:56:22]      + storage dimensions: 1920 x 800
[14:56:22]      + pixel aspect ratio: 1 : 1
[14:56:22]      + display dimensions: 1920 x 800
[14:56:22]    + encoder: H.264 (libx264)
[14:56:22]      + options: ref=4:bframes=4:b-adapt=2:direct=auto:me=umh:subme=9:merange=24:analyse=all:trellis=2:psy-rd=1.0,0.15:deblock=-1,-1
[14:56:22]      + quality: 22.00 (RF)
[14:56:22]  * audio track 1
[14:56:22]    + decoder: English (AAC LC) (2.0 ch) (track 1, id 0x1)
[14:56:22]      + bitrate: 157 kbps, samplerate: 48000 Hz
[14:56:22]    + mixdown: Stereo
[14:56:22]    + encoder: AAC (libavcodec)
[14:56:22]      + bitrate: 128 kbps, samplerate: 48000 Hz
[14:56:22] sync: expecting 3506 video frames
[14:56:22] encavcodecaInit: Unknown avcodec option stereo_mode
[14:56:22] encx264: encoding at constant RF 22.000000
[14:56:22] encx264: unparsed options: ref=4:bframes=4:b-adapt=2:direct=auto:me=umh:subme=9:merange=24:analyse=all:trellis=2:psy-rd=1,0.15:deblock=-1,-1
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 4.0
[14:56:22] sync: first pts video is 0
[14:56:22] sync: Chapter 1 at frame 1 time 0
[14:56:22] sync: first pts audio 0x1 is 0
[14:58:48] reader: done. 1 scr changes
[14:58:50] work: average encoding speed for job is 23.430313 fps
[14:58:50] vfr: 3505 frames output, 0 dropped and 0 duped for CFR/PFR
[14:58:50] vfr: lost time: 0 (0 frames)
[14:58:50] vfr: gained time: 0 (0 frames) (0 not accounted for)
[14:58:50] aac-decoder done: 6572 frames, 0 decoder errors
[14:58:50] h264-decoder done: 3505 frames, 0 decoder errors
[14:58:50] sync: got 3505 frames, 3506 expected
[14:58:50] sync: framerate min 25.000 fps, max 25.000 fps, avg 25.000 fps
x264 [info]: frame I:42    Avg QP:16.68  size: 84701
x264 [info]: frame P:1009  Avg QP:20.37  size: 28138
x264 [info]: frame B:2454  Avg QP:22.64  size:  7414
x264 [info]: consecutive B-frames:  5.7%  3.5% 20.0% 33.7% 37.1%
x264 [info]: mb I  I16..4: 37.9% 36.6% 25.5%
x264 [info]: mb P  I16..4: 13.8% 13.2%  2.0%  P16..4: 33.8%  6.8%  4.6%  0.2%  0.1%    skip:25.7%
x264 [info]: mb B  I16..4:  1.6%  1.5%  0.2%  B16..8: 35.0%  3.0%  0.5%  direct: 2.3%  skip:55.9%  L0:52.3% L1:41.7% BI: 6.0%
x264 [info]: 8x8 transform intra:44.5% inter:59.7%
x264 [info]: direct mvs  spatial:99.5% temporal:0.5%
x264 [info]: coded y,uvDC,uvAC intra: 29.7% 44.2% 13.6% inter: 7.8% 13.7% 1.3%
x264 [info]: i16 v,h,dc,p: 18% 47% 12% 23%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 18% 31%  4%  5%  5%  6%  5%  6%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 31% 13%  5%  7%  7%  7%  5%  8%
x264 [info]: i8c dc,h,v,p: 42% 34% 15%  9%
x264 [info]: Weighted P-Frames: Y:8.6% UV:5.2%
x264 [info]: ref P L0: 68.0% 11.8% 15.6%  4.2%  0.4%  0.0%
x264 [info]: ref B L0: 91.6%  7.4%  1.0%
x264 [info]: ref B L1: 97.6%  2.4%
x264 [info]: kb/s:2861.20
[14:58:50] mux: track 0, 3505 frames, 50140907 bytes, 2860.29 kbps, fifo 2048
[14:58:50] mux: track 1, 6573 frames, 2192269 bytes, 125.06 kbps, fifo 4096
[14:58:50] libhb: work result = 0

# Encode Completed ...


User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by s55 »

The ffmpeg AAC encoder does do a better job than that of libav. It's not perfect and still has quirks though. For the most part it's fine to use.

Given your source above, I'd be inclined to just use AAC passthru rather than re-encoding.

I Don't know if anyone is contributing improvements to the ffmpeg aac encoder. If they release improvements, HandBrake will pick them up with time.
jacop89
Novice
Posts: 64
Joined: Sat Dec 01, 2012 9:11 am

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by jacop89 »

The latest Nightly build witch FFmpeg version use? the latest stable 4.0 version?
FFmpeg AAC Encodec is still better then LibaV? Oh finally!

Last question:
there is no way to bring FDK AAC encoder again in the future?
Any possibility to add it into Windows GUI?

Thanks a lot, s55!
rollin_eng
Veteran User
Posts: 4840
Joined: Wed May 04, 2011 11:06 pm

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by rollin_eng »

User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by s55 »

FDK coming back to a HandBrake release is not an option that's on the table.

Yes, we use ffmpeg 4. in the nightlies.
jacop89
Novice
Posts: 64
Joined: Sat Dec 01, 2012 9:11 am

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by jacop89 »

s55 wrote: Sun Jun 17, 2018 5:38 pm FDK coming back to a HandBrake release is not an option that's on the table.

Yes, we use ffmpeg 4. in the nightlies.
Ok perfect thanks again!
So I hope the FDK AAC encoder can come back in the future (not only for the quality, but also for the possibility of having real VBR Quality, HE-AAC encoding, and multi-channel)!
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by mduell »

Ignore the politics and compile yourself for FDK-AAC.
jacop89
Novice
Posts: 64
Joined: Sat Dec 01, 2012 9:11 am

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by jacop89 »

mduell wrote: Mon Jun 18, 2018 4:11 pm Ignore the politics and compile yourself for FDK-AAC.

I'm not a programmer, and I do not think it's an easy task add FDK AAC to Windows GUI!
User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by s55 »

Doesn't require any programming. Just need to compile libhb (hb.dll)

The code to support it exists in the code base. We just can't legally distribute it in binary form. So, if you want it, you basically have to compile what would be classes as a "nonfree" (as in, not GPL compatible) build yourself.

It's not terribly difficult but if it's not something your comfortable with, then you've got to ask yourself whether it's worth the hassle setting up an environment to build it. ffmpeg aac is probably going to be fine in most scenarios.
https://handbrake.fr/docs/en/1.1.0/deve ... ndows.html
andrewk89
Novice
Posts: 65
Joined: Thu Jun 13, 2013 4:29 pm

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by andrewk89 »

jacop89 wrote: Tue Jun 19, 2018 1:28 pm
mduell wrote: Mon Jun 18, 2018 4:11 pm Ignore the politics and compile yourself for FDK-AAC.

I'm not a programmer, and I do not think it's an easy task add FDK AAC to Windows GUI!
Following the compiling instructions is trivial. You can literally copy / paste the commands from the narrative. Read carefully to make sure you're copying the right commands and it will work out.

Using Linux is non-trivial. It's a mind-#$%^ if you've never seen it. Depending on how you do it, you may need anywhere between basic command line skills (not necessarily Linux) to Linux-proficiency.

I've used VirtualBox on-and-off for maybe 15 years. Not a heavy user. Just curious about the different flavors of Linux. With Ubuntu inside VirtualBox, installing the Guest Additions for folder sharing between Ubuntu and Windows seems like it has gotten harder. Supposedly Ubuntu 18.04 (?) has the Guest Additions baked in, but I haven't tried. Setting up the folders for file sharing between the guest and host is harder. Pushing the compiled .dll from the guest to Windows was less hard, but not easy.

In Windows 10, I also tried the Windows Subsystem for Linux ("Ubuntu" in the Windows app store). So much easier than VirtualBox. Really don't need to know any Linux. Only trick is how to file the compiled .dll with Windows Explorer. Google is your friend.

Above is based on compiling FDK-AAC for version 1.0.0 in VirtualBox, and 1.1.0 and 1.1.1 in Windows Subsystem for Linux.
jacop89
Novice
Posts: 64
Joined: Sat Dec 01, 2012 9:11 am

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by jacop89 »

andrewk89 wrote: Fri Jun 22, 2018 11:27 pm
jacop89 wrote: Tue Jun 19, 2018 1:28 pm
mduell wrote: Mon Jun 18, 2018 4:11 pm Ignore the politics and compile yourself for FDK-AAC.

I'm not a programmer, and I do not think it's an easy task add FDK AAC to Windows GUI!
Following the compiling instructions is trivial. You can literally copy / paste the commands from the narrative. Read carefully to make sure you're copying the right commands and it will work out.

Using Linux is non-trivial. It's a mind-#$%^ if you've never seen it. Depending on how you do it, you may need anywhere between basic command line skills (not necessarily Linux) to Linux-proficiency.

I've used VirtualBox on-and-off for maybe 15 years. Not a heavy user. Just curious about the different flavors of Linux. With Ubuntu inside VirtualBox, installing the Guest Additions for folder sharing between Ubuntu and Windows seems like it has gotten harder. Supposedly Ubuntu 18.04 (?) has the Guest Additions baked in, but I haven't tried. Setting up the folders for file sharing between the guest and host is harder. Pushing the compiled .dll from the guest to Windows was less hard, but not easy.

In Windows 10, I also tried the Windows Subsystem for Linux ("Ubuntu" in the Windows app store). So much easier than VirtualBox. Really don't need to know any Linux. Only trick is how to file the compiled .dll with Windows Explorer. Google is your friend.

Above is based on compiling FDK-AAC for version 1.0.0 in VirtualBox, and 1.1.0 and 1.1.1 in Windows Subsystem for Linux.

Ok thanks... where can I find a guide for this operation?

For Dev Team... it's possible to create a simple method for simply add FDK AAC Encoder to Windows GUI version by users??
Deleted User 11865

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by Deleted User 11865 »

No, because you simply can't legally distribute a build of HandBrake with the functionality enabled. That's why it has to be done on your end.
andrewk89
Novice
Posts: 65
Joined: Thu Jun 13, 2013 4:29 pm

Re: Handbrake moves to FFmpeg: improve AAC audio quality?

Post by andrewk89 »

jacop89 wrote: Mon Jul 02, 2018 11:00 am Ok thanks... where can I find a guide for this operation?
viewtopic.php?f=11&t=34953#p163970
Post Reply