e71 wrote:
- Get the AC-3 stream into the Apple TV
In order to get the AC-3 stream into the Apple TV, the AC-3 stream has to be embedded into a file (either audio or video) in a format that can handle AC-3 data and that the Apple TV can recognize. None of the video formats that Apple TV currently supports (.mp4, m4v, .mov) can natively carry AC-3 data. <snip>
Actually, the .mov format can support any format. It essentially just states that it has n tracks, and their formats, and then proceeds to have file locations for samples along with time and duration information. There is nothing in .mov which limits it from carrying AC3 data. I stick AC3 data in .mov all the time. .mp4 and .m4v may be a different story, because the standards there limit the kinds of codecs which can be used in the containers. BTW, CoreAudio has a built in fourcc (codec code) for AC3. It is 'ac-3' and my codec uses it.
e71 wrote:
- Transfer the AC-3 stream from Apple TV to the stereo / TV
Once in the Apple TV, the AC-3 audio stream needs to be transmitted to the stereo receiver where it is decoded into individual channels and played out the speakers. The standard way to do this is over S/PDIF which is carried on either a coax cable (typically connected with an RCA connector) or an optical cable (which the Apple TV uses). This same transport can individually carry both compressed AC-3 / DTS audio and uncompressed stereo audio. When carrying compressed AC-3 data, there is a status bit in the S/PDIF transport stream that is set differently than when carrying normal, uncompressed audio. This is one of the biggest hurdles in getting AC-3 data to be decoded by the receiver. The sending side has to explicitly set that bit (which Apple TV doesn't do since it doesn't know anything about AC-3). The playback software has to know that it is sending AC-3 data and then explicitly tell the audio driver to set that bit. Otherwise, the receiver generally won't recognize the data as AC-3 and will try to play it as uncompressed stereo audio.
I expect this is exactly what the "Encoded Digital Audio" format is. If you don't know what I am talking about here, open Audio Midi Setup, and examine the formats for audio output on an optical connection. If you try playing a DVD in DVD Player and use the passthrough, you will see that the format in use is Encoded Digital Audio.
e71 wrote:
So given all of this, there should be no way for Apple TV with the built-in software to play back discrete, AC-3 encoded 5.1 audio. But fortunately a number of enterprising individuals have discovered that there is. When AC-3 data is sent over S/PDIF, it looks like uncompressed stereo audio to the receiver. The smaller 5.1 AC-3 stream is padded to be the same size as uncompressed stereo audio. The receiver typically looks at the status bit to determine whether the data is AC-3 compressed, or uncompressed stereo. Fortunately it seems that at least some if not all currently receivers can auto-detect 5.1 AC-3 even without the status bit set. There does appear to be a limitation however. Testing has shown that at least some, probably most and possibly all receivers won't auto-detect 48kHz AC-3 when played back this way. And most if not all DVD originated 5.1 AC-3 streams are 48kHz. So in order to take advantage of this technique, they have to be converted to 44.1kHz. That means that the AC-3 stream has to be decoded, converted from 48kHz to 44.1kHz and then re-encoded to AC-3. Its not ideal, but even a re-encoded 44.1kHz AC-3 stream should sound quite good.
Actually, on the inability to work with 48KHz AC-3, I have to say you are flat wrong. It works exactly the same with 48KHz AC-3 as it does with 44.1KHz. The problem is if the ATV has its audio output set to 44.1KHz and it has audio in 48KHz, it will downsample it to match the output of the device. This downsampling of supposed PCM data
destroys the encoded audio, which is why it seems like it doesn't work. Change the output sample rate to 48KHz, and then 48KHz AC-3 works.
I actually stated much of this earlier in this thread:
http://handbrake.m0k.org/forum/viewtopi ... =8013#8013