Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Allow for AAC he-audio encoding, configurable bitrates #48

Closed
wants to merge 1 commit into from

Conversation

bdaroz
Copy link
Contributor

@bdaroz bdaroz commented Jun 26, 2016

Update to allow AAC, in addition to opus codec, to be used in --he-audio mode. Adds a new --he-audio-format parameter and --he-audio-bitrate parameter to specify the bitrate per channel of audio in the stream. The old --downmix-he-audio parameter is removed and replaced by --he-audio-format prologic.

Default bitrate set at 64kbps/channel. Link to the FFmpeg wiki explaining the default included in code comment.

Update to allow AAC, in addition to opus codec, to be used in
--he-audio mode. Adds a new --he-audio-format parameter and
--he-audio-bitrate parameter to specifify the bitrate per channel
of audio in the stream. The old --downmix-he-audio parameter is
removed and replaced by --he-audio-format prologic.

Default bitrate set at 64kbps/channel. Link to the FFmpeg wiki
explaing the default included in code comment.
@FallingSnow
Copy link
Owner

I've used he aac profile 2 before and opus provides superior quality at the same bitrate.

@bdaroz
Copy link
Contributor Author

bdaroz commented Jun 26, 2016

It does, however, it does not have as robust support among devices, meaning that, for example, if you're using Plex, the server has to transcode the track.

Note this commit does not change the default -- it's still opus, it just adds the aac support.

@FallingSnow
Copy link
Owner

Neither does h265, but I'm not going to add an option to use x264.

I believe this utility should only provide the best, users should already be aware that h265ize does not target compatibility.

On another note @bdaroz, I think I'm going to to merge --no-auto-subtitle-titles and --no-auto-audio-titles into one flag.

@bdaroz
Copy link
Contributor Author

bdaroz commented Jun 26, 2016

Fair enough, but keep in mind tests pulled off master showed the current settings encoding opus at 32kbps/channel not the 48kbps in the documentation. (and below the 64k recommended)

Also, if you want to look at those flags, check #46 as well.

@FallingSnow
Copy link
Owner

The documentation actually refers to per 2 channels. But even that is wrong, in the code it's set to 64kbps per 2 channels. That's why your seeing 32kbps/channel. I will make an issue to update the documentation.

I set it at 32k because I personally don't notice any difference, but I am by no means an audiophile.

BTW, can you provide me a link to the recommendation of 64kbps/channel.

@bdaroz
Copy link
Contributor Author

bdaroz commented Jun 26, 2016

Here's the link:
https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio
(Bitrates at at the bottom of the page)

Also note the chart at the top of this Opus page:
https://www.opus-codec.org/comparison/

@bdaroz bdaroz deleted the audioCodecs branch June 26, 2016 20:01
@FallingSnow
Copy link
Owner

Interesting, but I suppose bitrate is really just subjective. Do you notice any degredation in audio quality when using --he-audio? h265ize also uses a frame duration of 60ms rather than the default 20ms.

Increasing the frame duration also slightly improves coding
efficiency, but the gain becomes small for frame sizes above 20 ms.
RFC 6716

@FallingSnow
Copy link
Owner

I think I might bring the bitrate up to 40k/channel just so it falls under fullband,

@bdaroz
Copy link
Contributor Author

bdaroz commented Jun 26, 2016

Because all the gear I have hooked up to audio equipment that's not crap (eg computer headphones) can't decode opus I have no way of telling. (Which is why I added this option in the PR to start with -- I'd have to transcode back to aac or something else in real time anyway.) That said, because any loss of quality would need the source material to correct (and if people are replacing existing h264/ac3 or h264/dts, would need to reacquire it) I would err on the slightly larger, but known quality side. I picked 64k/channel because all the comparisons and listening tests used that bitrate, but nothing I could see went lower.

One last thought... Looking at the quality graph on the page I linked, if you're coming from 64k/channel ac3, going to anything less than at least 48k/channel opus would be a drop in quality. Worse still DTS (or DTS-MA) to opus at 40k could be a significant drop (at least with a significant bitrate improvement). Either way, hard to hard to argue it's the "best" when you're reencoding to an audio quality loss for a small gain at best. (If my math is right 64k/channel ac3 -> 40k/channel opus is a 24kbps/channel savings, over 6 channels 144kbps, or 18KB/s or about 64MB/hr. If there is a perceptible loss, is the paltry space improvement worth it?)

@FallingSnow
Copy link
Owner

You bring up a good point about no research material going below 64k.

As to why I feel it's worth the 64MB/hr, I only use he audio on half hour episodes where I target 130-180MB. So that's why it's worth it for me personally. I already didn't notice any degradation when it came to 32k so I feel people such as myself with little audio experience wouldn't mind the 40k bitrate.

@bdaroz
Copy link
Contributor Author

bdaroz commented Jun 27, 2016

Understood, my use case is more for archival purposes (think inactive or not often accessed) with shows that are no longer on the air. I don't need dts audio there anymore, but while I think h265 decoder support will be more and more likely in future devices, I'm not as optimistic for opus, hence why I go aac. In that case the drop from 1500kbps to 384kbps is already dramatic, another 160kbps or so isn't really going to make as much an impact in space savings.

@rb2k
Copy link

rb2k commented Dec 29, 2016

I know it has been a while, but I'd love to chime in to voice my support for AAC just for compatibility reasons.
There are a good amount of players by now that can decode HVEC video (and AAC) directly. Both on SmartTVs as well as applications (e.g. infuse for ipad).
Sadly, so far I haven't really seen support for Opus supported anywhere yet (even though it's the better codec).

@FallingSnow
Copy link
Owner

I will reconsider this since more people have shown interest. In the mean time, I do believe @bdaroz's fork has AAC support.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants