This is intended to be a tutorial, hopefully not duplicating a pre-existing thread. This is for Macs but may work on Windows as well with a little "standing on one leg and pulling faces" and such like.
It would be great to have multichannel music in iTunes but "multichannel" and "iTunes" are two words which don't mix. The only way seems to be to have Dolby Digital or DTS in WAV files and to manually set up the digital output audio device to the right sample rate, setting the iTunes volume to maximum (x1) to preserve the bitstream. This works but iTunes does not have exclusive use of the device, so system beeps or viewing web page videos will disrupt the decoding of the bitstream and leave just silence, or even worse, a very loud noise.
However there IS a way by using the M4V format used by podcasts. This supports multiple audio codecs including Dolby Digital, including multichannel Dolby Digital. Playing a Dolby Digital track causes iTunes to set up the audio device for exclusive use, the stream being selected via the "Audio & Subtitles" submenu on the Controls menu which becomes available when multiple streams are present in an imported M4V file. This provides what is needed - no other application producing audio can mix anything into the playback stream so it stays intact.
An M4V file imported into iTunes can be played like an MP3, WAV, or ALAC file, but now with full multichannel support. It also contains only raw DD, unlike WAV files which encapsulate it in a padded-out S/PDIF format and use much more space, so it helps to make the most of hard disk space.
The M4V format also supports chapters, a new menu being added when iTunes detects a track has chapters defined in it - this makes it possible to import a whole album as a continuous DD stream and to access individual tracks as chapters, meaning the audio can play continuously without gaps, gaps being unavoidable if the album is imported as separate tracks.
Unfortunately the M4V format does not support DTS as a codec, they remain only playable in WAV-type PCM files.
How-to:
The results will be in "outfile.m4v" which can then be directly imported into iTunes like any other track.
This example is for two Dolby Digital audio streams (each of which will be separately selectable in the iTunes "Audio & Subtitles" submenu when the imported file is played) but it can be adapted for any number. Just add "-i nth_ac3_file.ac3", "-map n:0", "-c:a:n-1 copy", "-metadata:s:a:n-1 language=eng" and "-disposition:a:n-1 default" options as appropriate. Note that the "-disposition" option sets which stream is to be the default, so there should only be one set to "default", all the others should be set to "none". If there is only one audio stream then this option can be skipped. The "-map n:0" options must be in order otherwise the subsequent options will stop working.
Sample "chapters_file.txt" file for ffmpeg, adapt as appropriate. The start and end times are in 100ths of a second.
Make sure that you select "Prefer AC3 Passthrough" in the iTunes "Audio & Subtitles" submenu, and enjoy.
It would be great to have multichannel music in iTunes but "multichannel" and "iTunes" are two words which don't mix. The only way seems to be to have Dolby Digital or DTS in WAV files and to manually set up the digital output audio device to the right sample rate, setting the iTunes volume to maximum (x1) to preserve the bitstream. This works but iTunes does not have exclusive use of the device, so system beeps or viewing web page videos will disrupt the decoding of the bitstream and leave just silence, or even worse, a very loud noise.
However there IS a way by using the M4V format used by podcasts. This supports multiple audio codecs including Dolby Digital, including multichannel Dolby Digital. Playing a Dolby Digital track causes iTunes to set up the audio device for exclusive use, the stream being selected via the "Audio & Subtitles" submenu on the Controls menu which becomes available when multiple streams are present in an imported M4V file. This provides what is needed - no other application producing audio can mix anything into the playback stream so it stays intact.
An M4V file imported into iTunes can be played like an MP3, WAV, or ALAC file, but now with full multichannel support. It also contains only raw DD, unlike WAV files which encapsulate it in a padded-out S/PDIF format and use much more space, so it helps to make the most of hard disk space.
The M4V format also supports chapters, a new menu being added when iTunes detects a track has chapters defined in it - this makes it possible to import a whole album as a continuous DD stream and to access individual tracks as chapters, meaning the audio can play continuously without gaps, gaps being unavoidable if the album is imported as separate tracks.
Unfortunately the M4V format does not support DTS as a codec, they remain only playable in WAV-type PCM files.
How-to:
- make sure you have the ffmpeg command line utility installed.
- get your audio into a continuous raw Dolby Digital stream in a file. If there are multiple audio tracks (e.g. stereo and multichannel versions), make sure they are in separate files.
- prepare your chapter markers in a file, see below for a sample.
- the "fun" bit - create your M4V file with ffmpeg:
Bash:
ffmpeg -i chapters_file.txt -i first_ac3_file.ac3 -i second_ac3_file.ac3 -map 1:0 -map 2:0 -c:a:0 copy -c:a:1 copy -metadata:s:a:0 language=eng -metadata:s:a:1 language=eng -disposition:a:0 default -disposition:a:1 none -f mp4 outfile.m4v
The results will be in "outfile.m4v" which can then be directly imported into iTunes like any other track.
This example is for two Dolby Digital audio streams (each of which will be separately selectable in the iTunes "Audio & Subtitles" submenu when the imported file is played) but it can be adapted for any number. Just add "-i nth_ac3_file.ac3", "-map n:0", "-c:a:n-1 copy", "-metadata:s:a:n-1 language=eng" and "-disposition:a:n-1 default" options as appropriate. Note that the "-disposition" option sets which stream is to be the default, so there should only be one set to "default", all the others should be set to "none". If there is only one audio stream then this option can be skipped. The "-map n:0" options must be in order otherwise the subsequent options will stop working.
Sample "chapters_file.txt" file for ffmpeg, adapt as appropriate. The start and end times are in 100ths of a second.
Code:
;FFMETADATA1
major_brand=M4V
minor_version=0
artist=Pink Floyd
album_artist=Pink Floyd
album=Atom Heart Mother
genre=Rock
compilation=0
gapless_playback=0
[CHAPTER]
TIMEBASE=1/100
START=0
END=21400
title=Rise And Shine
[CHAPTER]
TIMEBASE=1/100
START=21400
END=49800
title=Sunny Side Up
[CHAPTER]
TIMEBASE=1/100
START=49800
END=78000
title=Morning Glory
Make sure that you select "Prefer AC3 Passthrough" in the iTunes "Audio & Subtitles" submenu, and enjoy.
Last edited: