Log in

View Full Version : Encoding witth QAAC like CT AAC


LeMoi
12th December 2016, 17:55
Hello there,
I've been using Coding Technologies AAC from a long time, with WinAmp old dll, using BeLight and BeSweet. The parameters I used the most often are HE-AAC 2.0 64 kbps and LC-AAC 5.1 192 or 256 kbps, sometimes HE-AAC v2 with Parametric Stereo 32 kbps.
http://nsa38.casimages.com/img/2016/12/12//161212060829859621.jpg
http://nsa38.casimages.com/img/2016/12/12//16121206083031202.jpg
I'm very satisfied with the result since i'm just looking for medium quality audio for 700 MB movie rips.
I recently discovered QAAC, and the fact that it can be directly encoded through MeGui, without using BeSweet.
So my question is really simple, what parameters should I use in MeGui to have the same (or better ?!) results at the same bitrate using the QAAC encoder and MeGUI?

Thanks for your help!

tebasuna51
12th December 2016, 21:56
You can use eac3to, BeHappy or MeGUI to encode to AAC with QAAC.

If you want fix a average bitrate you can use the 'Constrained VBR' mode, always better than ABR or CBR .
After you can select the Profile desired.
And, for movies, I recommend check the 'No Delay' option.

LeMoi
12th December 2016, 22:21
Thanks for your help!
So, for example, for my first stereo HE-AAC 64 kbps setting, should it be like that:
http://nsa37.casimages.com/img/2016/12/12//161212103438929427.jpg
And for 5.1 LC-AAC 192 kbps setting:
http://nsa38.casimages.com/img/2016/12/12//16121210343936324.jpg
What if the source is a 7.1 DTS, will the LC-AAC be 7.1 to, or is there an option to keep 6ch instead of 8 ? Or does the AAC only allow 6ch max?
I don't find an equivalent of Parametric Stereo for low bitrates (e.g. 32 kbps)...
And last question, sometimes, for a 6ch track, I used to check the "Mode Boost: LigH" option in BeLight, to boost the volume for people who listen to the track in on only stereo system, is there such an option for qAAC in MeGUI, or in BeHappy ?

tebasuna51
13th December 2016, 15:17
My first answer was only related with QAAC encoder.
QAAC don't support HEv2 (Parametric Stereo), is very low quality not recommended for track movies.
EDIT: seems change automatically for low bitrates like herbert show in second next post
EDIT 2: I was right QAAC don't support HEv2

Other question is how decode, downmix or improve the audio before encode:

- Preferred decoder: Use always 'LWLibavAudioSource' for any input (DTS-HD, TrueHD, DTS, E-AC3, AC3, AAC, ...)

- Output Channels: Use 'Keep Original Channels' or 'Downmix multichannels to stereo' at your choice.
MeGUI don't offer 7.1 to 5.1, and encode to a 7.1 AAC is possible but not recommended.
Maybe you need BeHappy to do 7.1 (DTS-HD or TrueHD) -> AAC 5.1

- Apply Dynamic Range Compresión: recommended if 'Downmix multichannels to stereo' but only work with AC3 sources.

- Normalize Peaks to: 100% recommended if 'Downmix multichannels to stereo' (equivalent to BeLight OTA)

The BeLight (BeSweet) Boost filters aren't supported here, we can do some similar effects with AviSynth plugins, but is not easy to implement.

LeMoi
14th December 2016, 00:04
Thanks for the details. I only use HE-AAC v2 (Parametric Stereo) for commentary tracks, which don't need high or medium quality audio, it's just to save half the size of a track! I'll keep using BeLight for this, and for 6ch tracks (to be able to boost a little), too, thanks again for your help :)

herbert
14th December 2016, 01:25
Apple's encoder switches to HE-AAC v2 (PS) automatically for 32kbps or lower.

ffmpeg -i test.mp3 -f wav - | qaac64 --cvbr 64 -o lc.mp4 -
AAC-LC Encoder, CVBR 64kbps, Quality 96
Format profile : LC

ffmpeg -i test.mp3 -f wav - | qaac64 --he --cvbr 64 -o he.mp4 -
AAC-HE Encoder, CVBR 64kbps, Quality 96
Format profile : HE-AAC

ffmpeg -i test.mp3 -f wav - | qaac64 --he --cvbr 32 -o heps.mp4 -
AAC-HE Encoder, CVBR 32kbps, Quality 96
Format profile : HE-AACv2

tebasuna51
14th December 2016, 01:39
Apple's encoder switches to HE-AAC v2 (PS) automatically for 32kbps or lower.

Good to know, I never test low bitrates.

LeMoi
14th December 2016, 10:02
Thanks for the precisions :)

lvqcl
14th December 2016, 11:35
Cannot confirm: 'qaac64 --he --cvbr 32' still creates HE-AAC v1 files here.

herbert
14th December 2016, 15:10
Hmmm, interesting.

This was my test file: http://www.linguistik.uzh.ch/static/podcast/podcast-files/angesprochen-2016-11.mp3

MediaInfo tab in MPC-HC lists this as HE-AAC v2 when encoded at or below 32kbps by QAAC.

sneaker_ger
14th December 2016, 16:58
Please list your exact QAAC command line and version.

tebasuna51
14th December 2016, 21:56
Using qaac v2.61 the low bitrate supported is 32 Kb/s and the output is HE, not HEv2, with 2 standard channels +SBR

Using the mp3 uploaded or any input than I test.
angesprochen-2016-11.mp3_.m4a
AAC-HE Encoder, CVBR 32kbps, Quality 96
[9.0%] 24:23.222/4:30:31.923 (23.0x), ETA 10:42.577
64528128/715827840 samples processed in 1:03.679
Overall bitrate: 31.9982kbps
Optimizing...done

Don't show the "Format profile..." message.

LeMoi
14th December 2016, 22:19
Is MediaInfo really reliable? It is often wrong for detecting HE vs LC AAC in some of my rips made wit BeSweet, but I have not tried it yet for encodes made with QAAC

sneaker_ger
14th December 2016, 22:20
I suspect he's using an old MediaInfo version.

herbert
14th December 2016, 22:47
I suspect he's using an old MediaInfo version.

Quite possible, I'm using MediaInfo as shipped as part of MPC-HC 1.7.10.264.

ffmpeg version N-82225-gb4e9252, qaac 2.58, CoreAudioToolbox 7.10.7.0

I uploaded test encodes here: https://mega.nz/#!pYgTDQSI!6G1MQCAAdxSrFnFnWanSXfIolB4NyEZO4jRg76326L0

testffmpeg.mp4 = ffmpeg -i angesprochen-2016-11.mp3 -f wav - | qaac64 --he --cvbr 32 -o testffmpeg.mp4 -

test.mp4 = qaac64 --he --cvbr 32 -o test.mp4 angesprochen-2016-11.mp3

The file generated by ffmpeg | qaac is identified as HE-AAC v2 by MediaInfo.
The plain qaac encode is identified as HE-AAC.

Is there any reliable way of identifying the actual version of HE-AAC employed here?

Edit: Changed host for files

tebasuna51
15th December 2016, 01:24
I have my own tool (http://forum.doom9.org/showthread.php?p=1522330#post1522330) to check .m4a

This is a true HE v2 encoded with fdkaac:
File ........: D:\tmp\angesprochen-2016-11.m4a
Size ........: 5993053 bytes

---------------------------------------------- Header Info
Atom ID .....: ftyp
Audio format : AAC-HE v2 (LC+SBR+PS)
Channels ....: 2
SampleRate ..: 44100 Hz.
Total Frames : 31511
Total Samples: 32267264
Data Length .: 5853472 bytes
Duration trak: 1463.368 sec., (0h. 24m. 23.368s.)
BitRate .....: 32 Kb/s

And this I obtain with your uploaded samples:
File ........: D:\tmp\test.mp4 [testffmpeg.mp4]
Size ........: 5997310 bytes [5999452 bytes]
---------------------------------------------- Header Info
Atom ID .....: ftyp
Audio format : AAC-HE (LC+SBR)
Channels ....: 2
SampleRate ..: 44100 Hz.
Total Frames : 31510
Total Samples: 32266240
Data Length .: 5857602 bytes [5859844 bytes]
Duration trak: 1463.322 sec., (0h. 24m. 23.322s.)
BitRate .....: 32 Kb/s

tebasuna51
15th December 2016, 19:22
I only use HE-AAC v2 (Parametric Stereo) for commentary tracks, which don't need high or medium quality audio,
Still you can use 32 Kb/s with HE-AAC v1 (without PS) for these tracks

and for 6ch tracks (to be able to boost a little), too
I make some test about BeSweet Boost and I don't like very much.

First, never use the DspGuru mode, it is broken cutting and inversing peaks.

The LigH and Tera mode work amplifying low volume of all channels, and let high volume without changes.

If the problem is low dialog volume in 5.1 I think than is better amplify only the center channel

Also BeLight work only with AC3 input (for 5.1).

You can use a script like this:
LoadPlugin("MEGUI\tools\lsmash\lsmashsource.dll")
LoadPlugin("MEGUI\tools\avisynth_plugin\AudioLimiter.dll")
LWLibavAudioSource("YOUR_SOURCE", stream_index=-1,cache=false)

a = ConvertAudioToFloat()

flr = Getchannel(a, 1, 2)
cen = Getchannel(a, 3)#.Amplify(2).SoftClipperFromAudX(0.0)
lfe = Getchannel(a, 4)

Getchannel(a, 5, 6)
(AudioChannels(a)==7) ? c61_51(a) : last
(AudioChannels(a)==8) ? c71_51(a) : last
sur = last

mergechannels(flr,cen,lfe,sur)
ConvertAudioTo16bit()

function c61_51(clip b) {
blr = Getchannel(b, 5, 5)
slr = Getchannel(b, 6, 7)
MixAudio(blr, slr, 0.7071, 1.0).SoftClipperFromAudX(0.0)
return last
}

function c71_51(clip b) {
blr = Getchannel(b, 5, 6)
slr = Getchannel(b, 7, 8)
MixAudio(blr, slr, 1.0, 1.0).SoftClipperFromAudX(0.0)
return last
}
(Change MEGUI with the full path to your megui install, and YOUR_SOURCE with the full path to your input file)

To accept any source even DTS-HD or TrueHD 6.1 or 7.1 than downmix to 5.1.

If you remove the '#' in:

cen = Getchannel(a, 3).Amplify(2).SoftClipperFromAudX(0.0)

you can amplify only the center channel at your desired level.

herbert
16th December 2016, 03:14
I have my own tool (http://forum.doom9.org/showthread.php?p=1522330#post1522330) to check .m4a


That's a bummer about qaac! Thanks for double checking and the tool, will make use of it.

LeMoi
16th December 2016, 23:59
You can use a script like this:

(Change MEGUI with the full path to your megui install, and YOUR_SOURCE with the full path to your input file)

To accept any source even DTS-HD or TrueHD 6.1 or 7.1 than downmix to 5.1.

If you remove the '#' in:

cen = Getchannel(a, 3).Amplify(2).SoftClipperFromAudX(0.0)

you can amplify only the center channel at your desired level.
Thanks for the script, I'll try it next time I need to encode to AAC 5.1!

LeMoi
17th December 2016, 23:30
OK my first try is not really succesfull ^^
Doing a simple DTS -> HE-AAC conversion with these settings
http://nsa37.casimages.com/img/2016/12/17//161217114500765525.jpg
getting this error
http://nsa37.casimages.com/img/2016/12/17//16121711450134664.jpg
Did I miss something?

BTW I tried the same file 2 days ago but I wasn't home when it finished. I closed MeGUI without seeing that there were errors and the file didn't encode at all, I got a .dts.lwi file and an empty aac file with the same filename but I couldn't see the log...

lvqcl
18th December 2016, 01:11
Uncheck 'No Delay' option. It seems that it's not applicable to HE-AAC.

tebasuna51
18th December 2016, 01:51
Seems than the 'No Delay' option only work with AAC-LC.

Sorry, I never test AAC-HE before.

EDIT: like lvqcl say before than me.

hello_hello
18th December 2016, 07:29
Edit: Damn! Beaten to the punch twice. I didn't see the thread had a second page. :(

The "no delay" option can't be used with HE encoding. It's naughty of MeGUI to let you do it. I'll submit a bug report.

Edit: Bug report. https://sourceforge.net/p/megui/bugs/865/

https://github.com/nu774/qaac/wiki/Command-Line-Options

--no-delay
Compensate encoder delay by prepending 960 samples of silence, then trimming 3 AAC frames from the beginning (and also tweak iTunSMPB). This option is mainly intended for resolving A/V sync issue of video.
--num-priming (Experimental)
Set arbitrary number of priming samples in range from 0 to 2112 (default 2112). Applicable only for AAC LC. --num-priming=0 is the same as --no-delay. Doesn't work with --no-smart-padding.

LeMoi
20th December 2016, 22:57
OK, last try went fine but the bitrate was too variable, I targeted 64 kbps and I obtained 66 kbps, which can be a problem if a reallt want a specific 700 MB for example. I think I should use CBR to avoid this, or is there another way to have a 'precise' VBR like in video encoding?

hello_hello
21st December 2016, 06:39
Which encoding method did you use? For Constrained VBR I think you're setting the minimum average bitrate, but it's allowed to increase, although then it wouldn't be the average bitrate, but that's how Apple seem to explain it. They say it might result in a higher bitrate than ABR encoding.

https://developer.apple.com/library/content/technotes/tn2237/_index.html#//apple_ref/doc/uid/DTS40008147-CH1-SUBSECTION11

A 2kbps difference is only about 1.75MB for a 2 hour movie though.

I tried a few quick tests, re-encoding a stereo movie soundtrack, HE-AAC, 64kbps.

ABR - 63.3kbps
CVBR - 66.2kbps
CBR - 64kbps

By the way, QAAC has built in dynamic range compression. I've never used it myself, but you should be able to add it to the custom command line section in MeGUI's encoder configuration. If you do, it might be an idea not to check the normalise option and get QAAC to do the normalising instead. I don't know if it'd change the result. You'd have to test it. The command line option for enabling normalising is -N
There's an example of how to configure the dynamic range compression here:
https://github.com/nu774/qaac/wiki/Dynamic-range-compression
Not that I've used this function either, but you can specify your own downmix matrix. I don't know if MeGUI would complain if the encoding script it creates contains multiple audio channels but the encoder only outputs stereo.
https://github.com/nu774/qaac/wiki/Matrix-mixer

There's a few utilities for "compressing" the audio that don't use standard compression techniques. They work by increasing the volume of the quiet parts rather than compressing the loud bits. I find that works far better as there's no need to adjust the compression threshold for each source. Once you have the "compression" configured the way you like it, it should be fairly set and forget. I use a Winamp DSP courtesy of ffdshow's audio decoder to compress on playback rather than do it when encoding (Potplayer can load them itself). foobar2000 can add DSPs to it's conversion chain so I mainly use it for audio encoding. There's a matrix mixer DSP for downmixing and a WinAmp bridge DSP for loading WinAmp plugins if you want to compress. There's even a plugin for opening Avisynth scripts with foobar2000.

If you're interested, there's a few examples of compression attached to this post, and if you scroll up you'll find links and info on setting up foobar2000. http://forum.videohelp.com/threads/380744-DTS-to-AAC-using-Nero-AAC-encoder-command-line?p=2462994&viewfull=1#post2462994

LeMoi
22nd December 2016, 22:58
Thanks for your explanations. I use the profile that I showed a snap of it in previous post with CVBR 64 kbps
Actually, i'm doing multitracks mkv, and 2 audio files with 4 MB more can result in a +703 MB file... I know for most people it's not a cotnraint, but for some personal reasons I have to make a CD size file, so it can cause some problems ^^
I think i'll stick with the same profile and I'll just change CVBR to CBR to avoid oversized files, thanks again for your help!
For DRC, I just checked the box in the profile options, but I don't know if it's the same principle you're talking about or not...

hello_hello
23rd December 2016, 00:58
I think the DRC option simply applies any DRC info that may or may not be present in an AC3 stream. It's there for hardware players to apply DRC for AC3 correctly and I assume it's also applied when re-encoding if the option is checked. Someone else may know if it applies to any other source types. DTS possibly?

tebasuna51
23rd December 2016, 11:06
@LeMoi
If you want sacrify the quality, using CBR instead CVBR for a 2 Kb/s difference, is your choice, of course is not my advice.

@hello_hello
Is correct your comment.

About DTS: Yes, it can have DRC info when this flag is activated:

DYNF (Embedded Dynamic Range Flag)
DYNF indicates if embedded dynamic range coefficients are included at the start of each subframe. Dynamic range correction may be implemented on all channels using these coefficients for the duration of the subframe

but I only see a few dts's than uses this.

In Dolby Digital streams is mandatory the use of DRC, but encoding with free tools to AC3 (ffmpeg, Aften) is not recommended (bad implemented) at all.

LeMoi
24th December 2016, 16:45
@LeMoi
If you want sacrify the quality, using CBR instead CVBR for a 2 Kb/s difference, is your choice, of course is not my advice.

If the difference between these 2 settings is audible at these low bitrates, I can do an effort an target a smaller filesize with a smaller video to compensate the oversized audio files

hello_hello
25th December 2016, 15:56
I checked to make sure my memory was okay and Wikipedia says a 700MiB CD should hold 703MiB. ImgBurn says 702.8MiB for the CD I looked at, so there's a small margin for error there. https://en.wikipedia.org/wiki/CD-ROM#Capacity

LeMoi
25th December 2016, 22:55
Yup, I know that, I generally stop at 702.5 MB max.
I still have to try your script for 6ch, but the quality at 64 kbps seems good compared to my old CT AAC encodings :)