<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Diego's Rants &#187; aac</title>
	<atom:link href="http://blog.massanti.com/tag/aac/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.massanti.com</link>
	<description>Confessions from a Geek</description>
	<lastBuildDate>Wed, 27 Oct 2010 11:22:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Updated HE-AAC (aacPlus) reference encoder for Mac OS X</title>
		<link>http://blog.massanti.com/2009/12/07/updated-he-aac-aacplus-reference-encoder-for-mac-os-x/</link>
		<comments>http://blog.massanti.com/2009/12/07/updated-he-aac-aacplus-reference-encoder-for-mac-os-x/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 00:10:55 +0000</pubDate>
		<dc:creator>Diego Massanti</dc:creator>
				<category><![CDATA[Apple / Macintosh]]></category>
		<category><![CDATA[Audio Tech]]></category>
		<category><![CDATA[Computers & Tech]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[aac]]></category>
		<category><![CDATA[aacPlus]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[encoding]]></category>

		<guid isPermaLink="false">http://blog.massanti.com/?p=1038</guid>
		<description><![CDATA[This is an updated build of the 3GPP group AAC Plus (or HE-AAC) reference audio encoder for Mac OS X 10.5 &#8220;Leopard&#8221; or newer. You can get the binary build (3 way universal binary with PowerPC, i386 and x86_64 architectures) here: enhAacPlusEnc for Mac OS X Leopard, Binary build with 3 architectures. Xcode project (3.2 [...]]]></description>
			<content:encoded><![CDATA[<p>This is an updated build of the 3GPP group AAC Plus (or HE-AAC) reference audio encoder for Mac OS X 10.5 &#8220;Leopard&#8221; or newer.</p>
<p>You can get the binary build (3 way universal binary with PowerPC, i386 and x86_64 architectures) here:</p>
<p><a href="http://blog.massanti.com/wp-content/uploads/2009/12/enhAacPlusEnc.zip">enhAacPlusEnc for Mac OS X Leopard, Binary build with 3 architectures.</a></p>
<p>Xcode project (3.2 or newer) can be downloaded here:</p>
<p><a href="http://blog.massanti.com/wp-content/uploads/2009/12/enhAacPlusEnc1.zip">enhAacPlusEnc Xcode project (3.2 or newer)</a></p>
<p>For more info visit the original post <a href="/2007/09/30/he-aac-plus-encoder-mac-universal-binary/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.massanti.com/2009/12/07/updated-he-aac-aacplus-reference-encoder-for-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HE-AAC Plus encoder for Mac (Universal Binary)</title>
		<link>http://blog.massanti.com/2007/09/30/he-aac-plus-encoder-mac-universal-binary/</link>
		<comments>http://blog.massanti.com/2007/09/30/he-aac-plus-encoder-mac-universal-binary/#comments</comments>
		<pubDate>Sun, 30 Sep 2007 16:51:15 +0000</pubDate>
		<dc:creator>Diego Massanti</dc:creator>
				<category><![CDATA[Apple / Macintosh]]></category>
		<category><![CDATA[Computers & Tech]]></category>
		<category><![CDATA[aac]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[encoder]]></category>
		<category><![CDATA[enhAacPlusEnc]]></category>
		<category><![CDATA[he]]></category>
		<category><![CDATA[intel]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[plus]]></category>
		<category><![CDATA[powerpc]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[universal]]></category>
		<category><![CDATA[v2]]></category>

		<guid isPermaLink="false">http://massanti.com/2007/09/30/he-aac-plus-encoder-mac-universal-binary/</guid>
		<description><![CDATA[This post is outdated, for a more up to date version of both the binary encoder and the sources, please visit this new post. I needed a native solution to encode HE-AAC Plus audio on a Mac, but there is not any native solution so far right now, so i compiled the reference encoder (enhAacPlusEnc) [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>This post is outdated, for a more up to date version of both the binary encoder and the sources, please <a href="/2009/12/07/updated-he-aac-aacplus-reference-encoder-for-mac-os-x/">visit this new post</a>.</p></blockquote>
<p>I needed a native solution to encode HE-AAC Plus audio on a Mac, but there is not any native solution so far right now, so i compiled the reference encoder (enhAacPlusEnc) published by the <a href="http://www.3gpp.org/">3GPP group</a>.<br />
I also created an xCode project to make it easy to manage future builds.<br />
This is an &#8220;Universal Binary&#8221; build, meaning that it will work on both, Intel based and PowerPC based Macs.</p>
<p>You can download the universal binary encoder by clicking <a href="http://blog.massanti.com/tools/enhAacPlusEnc.zip">here</a>, and you can download the xcode project by clicking <a href="http://blog.massanti.com/tools/enhAacPlusEnc.xcodeproj.zip">here</a>.</p>
<p>Keep in mind that i had to make some minor modifications in order to make it compile as Universal Binary, so you wil find some minor diferences when comparing with the original source code released by the 3GPP group.</p>
<p>If you have any question, leave a comment here.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.massanti.com/2007/09/30/he-aac-plus-encoder-mac-universal-binary/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Creating good quality h264 video for the upcoming Flash Player and Flash Media Server</title>
		<link>http://blog.massanti.com/2007/09/28/encoding-h264-video-aac-plus-audio-for-flash/</link>
		<comments>http://blog.massanti.com/2007/09/28/encoding-h264-video-aac-plus-audio-for-flash/#comments</comments>
		<pubDate>Fri, 28 Sep 2007 11:04:42 +0000</pubDate>
		<dc:creator>Diego Massanti</dc:creator>
				<category><![CDATA[Apple / Macintosh]]></category>
		<category><![CDATA[Video Encoding]]></category>
		<category><![CDATA[aac]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[h264]]></category>
		<category><![CDATA[high]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[quality]]></category>
		<category><![CDATA[stream]]></category>
		<category><![CDATA[streamming]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://massanti.com/2007/09/28/encoding-h264-video-aac-plus-audio-for-flash/</guid>
		<description><![CDATA[Important This tutorial has been updated (and improved) a lot, for the new version please follow this link. UPDATE: I realized that when i read a tutorial about anything, in most cases, i want to first see what result im going to get so then i can decide if the tutorial is worth reading (or [...]]]></description>
			<content:encoded><![CDATA[<blockquote class="warning">
<h3>Important</h3>
<p>This tutorial has been updated (and improved) a lot, for the new version please follow <a href="http://massanti.com/2008/01/01/encoding-h264-aacplus-with-mencoder-for-flash/">this link</a>.
</p></blockquote>
<blockquote><p>UPDATE: I realized that when i read a tutorial about anything, in most cases, i want to first see what result im going to get so then i can decide if the tutorial is worth reading (or not), so here is a head by head comparison: </p>
<p>This is an h264 file encoded by the guys at apple.com, it&#8217;s the TV Commercial for the brand new iMac: <a href="http://movies.apple.com/movies/us/apple/mac/imac/2007/apple_solar_20070820_848x480.mov" rel="shadowbox[post-15];width=640;height=385;">ORIGINAL VIDEO</a></p>
<p>This is the same file re-encoded using the steps on this tutorial: <a href="http://plusmediaserver.com/media/new_imac_2007.mp4">RE-ENCODED VIDEO</a></p>
<p>Obviouisly, there is an small quality degradation, but keep in mind that apple&#8217;s original movie is 14MB in size, while mine is <strong>1.5MB</strong> <img src='http://blog.massanti.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .<br />
You can play my MP4 video with almost any video player out there, but remember that <strong>not all video players out there support HE-AAC audio (or aacPlus) and b-frames</strong>, so if you play the file with a player like QuickTime, <strong>it is NOT going to work</strong>.<br />
I recommend <a href="http://www.mplayerhq.hu/">mPlayer</a> or <a href="http://www.videolan.org/vlc/">VLC media player</a> to play this kind of video, and obviously, Flash Player will play the file perfectly too.
</p></blockquote>
<blockquote class="mac"><h3>Update for Macintosh users:</h3>
<p>I updated the bash script on this post so it can be used also by Macintosh users, so instead of using the NERO Digital AAC Encoder, Macintosh users can take advantage of the native 3GPP AAC Plus V2 encoder that i just compiled. Visit <a href="http://massanti.com/2007/09/30/he-aac-plus-encoder-mac-universal-binary/">this post</a> for more information about it.</p></blockquote>
<p>Like a lot of people out there, i was really happy when i found the <a href="http://www.adobe.com/aboutadobe/pressroom/pressreleases/200708/082107FlashPlayer.html">press release from Adobe</a>, stating the addition of h.264 video support and HE-AAC Plus audio to their <a href="http://labs.adobe.com/downloads/flashplayer9.html">upcoming Flash Player</a> versions, and also, to the upcoming Flash Media Server.<br />
After following several &#8220;Tutorials&#8221; all over the web, i found that there was not any single one that gave me the results that i wanted; that is, good video quality, with the less possible file size, so after a lot of trial and error and after a lot of help and optimizations by the guys at the ffmpeg and x264 IRC channels, i decided to create this tutorial that will most probably help you a lot to encode good quality h264 video, with HE-AAC Plus Audio, and all this inside an MP4 container with tags and all ready to deliver to your visitors.</p>
<p>There are several things that you will need in order to do this:</p>
<ul>
<li>The latest <a href="http://wiki.videolan.org/Subversion">SVN version of the x264 video codec</a>.</li>
<li>The latest <a href="http://ffmpeg.mplayerhq.hu/download.html">SVN version of the excellent ffmpeg video encoding utility</a>.</li>
<li>The <a href="http://gpac.sourceforge.net/home_download.php">latest version of the GPAC utilies</a> (it contains several tools to mux and work with MP4 files).</li>
<li>The <a href="http://www.nero.com/nerodigital/eng/down-ndaudio.php">linux version of the Nero Digital AAC Audio Encoder</a></li>
<li>GCC 4.1 or later installed, this is a requeriment for x264 to encode faster. It WILL work if you compile with older versions of GCC, but you will have performance issues resulting in more time needed to compress the video streams.</li>
</ul>
<p><span class="info"><strong>Some friendly bookmarks:</strong><br />
SVN checkout for x264:<br />
<code>svn checkout svn://svn.videolan.org/vlc/trunk vlc-trunk</code><br />
SVN checkout for ffmpeg:<br />
<code>svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg</code></span></p>
<p>First of all, I&#8217;m assuming that you are running Linux, Mac-OS X or any other UNIX variant. I never tried this on windows because I am pretty sure that there are lot of really nice programs that you could buy to do the job.<br />
<span id="more-15"></span><br />
<strong>Step 1: Configuring, compiling and installing all the stuff.</strong></p>
<p>I am assuming that you have some basic skills with Linux / Unix / Mac OS, so i won&#8217;t really digg into the details of how to compile from sources all the tools. In most cases just taking a look at the readme file for each piece of software will tell you all you need to know, so i will just explain here some basical tips that you need to know.<br />
After configuring, building and installing the x264 codec, this is the configure line that i used for ffmpeg in my paticular case:</p>
<p><code>./configure --enable-libx264 --enable-libfaac --enable-gpl --prefix=/usr --enable-libfaad --enable-swscaler --enable-pp</code></p>
<p>All the settings there are self-explanatory, the only thing you could need to change is the prefix to something like <strong>&#8211;prefix=/home/yourusername/</strong> if you prefer to install the software just for your own user account.<br />
After you have ffmpeg installed and running, we need to install two more things, the GPAC utilities and the Nero Digital AAC Audio Encoder.<br />
Go <a href="http://gpac.sourceforge.net/home_download.php">grab the latest sources for GPAC</a>, do the usual:</p>
<p><code>./configure &amp;&amp; make &amp;&amp; make install</code></p>
<p>After that you are ready to go, then go and <a href="http://www.nero.com/nerodigital/eng/down-ndaudio.php">download the latest version of the Nero encoder</a>, and you will notice a directory called &#8220;linux&#8221; inside it, you should copy all the files there to any location in your path, usually /usr/bin (if you are installing everything as root) or /home/yourusername/bin (if you are installing just for your user account).</p>
<p><strong>Step 2: Checking that everything is working as supposed.</strong></p>
<p>To check that everything is ok, you should type:</p>
<p><code>ffmpeg -formats</code></p>
<p>and you will get a LONG list of supported encoders and decoders, if you have the following line, you are ready to go:</p>
<p><code> EV    libx264</code></p>
<p><strong>Step 3: Doing the video encoding (or transcoding).</strong></p>
<p>So everthing looks great so far, except for one little detail, there is actually no support for any HE-AAC encoder directly from inside ffmpeg, so we will do the encode in 2 phrases, first the video, and then the audio.</p>
<p>From now on, i will assume that we have a video called &#8220;movie.avi&#8221; that we want to convert to a Flash Ready h264 file, so lets start encoding the video.<br />
I am a person who likes quality, so for this example I am going to use a 2 pass encoding process.</p>
<p>This is the command line to perform the first pass of the video encoding:</p>
<p><code>ffmpeg -y -i movie.avi  -an <strong>-pass 1</strong> -vcodec libx264 -b 384k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 384k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.8 -qmin 10 -qmax 51 -qdiff 4 movie_temp.mp4</code></p>
<p>Depending on how long is your video source and how powerful is your computer, after some minutes it should finish, so it is time to make the second pass of the video encoding:</p>
<p><code>ffmpeg -y -i movie.avi  -an <strong>-pass 2</strong> -vcodec libx264 -b 384k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 384k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.8 -qmin 10 -qmax 51 -qdiff 4 movie_temp.mp4</code></p>
<p>This pass is gonna take more time than the first one, because the first one just analyzes the video while the 2nd pass does the actual encoding.</p>
<p>IF everything went as supposed, after some time you should have a new file called &#8220;movie_temp.mp4&#8243; and you will notice that it is just your movie, but without sound&#8230;. dont alarm! we are going to make the sound part right now.</p>
<p><strong>Step 4: Doing the audio encoding.</strong></p>
<p>This part is pretty simple, we will use ffmpeg to create a simple wav file because the nero encoder only accepts a wav file as input, so we will do:</p>
<p><code>ffmpeg -i movie.avi -ar 48000 -ac 2 movie_temp_audio.wav</code></p>
<p>After this finishes, you will have a wav file called &#8220;movie_temp_audio.wav&#8221; that should be playable in any audio player of your choice, it basically contains the audio of your movie, so let&#8217;s transform this to a shiny HE-AAC Plus audio file.</p>
<p>To convert the wav audio file into an HE-AAC Plus file, we will use the Nero Encoder (neroAacEnc) and we will tell it to use our recently created wav file as source and output it to a new audio only mp4 file called &#8220;movie_temp_audio.mp4&#8243; like this:</p>
<p><code>neroAacEnc -br 48000 -he -if movie_temp_audio.wav -of movie_temp_audio.mp4</code></p>
<p>So ok, we have at this point one MP4 file with just video, and another MP4 file with just audio, lets mux all this into our final flash ready MP4.</p>
<p><strong>Step 5: Muxing everything into our final MP4 file ready for Flash broadcast.</strong></p>
<p>At this point we are going to use a program called &#8220;MP4Box&#8221; that is part of the GPAC utilities that you have already installed if you followed my instructions.</p>
<p>First, we will command MP4Box to add <strong>ONLY</strong> the video track of our first <em>video only</em> MP4 into our final MP4:</p>
<p><code>MP4Box -add movie_temp.mp4#video final_movie.mp4</code></p>
<p>This will create a new MP4 file called &#8220;final_movie.mp4&#8243;, and it will add our video track inside it. Now we need to add the audio track into our final movie file, to do that we do as follows:</p>
<p><code>MP4Box -add movie_temp_audio.mp4#audio final_movie.mp4</code></p>
<p>After this step, if you open your &#8220;final_movie.mp4&#8243; file with some video player like QuickTime, mPlayer or VLC, you should have a brand new h264 file with both video and audio, and with perfect sync between the two.<br />
We need now to do some extra steps to optimize the file for progressive HTTP streaming so the flash player doesn&#8217;t needs to download the whole file before starting to play it, so lets interleave our file:</p>
<p><code>MP4Box -inter 500 final_movie.mp4</code></p>
<p>This line will interleave meta information to the file every 500 msec, that way, the flash player will be able to play the file as soon as it gets the first 500msec of video data.</p>
<p>After you are satisfied with your result, you can simply type:</p>
<p><code>rm movie_temp* -f</code></p>
<p>to get rid of all the temporal files that you created.</p>
<p>Obviously, this involves a LOT of steps in order to create the final file, and it is good to make them one by one so you get an idea of what are you doing&#8230;. after all, the idea is to learn&#8230;. isn&#8217;t it ?<br />
But as you may suppose, the logical step after doing the &#8220;manual&#8221; way, is to create a bash script that is gonna do everything for us, so i give you below, an example of how this script could look:</p>
<pre><code class="bash">#! /bin/bash
# ${foo%.*} to remove the extension
# FIRST PASS
echo "Starting Pass 1 ! ! !"

ffmpeg -y -i $1 -an -pass 1 -vcodec libx264 -b 384k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 384k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.8 -qmin 10 -qmax 51 -qdiff 4 ${1%.*}_temp.mp4

# SECOND PASS
echo "Starting pass 2 ! ! !"

ffmpeg -y -i $1 -an -pass 2 -vcodec libx264 -b 384k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 384k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.8 -qmin 10 -qmax 51 -qdiff 4 ${1%.*}_temp.mp4

# Exporting audio to a temporal 48k WAVE file
ffmpeg -y -i $1 -ar 48000 -ac 2 ${1%.*}_temp_audio.wav

# Encoding audio to HE-AAC V2 (aacPlus SBR + PS) -- UNCOMMENT THE FOLLOWING LINE on LINUX / UNIX with the NERO encoder
neroAacEnc -br 48000 -he -if ${1%.*}_temp_audio.wav -of ${1%.*}_temp_audio.mp4

# Encoding audio to HE-AAC V2 (aacPlus SBR + PS) -- UNCOMMENT THE FOLLOWING LINE on Mac OS X and remember to comment the LINUX one:
# enhAacPlusEnc ${1%.*}_temp_audio.wav ${1%.*}_temp_audio.aac 48000 s

#Creates final MP4 container and adds video track...
MP4Box -add "${1%.*}_temp.mp4#video" ${1%.*}_flash_ready.mp4

#Adds audio track...
# IMPORTANT: If running this script on LINUX, UNCOMMENT THIS line:
MP4Box -add "${1%.*}_temp_audio.mp4#audio" ${1%.*}_flash_ready.mp4

# IMPORTANT:if running this script on a MAC, UNCOMMENT THIS line and remember to comment the LINUX one:
#MP4Box -add "${1%.*}_temp_audio.aac" ${1%.*}_flash_ready.mp4 

#Sets MetaData...
MP4Box -lang English ${1%.*}_flash_ready.mp4

#Interleaving (For HTTP Streming... this should be removed if using FMS / RTMP )
MP4Box -inter 500 ${1%.*}_flash_ready.mp4

echo "Deleting Temporary Files..."
rm ${1%.*}_temp* *.log -f

echo "DONE!"
echo "Your file has been encoded as ${1%.*}_flash_ready.mp4"</code></pre>
<p>You should make a file called, for example, mkmp4.sh and paste the script inside it, then chmod +x the file and move it to /usr/bin , after that, you should be able to run for example:</p>
<p><code>mkmp4 mymovie.avi</code></p>
<p>and the bash script will create a new file called mymovie_flash_ready.mp4 in the same directory, that assuming that you have all the needed tools in the path.</p>
<p>So happy encoding! if you have any questions or any problem, please post a comment here and i will try to help you as soon as i can. Please avoid to post questions about how to build / configure / compile software because i don&#8217;t really have the time to help you with that and there are a lot of tutorials for that on the web, and like i said, this tutorial assumes that you have the basic linux skills already inside your little brain.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.massanti.com/2007/09/28/encoding-h264-video-aac-plus-audio-for-flash/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
<enclosure url="http://movies.apple.com/movies/us/apple/mac/imac/2007/apple_solar_20070820_848x480.mov" length="13824259" type="video/quicktime" />
<enclosure url="http://plusmediaserver.com/media/new_imac_2007.mp4" length="1597936" type="video/mp4v-es" />
		</item>
	</channel>
</rss>

