|2006-01-16, 09:41||Link #1|
Join Date: Aug 2004
MP4 "extractor" and AAC encoder/player?
Is there any program that can extract the audio & video components of a mp4 file, like mkvextract does with mkv?
Similarly: is there any program that can encode, load and/or play AAC audio files?
|2006-01-16, 12:23||Link #2|
Join Date: Jan 2001
For MP4, try "mp4box" -- http://www.aziendeassociate.it/cd//gpac/dev/MP4Box.7z
For AAC, you can play them with a recent version of WinAmp afaik, but in case you can't,
you can decode them to WAV with "faad" and possibly some tools from this site: http://dspguru.doom9.net/
|2006-01-17, 09:23||Link #5|
Two bit encoder
Join Date: Jan 2006
Location: Chesterfield, UK
There are a number of ways you can go about extracting AAC from an MP4 file, depending on what outcome you want.
Here are your options:
1) Extract the track to a new MP4 file (containing only the AAC audio)
2) Extract the track to raw AAC (player support might be limited though)
3) Extract the track and encode to WAV (for transcoding to MP3 etc.)
Option 1) is ideal since you don't alter the audio quality, and will be playable as long as you have Haali's MP4 splitter and an AAC audio decoder, like realaac or libfaad2 (as included in FFDShow) or for advanced users there is a seperate CoreAAC decoder (which is based on FAAD2). Option 2) will extract the raw AAC data, which will save you a few KB per file but some players might not handle it. The good news is that you could remux it to MP4 at a later date. Option 3) will have you extract the audio and transcode it to WAV, which allows greater flexibilty should you want to encode it to some other format, for instance Vorbis or MP3. Though this isn't ideal because even as high quality as Vorbis is, you will suffer generation loss from the audio being compressed again.
On with the show. You are probably familliar with CMD, maybe even MP4box, but since this might become a common question in the future, I'll explain it fully so hopefully anyone can follow it.
Before you start:
You will need MP4Box.
As referenced to earlier. This isn't the newest version on the block, but it's recent and stable. A current build had a few bugs so it's better safe than sorry. I don't know specifically what build, but it suggests builds before December 22nd and after 17 January should be OK.
You can also get builds here http://kurtnoise.free.fr/mp4tools/
You will need FAAD2 (Only for Option 3)
FAAD2 is a command line AAC/MP4 audio decoder, this will allow you to convert your AAC audio to WAV (so allowing you to encode it to Vorbis, MP3 or other should you want to).
You can also get it from here: http://rarewares.org/aac.html
Option 1) Extract the track to a new MP4 file
1) For the simplicity of this guide, we will make a folder in C:\ called aacextract and place MP4box and the source MP4 video in it.
2) Start CMD by clicking the Windows start button and then Run, then type CMD. You should get a black window with white text.
3) Now we need to tell CMD where the files are, so type cd C:\aacextract and press enter. This will change the directory, you can now execute the programs by just their filenames rather than typing their full location.
4) Now we need to check the MP4 file to see what the track number of the audio is that we want to extract. In the CMD window you should have something that looks like C:\aacextract>. Now type MP4box.exe -info "filename.mp4". This should bring up a lot of information that looks like this:
C:\aacextract>MP4Box.exe -info "Gundam X - Dreams.mp4" * Movie Info * Timescale 600 - Duration 00:01:17.576 Fragmented File no - 2 track(s) File Brand isom - version 1 File has root IOD Scene PL 0xff - Graphics PL 0xff - OD PL 0xff Visual PL: AVC/H264 Profile (0x15) Audio PL: AAC Profile @ Level 2 (0x29) No streams included in root OD Chapters: Chapter #1 - 00:00:00.000 - "After War Gundam X - Dreams" Track # 1 Info - TrackID 1 - TimeScale 24000 - Duration 00:01:17.577 Media Info: Language "jpn" - Type "vide" - Sub Type "avc1" - 1860 samples MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21 AVC/H264 Video - Visual Size 640 x 480 - Version 1 Profile 0x64 Level 0x33 Self-synchronized Track # 2 Info - TrackID 3 - TimeScale 48000 - Duration 00:01:17.333 Media Info: Language "jpn" - Type "soun" - Sub Type "mp4a" - 3625 samples MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40 MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 48000 Synchronized on stream 1
5) Now we know what TrackID we want, we can proceed to extract it to a new MP4 file. Still using CMD and MP4box, you should now be at C:\aacextract> now all the information has just been shown. To extract a single track to MP4 (remember you can do this to video as well as audio), the switch is -single, followed by the TrackID number. In this case since it is TrackID 3 we want, we would type -single 3. The full command you must type to do this is MP4box.exe -single 3 "filename.mp4". This will create a new, audio only MP4 file, with a new filename suffixed with _track3, so my example of Gundam X - Dreams.mp4 becomes Gundam X - Dreams_track3.mp4 for the audio only MP4.
You're done. Just close CMD and move the files to where you want them as you would normally do.
Option 2) Extract the track to raw AAC
Follow steps 1-4 for Option 1 exactly, and then proceed to this next step, instead of following the previous step 5 (The previous step 5 tells you how to extract to MP4, this step 5 tells you how to extract raw data).
5) Now we know what TrackID we want, we can proceed to extract it to it's raw format. Still using CMD and MP4box, you should now be at C:\aacextract> now all the information has just been shown. To extract a single track to raw (remember you can do this to video as well as audio), the switch is -raw, followed by the TrackID number. In this case since it is TrackID 3 we want, we would type -raw 3. The full command you must type to do this is MP4box.exe -raw 3 "filename.mp4". This will create a new, raw file (ie one that is not in a container format), with a new filename suffixed with _track3, so my example of Gundam X - Dreams.mp4 becomes Gundam X - Dreams_track3.aac for the audio.
As before, it is now complete. Just close CMD and move the files to where you want them as you would normally do.
Option 3) Extract the track and encode to WAV
For this part of the guide, you will also need the FAAD2 command line, you can find the download link earlier in this post. Make sure you also place it in the same folder as MP4box and the source file.
Follow all the steps for Option 1 or Option 2, it doesn't matter which, but do not close the window when it has done extracting the track as raw or MP4. We can use this window to call FAAD to transcode the file. Now proceed with the FAAD2 section.
1) Now that you have an MP4 or a raw aac file, you may convert it to WAV using the program called FAAD. You should now be back at C:\aacextract>. Type faad.exe "filename_tracknumber.mp4". That's all you need to do, it will now create a WAV file from your MP4 or raw AAC. Going back to my example of Gundam X, if you had just followed Option 1 and you wanted to convert this file you type faad.exe "Gundam X - Dreams_track3.mp4" (since that was the filename that MP4box created for the output).
If you are familliar with batch files, or very lazy, you could shorten all of Option 3 to this.
@ECHO OFF MP4box.exe -single 3 "Gundam X - Dreams.mp4" FAAD.exe "Gundam X - Dreams_track3.mp4" del "Gundam X - Dreams_track3.mp4" PAUSE
Would be interesting to hear which option you go for in the end (I'll be dissapointed if you are re-encoding(!))
Last edited by Zero1; 2006-01-17 at 10:30.
|2006-01-18, 09:42||Link #6|
Join Date: Aug 2004
zero1, I'm reading your edited post at the moment of writing of this post. I'll still deciding on what option to use. I'll reply to you later when I have the time.
Last edited by tugatosmk; 2006-01-18 at 09:52.