Apple TV and 5.1 support - some definitive answers

Discuss encoding for devices and presets.
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.
aur0ra
Posts: 17
Joined: Sun Apr 15, 2007 12:53 pm

Re: AC3 using multiple tools

Post by aur0ra »

ragboy wrote: The THX demo I uploaded works on factory setup of Apple TV, you just need a receiver connected via optical, that will decode dolby digital CDs.
Ok, I finally got the DDWAV thing working. I love the fact that it is Dolby Digital but I don't love the fact that the file size is almost 3x the size of the original AC3.

I tried your method and inserted an AC3 track into the MP4 but (obviously) that wouldn't copy to the Apple TV because of the unrecognized audio layer...

It would be cool if someway-somehow the Apple TV would pass the AC3 from an MP4 track. I found this site which does AC3 passthrough in MP4

http://edageek.com/2007/01/24/ateme-ac- ... c-encoder/

But that doesn't help us at all because the file won't be copied or played on the Apple TV.

I was originally all about the ATVFiles plugin, but when I found out that my movies and such wouldn't be under "Movies", "TV Shows" etc it kind of turned me off a bit (that and I couldn't get AC3 working with ATVFiles either). There's gotta be a way to get this to work out of the box and I intend on trying more to hopefully find a solution.
Anamonde
Novice
Posts: 71
Joined: Fri Mar 16, 2007 11:11 pm

Post by Anamonde »

Yeah I would still love to see AC3 passthrough in mp4 like gbooker suggested. For me and anyone else running ATVFiles this would be awesome.
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: AC3 using multiple tools

Post by jbrjake »

aur0ra wrote:I found this site which does AC3 passthrough in MP4

http://edageek.com/2007/01/24/ateme-ac- ... c-encoder/
I see nothing there concerning AC3 passthrough in the MP4 container. It's about AC3 pass-through in an MPEG-2 transport stream. The only references to "MPEG-4" on the page refer to the MPEG-4 AVC/H.264 codec, not the MPEG-4 container.
e71
Posts: 15
Joined: Thu Mar 29, 2007 7:14 pm

AC-3 playback info

Post by e71 »

There seems to be some confusion as to how AC-3 playback works and why the Apple TV has problems. To understand these issues, we need to look at two components:
  1. Get the AC-3 stream into the Apple TV
  2. Transfer the AC-3 stream from Apple TV to the stereo / TV during playback
Each of these has their own set of problems and challenges that can prevent you from successfully playing back discrete 5.1 audio. Let's look at each item individually:
  1. 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. If we could embed an AC-3 stream into a supported file format, Apple TV would still need to support AC-3. It would need to recognize the AC-3 data and know what to do with it (either decode it using a built-in AC-3 codec which it doesn't currently have or send it out over S/PDIF to be decoded by the receiver). Because Apple TV does not even look for AC-3 data, we're pretty much out of luck here without adding software.
  2. 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.
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.

Another part of the puzzle is getting the raw AC-3 stream into a format that Apple TV can handle. There is a format called dd-wav that takes the raw AC-3 data, pads each block 0s so that the final length matches an uncompressed stereo stream at the same sample rate. That is actually the same format that the AC-3 data is transmitted over S/PDIF in and what really allows Apple TV to send AC-3 data to a receiver. The final task is to get the dd-wav back into a video file that Apple TV can handle (typically mp4 in our case). Because the exact AC-3 data has to get to the receiver without modification, none of the lossy codecs (like mp3 and aac) can be used. And since it looks like Apple TV can't handle straight uncompressed audio in an mp4 file, the best / only solution found to date is compress the stream using the Apple Lossless codec.

So to summarize, here are the steps in a general sense to get AC-3 data out of the Apple TV (matching the earlier specific processes posted by aswick and numbers987654321):
  1. Extract raw AC-3 stream from DVD (likely 48kHz sample rate)
  2. Convert to raw 44.1kHz AC-3 stream if original is 48kHz
  3. Convert raw 44.1kHz AC-3 stream to dd-wav
  4. Encode dd-wave as Apple Lossless and embed into video file
Currently some of these steps have to be performed on Windows, but that is soon to change ;-).
deckeda
Enlightened
Posts: 138
Joined: Thu Feb 22, 2007 8:38 am

Post by deckeda »

Here's what concerns me:

1) #4 ... which container will hold that elixir, and what would it take for AppleTV to not just recognize/accept it (a Perian-type solution?) but of course also deliver it unscathed out the S/PDIF ? And then there's iTunes and metadata to consider.

2) Apple Lossless would balloon the file size quite a bit --- and because it's variable, to an unpredictable amount --- probably to the detriment of available bitrate for video. Perhaps a new AppleTV will accept higher total bitrates, but that's not yet.
e71
Posts: 15
Joined: Thu Mar 29, 2007 7:14 pm

Post by e71 »

deckeda wrote:Here's what concerns me:

1) #4 ... which container will hold that elixir, and what would it take for AppleTV to not just recognize/accept it (a Perian-type solution?) but of course also deliver it unscathed out the S/PDIF ? And then there's iTunes and metadata to consider.
So far, I believe only .mov files have been working, but I don't see any reason why a .mp4 wouldn't work as well. I have some more experimenting to do to figure that one out. With a dd-wav audio stream embedded in the video file, I don't think we'll run into the same metadat bugs that have been seen with multi-channel streams. As far as iTunes is concerned, its just a standard Apple Lossless stream. But I haven't tried it myself, so I don't know for sure.
deckeda wrote: 2) Apple Lossless would balloon the file size quite a bit --- and because it's variable, to an unpredictable amount --- probably to the detriment of available bitrate for video. Perhaps a new AppleTV will accept higher total bitrates, but that's not yet.
I wouldn't expect the audio bitrate to impact the supported video bitrates on Apple TV. I would expect it to be more CPU limited rather than net bandwidth limited and decoding a higher bitrate Apple Lossless file shouldn't be any more CPU intensive than a 128kbps AAC audio stream. But I could be wrong here too. Quite a lot of speculation on my part here, but hopefully reasonably accurate.
ragboy
Experienced
Posts: 82
Joined: Mon Apr 09, 2007 4:03 pm

Re: AC3 using multiple tools

Post by ragboy »

aur0ra wrote:
ragboy wrote: The THX demo I uploaded works on factory setup of Apple TV, you just need a receiver connected via optical, that will decode dolby digital CDs.
Right on. I started experimenting to figure out what caused the problem. Turns out ATVFiles does *something* to hose the DDWAV output. I don't know how or why, but after installing ATVFiles the demo didn't work.

As a side note - I tried your method all night and wasn't able to get a DDWAV file to play. I thought I followed your instructions (again, it was late). Using AC3Machine and BeSweet v1.5b (since v1.4 didn't have the ac3enc.dll) cause the static sound on my computer (which is expected) but no sound at all from the receiver. I made sure to choose AC3-WAV from the options and turned everything else off.
After you create the DD-WAV file, you must export to a mov, just sound, apple lossless, as described.
ragboy
Experienced
Posts: 82
Joined: Mon Apr 09, 2007 4:03 pm

Post by ragboy »

e71 wrote:
deckeda wrote:Here's what concerns me:

1) #4 ... which container will hold that elixir, and what would it take for AppleTV to not just recognize/accept it (a Perian-type solution?) but of course also deliver it unscathed out the S/PDIF ? And then there's iTunes and metadata to consider.
So far, I believe only .mov files have been working, but I don't see any reason why a .mp4 wouldn't work as well. I have some more experimenting to do to figure that one out. With a dd-wav audio stream embedded in the video file, I don't think we'll run into the same metadat bugs that have been seen with multi-channel streams. As far as iTunes is concerned, its just a standard Apple Lossless stream. But I haven't tried it myself, so I don't know for sure.
deckeda wrote: 2) Apple Lossless would balloon the file size quite a bit --- and because it's variable, to an unpredictable amount --- probably to the detriment of available bitrate for video. Perhaps a new AppleTV will accept higher total bitrates, but that's not yet.
I wouldn't expect the audio bitrate to impact the supported video bitrates on Apple TV. I would expect it to be more CPU limited rather than net bandwidth limited and decoding a higher bitrate Apple Lossless file shouldn't be any more CPU intensive than a 128kbps AAC audio stream. But I could be wrong here too. Quite a lot of speculation on my part here, but hopefully reasonably accurate.
I have seen MP4 files with ALAC as the soundtrack, so I know it is possible. However, I don't know how to build one, since you don't seem to have the option in QTPRO export, and ffmpeg/mencoder do not ENCODE ALAC. When I have some time, I may be able to get into the quicktime api to do this. But its kindof just for [Censored]-and-giggles, because the MOV file works just as well on Apple TV.

On another note, it is not the ALAC that bloats the audio file, but the conversion to DDWAV that bloats the file.

Another interesting note, is that VLC will recognize a ddwav, on the mac and play it through speakers, but not AFTER encoded to lossless.
gbooker
Posts: 43
Joined: Sat Apr 07, 2007 8:38 pm

Re: AC-3 playback info

Post by gbooker »

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
gbooker
Posts: 43
Joined: Sat Apr 07, 2007 8:38 pm

Re: AC3 using multiple tools

Post by gbooker »

aur0ra wrote:I was originally all about the ATVFiles plugin, but when I found out that my movies and such wouldn't be under "Movies", "TV Shows" etc it kind of turned me off a bit (that and I couldn't get AC3 working with ATVFiles either). There's gotta be a way to get this to work out of the box and I intend on trying more to hopefully find a solution.
Unfortunately, this is the price we have to pay. I don't think we can rely on Apple to add in the necessary features to make AC-3 passthrough work (I have tried in the past with QuickTime player and the response I received indicated that it is unlikely in order to appease the MPAA and their conspirators). So the only recourse it to hack it with something else.

Now Apple, if you are listening, all you have to do is have your BackRow (or whatever you call it) set the sample rate of the optical device to match that of the media file (which, honestly it should do anyway), and then if the audio is 'ac-3', switch the output to 'Encoded Digital Audio'. Course this only matters on the optical link, not on the PCM outputs. If you really feel up to it, you could also do the passthrough stuff itself and neglect my codec. It really isn't that hard!
e71
Posts: 15
Joined: Thu Mar 29, 2007 7:14 pm

Re: AC-3 playback info

Post by e71 »

gbooker wrote: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.
Good to know. I thought I had looked up the supported codecs for .mov, but I must have only seen a list of what Quicktime can natively decode.
gbooker wrote: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.
That is the format... There is a code for this as well: 'cac3'. The CoreAudio headers describe it as: "AC-3 packaged for transport over an IEC 60958 compliant digital audio interface" which in our case we're also packaging in a stereo PCM stream.
gbooker wrote: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
Sorry... I had read your earlier comments, but didn't interpret what you said to indicate that the Apple TV always output at 44.1kHz and resampled any output to match. It would be nice if it did automatically change the output format to match.
maurj
Enlightened
Posts: 148
Joined: Thu Jan 11, 2007 5:31 pm

Post by maurj »

Gbooker,

I'm up for trying to patch HandBrake's copy of libmp4v2 to create audio tracks of type 'ac-3', in order to make HandBrake create mp4 files with AC3 audio passthru. It remains to be seen whether these will be accepted by QuickTime, but I think there's every chance they will be if we're using the m4v file extension. This may just give us AC-3 audio in a QuickTime / Apple TV supported file format, rather than AVI. It may not work, but it's worth a try!

When creating your ac-3 MOV files, have you had to do anything special to the source AC3 stream when including it as a QuickTime soundtrack? Does it have a separate header, or do you just pass in the source samples?

- maurj
ragboy
Experienced
Posts: 82
Joined: Mon Apr 09, 2007 4:03 pm

Post by ragboy »

maurj wrote:Gbooker,

I'm up for trying to patch HandBrake's copy of libmp4v2 to create audio tracks of type 'ac-3', in order to make HandBrake create mp4 files with AC3 audio passthru. It remains to be seen whether these will be accepted by QuickTime, but I think there's every chance they will be if we're using the m4v file extension. This may just give us AC-3 audio in a QuickTime / Apple TV supported file format, rather than AVI. It may not work, but it's worth a try!

When creating your ac-3 MOV files, have you had to do anything special to the source AC3 stream when including it as a QuickTime soundtrack? Does it have a separate header, or do you just pass in the source samples?

- maurj
What would be great about this, is if the apple tv will show these files natively in backrow because of the m4v format. Then, it could be possible to play passthrough, by just installing a codec in to ATV, like perian, and not having to install ATV Files.
deckeda
Enlightened
Posts: 138
Joined: Thu Feb 22, 2007 8:38 am

Post by deckeda »

maurj wrote: I'm up for trying to patch HandBrake's copy of libmp4v2 to create audio tracks of type 'ac-3', in order to make HandBrake create mp4 files with AC3 audio passthru. It remains to be seen whether these will be accepted by QuickTime, but I think there's every chance they will be if we're using the m4v file extension. This may just give us AC-3 audio in a QuickTime / Apple TV supported file format, rather than AVI.
I do like the way you think, maurj!
loyalty_anchored
Bright Spark User
Posts: 183
Joined: Wed Mar 14, 2007 1:49 pm

Post by loyalty_anchored »

i do believe this to be the ideal solution, to have m4v files stream direct from itunes with the pass through codec installed on the ATV, this solution will give us the best of both worlds.

i would like to thank Gbooker and Maurj for all the efforts made and all the efforts that will be done to accomplish this.

got my fingers crossed :lol:
ragboy
Experienced
Posts: 82
Joined: Mon Apr 09, 2007 4:03 pm

Post by ragboy »

loyalty_anchored wrote:i do believe this to be the ideal solution, to have m4v files stream direct from itunes with the pass through codec installed on the ATV, this solution will give us the best of both worlds.

i would like to thank Gbooker and Maurj for all the efforts made and all the efforts that will be done to accomplish this.

got my fingers crossed :lol:
Ditto, the only question, is if backrow will display a file, even if m4v, with ac3 in it, and not AAC, or ALAC.
loyalty_anchored
Bright Spark User
Posts: 183
Joined: Wed Mar 14, 2007 1:49 pm

Post by loyalty_anchored »

ragboy wrote:
loyalty_anchored wrote:i do believe this to be the ideal solution, to have m4v files stream direct from itunes with the pass through codec installed on the ATV, this solution will give us the best of both worlds.

i would like to thank Gbooker and Maurj for all the efforts made and all the efforts that will be done to accomplish this.

got my fingers crossed :lol:
Ditto, the only question, is if backrow will display a file, even if m4v, with ac3 in it, and not AAC, or ALAC.
only way to know is to try. like i said, fingers crossed as this would allow me to do exactly what i intended with my DVD collection, Handbrake and my Apple TV.
gbooker
Posts: 43
Joined: Sat Apr 07, 2007 8:38 pm

Post by gbooker »

maurj wrote:I'm up for trying to patch HandBrake's copy of libmp4v2 to create audio tracks of type 'ac-3', in order to make HandBrake create mp4 files with AC3 audio passthru. It remains to be seen whether these will be accepted by QuickTime, but I think there's every chance they will be if we're using the m4v file extension. This may just give us AC-3 audio in a QuickTime / Apple TV supported file format, rather than AVI. It may not work, but it's worth a try!
Yeah, I am worried that QT or something will reject it if it has the wrong codec type for an m4v or mp4 file. It should work with a mov file
maurj wrote:When creating your ac-3 MOV files, have you had to do anything special to the source AC3 stream when including it as a QuickTime soundtrack? Does it have a separate header, or do you just pass in the source samples?
There are a few ways I have done this. My codec includes an ac3 importer, which will import raw .ac3 files into QT. Then I can save a reference movie or a self-contained movie. This is just a simple case of creating the sound track and including the samples with their timecodes and duration (AC3 is simple here, the samples are constant duration). Other methods include importing from an AVI or an MKV with perian. Same thing there, just normal sample data.

Don't forget, AC3 is a stream format. Each packet has its own header and the packet is entirely self-contained. My codec needs nothing more than a series of packets to decode, and QT only needs to know what data it feeds to the codec, and when to play it.
e71
Posts: 15
Joined: Thu Mar 29, 2007 7:14 pm

Mac OS X tools for dd-wav conversion

Post by e71 »

I have gotten a set of tools running on Mac OS X that will resample 48kHz AC-3 raw streams to 44.1kHz and then convert that to a dd-wav. So now all of the steps needed to get Apple TV to play back 5.1 AC-3 audio can be performed in Mac OS X instead of Windows. However I need a place to host the two tools. Does anybody have a site that can host them? They are under 5MB total.

Once they're available online, I'll post instructions on how to use them.
randyharris
Posts: 24
Joined: Wed May 09, 2007 3:58 am

Re: Mac OS X tools for dd-wav conversion

Post by randyharris »

e71 wrote:Does anybody have a site that can host them? They are under 5MB total.

Once they're available online, I'll post instructions on how to use them.
I'm more than happy to host, PM me and I'll send you info for getting me the file and I can put on www immediately.

:)

UPDATE: e71 has sent the files to me, they're hosted on my site, and he is writing up the instructions now on how to use. All the info will be posted soon.
Last edited by randyharris on Wed May 09, 2007 4:48 am, edited 1 time in total.
ragboy
Experienced
Posts: 82
Joined: Mon Apr 09, 2007 4:03 pm

Re: Mac OS X tools for dd-wav conversion

Post by ragboy »

e71 wrote:I have gotten a set of tools running on Mac OS X that will resample 48kHz AC-3 raw streams to 44.1kHz and then convert that to a dd-wav. So now all of the steps needed to get Apple TV to play back 5.1 AC-3 audio can be performed in Mac OS X instead of Windows. However I need a place to host the two tools. Does anybody have a site that can host them? They are under 5MB total.

Once they're available online, I'll post instructions on how to use them.
I can also host, let me know.
e71
Posts: 15
Joined: Thu Mar 29, 2007 7:14 pm

Mac OS X tools for dd-wav conversion

Post by e71 »

OK - here they are... tools to convert raw 48kHz AC3 files to 44.1kHz dd-wav encoded wav files for Mac OS X.

http://www.macseven.com/appletv/e71_App ... _tools.dmg

Thanks to randyharris for hosting them.

There are two utilities in the package. The first is a modified version of ffmpeg that can decode and encode AC-3 (existing functionality) and can resample all 6 channels in a 5.1 AC-3 file (new functionality not in existing ffmpeg builds). The second is a utility called spdifer for which the sources come from a Windows project called AC3Filter (see link at the end for the original sources). That has been ported to Mac OS X and had a couple of bugs fixed to be able to successfully convert raw AC-3 streams output by ffmpeg into a wav file.

Here are the new steps to creating a .mov video file with Handbrake-created video and embedded AC-3 audio that is recognized by Apple TV and correctly sent to and decoded by a standard stereo receiver:
  1. Create .mp4 using Handbrake as normal
  2. Use mplayer to extract the raw AC-3 audio stream
    • mplayer dvd://1 -dumpaudio -dumpfile audio-48.ac3
  3. Use new ffmpeg to convert 48kHz raw AC-3 audio file from dvd into a 44.1kHz raw AC-3 audio file:
    • ffmpeg -i audio-48.ac3 -acodec ac3 -ab 448000 -ar 44100 audio-441.ac3
  4. Use spdifer tool to convert raw 44.1kHz AC-3 audio file to dd-wav
    • spdifer audio-441.ac3 audio-441-ac3.wav -wav
  5. Continue with instructions on garcias.com: http://www.garcias.com/TheGarcias/Dad%2 ... 6FE4E.html
    Start with step 4 and make sure to perform a copy operation after step #7
That should be it. I still see the same sync issues as with the Windows tools however. I'm looking to that. It appears that the raw AC-3 file that mplayer creates is of a slightly different length than the .mp4 video that Handbrake creates. Its possible that explains the sync issues. Or it could just be an issue with exactly where mplayer starts the extraction vs. where Handbrake does.

* AC3Filter web site: http://ac3filter.net
starboundcanary
Posts: 2
Joined: Wed May 09, 2007 5:30 am

Re: Mac OS X tools for dd-wav conversion

Post by starboundcanary »

e71 wrote:OK - here they are... tools to convert raw 48kHz AC3 files to 44.1kHz dd-wav encoded wav files for Mac OS X.
They work like a charm, except that in the two ac3 files I attempted to convert (one from a clip of a TV show from my cable box, the other from a DVD Rip [Stranger than Fiction]), it appears that the right and center channels get swapped at some point in the process--the center channel (narration) ends up in the right speaker... I imagine this is just a simple bug in the code...

Also, offering PowerPC binaries (alongside the Intel ones you have) would be beneficial to those still using PPC machines.

Except for the serious center/right channel bug, the instructions worked like a charm and are so much simpler than trying to figure out the Windows side of things and translate back and forth between the two. Thanks for your hard work!
ragboy
Experienced
Posts: 82
Joined: Mon Apr 09, 2007 4:03 pm

Re: Mac OS X tools for dd-wav conversion

Post by ragboy »

e71 wrote:That should be it. I still see the same sync issues as with the Windows tools however. I'm looking to that. It appears that the raw AC-3 file that mplayer creates is of a slightly different length than the .mp4 video that Handbrake creates. Its possible that explains the sync issues. Or it could just be an issue with exactly where mplayer starts the extraction vs. where Handbrake does.

* AC3Filter web site: http://ac3filter.net
I fixed the sync issues in my procedures, and have an update at the bottom.

http://www.garcias.com/TheGarcias/Dad%2 ... 6FE4E.html

It involves yet another windows app, but I don't know any other app that will demux ac3 and tell you the delay.
e71
Posts: 15
Joined: Thu Mar 29, 2007 7:14 pm

Re: Mac OS X tools for dd-wav conversion

Post by e71 »

starboundcanary wrote:They work like a charm, except that in the two ac3 files I attempted to convert (one from a clip of a TV show from my cable box, the other from a DVD Rip [Stranger than Fiction]), it appears that the right and center channels get swapped at some point in the process--the center channel (narration) ends up in the right speaker... I imagine this is just a simple bug in the code...
Sorry about that... I didn't notice it in my testing because my front speakers are quite close together in my test setup. I should be able to have a new version tonight with this fixed.
starboundcanary wrote: Also, offering PowerPC binaries (alongside the Intel ones you have) would be beneficial to those still using PPC machines.
The spdifer tool is built for both architectures, but ffmpeg is only Intel. I'll have a look at the ffmpeg Makefile to see if they've made it easy or not. I'll try to get a Universal build out tonight if possible.
Locked