lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.39k stars 160 forks source link

Adding Multiple Surround Audio Tracks #268

Closed TehMaster closed 5 years ago

TehMaster commented 5 years ago

Hey Don (and others),

I cannot seem to get the flags correct to output multiple surround (7.1 and 5.1) tracks. My source is a bluray (with 8ch audio), and I would like to output the main audio track to a 7.1 eac3 768, and to a 5.1 ac3 448. To add to this I want to and the commentary track and copy that audio. What am I missing?

Here are my incorrect arguments for reference: --main-audio 1="7.1ch Surround" --audio-width main=surround --ac3-encoder eac3 --ac3-bitrate 768 --Add-audio 1="5.1ch Surround" --audio-width 1=surround --ac3-encoder ac3 --ac3-bitrate 448 --add-audio 6="Commentary" --pass-ac3-bitrate 384

Appreciate the help!!

lisamelton commented 5 years ago

@TehMaster Unfortunately, neither HandBrake nor FFmpeg are able to encode Dolby Digital Plus (DD+), i.e. eac3, audio in more than 5.1 channels yet. That might be coming in the future but I don't have an ETA. And although it's possible to encode AAC with 7.1 channels, I limit that to 5.1 because, other than a desktop computer, no devices out there that I know of can play it directly. Even then, desktop computers will mix 7.1 AAC down to stereo for playback and passthrough.

It's seems the world is not ready for encoding audio in 7.1 channels unless you have really expensive equipment and tools. Sorry about that.

Also, it's not easy to coax transcode-video into outputting the same input track in two different surround formats. Basically you have to use --handbrake-option to replace and pass all of the audio options to HandBrakeCLI yourself.

And that difficulty is by design. Why?

Most users never want to do this and, IMO, most users shouldn't do this because it's a waste of space and missing the point of why I created transcode-video in the first place. :)

Seriously, I strongly recommend that you just pick a single surround format and stick with that. I use DD+ (eac3) at 384 Kbps because:

  1. DD+ at 384 Kbps is actually as high quality as or even higher quality than plain ol' Dolby Digital (ac3) at 640 Kbps. Apple, Roku and Dolby streaming guidelines suggest DD+ at 192 Kbps for 5.1 channels so 384 Kbps is actually overkill.
  2. My various Roku devices will pass DD+ from Plex through to my surround systems unchanged so it doesn't even need to be dynamically re-transcoded.
  3. Plex will re-transcode DD+ to high-quality AAC at 256 Kbps stereo or 640 Kbps AC-3 surround when necessary.
  4. 384 Kbps is really small compared to the size of the video. Why waste space? :)

But... I can write the --handbrake-option voodoo for you if you really want that. Just let me know.

lisamelton commented 5 years ago

@TehMaster I finally had some time this afternoon, so... :) Here are the command line options and arguments to get what you want (except for 7.1 output which, as I mentioned before, is not possible):

-H audio=1,1,6 -H aencoder=eac3,ac3,copy -H ab=768,448, -H mixdown=,, -H aname=,"5.1ch Surround","Commentary"

The "-H" option (prefixed with a single "-") is just a shortcut for the longer "--handbrake-option". All of the commas are important! Even when they're trailing or doubled! Don't leave out a single one or it won't work.

And, obviously, don't include any other transcode-video audio options (like the ones you were using before) in your command line.

I hope that helps.

TehMaster commented 5 years ago

Hey Don,

I really appreciate your thoughtful explanations, and the time you took to write up the logic. I have a nice 5.1 setup now and admit the only reason i wanted to also store a 7.1 track is for a future 7.2 setup i plan to move to in a few years. You are also right about eac3 and 7.1 - when i used the guid version of handbrake i realize i output the 7.1 track in AAC. I recognize the limitations of DD being 5.1, but do not feel that 7.1 is pointless since my setup (Nvidiashield running plex receiver) can output 7.1 and play TrueHD 7.1/DTS-X/HD content if i set my receiver that way.

I only plan to use this for a few titles favorites anyway.. everything else gets eac3 5.1.

Appreciate the help as always!

lisamelton commented 5 years ago

@TehMaster No problem. That's why I'm here. :)

BTW, I realize that the Nvidia Shield can pass through 7.1 audio in formats like TrueHD or DTS-HD, as can many other devices, but can it decode 7.1 AAC and pass that through as PCM? I would guess it can't since it's based on Android and Android can currently only decode 5.1 AAC.

lisamelton commented 5 years ago

@TehMaster BTW, this is what I'm referencing for Android audio support:

https://developer.android.com/guide/topics/media/media-formats

I suppose Nvidia Shield might be rolling their own support for 7.1 AAC but I can't find anything online about that and their own website only doesn't say anything about channel support:

https://www.nvidia.com/en-us/shield/specs/

Please let me know if you have other information. Thanks!

lisamelton commented 5 years ago

@TehMaster OK, after some testing late tonight with a movie containing 7.1 AAC audio, Plex and a Roku connected to a 7.1 DD+ capable receiver, it looks like Plex is trying to re-transcode the AAC audio as 7.1 DD+. However, it's unclear whether the FFmpeg core that Plex is using is honoring that request or just creating 5.1 audio. Because when I try the same thing from the command line with ffmpeg, I can only get 5.1 audio.