First thing first, I have an Ubuntu 9.04 system running in 64-bit. I installed my ffmpeg from my posts (search ffmpeg, last posting). I am using an Intel Core2 Dou (not that this should matter).
Ok let's get started. Let's say my video is called Transformers2.mkv (Again, this is just an example, I love this movie). Also I am doing everything on the DESKTOP [/home/USER/Desktop]
Step 1. Installing additional apps using apt-get
Step 2. Reading the MKV file to see what you have.
sudo apt-get install mkvtoolnix gpac hexedit mplayer
NOTE: write down the FRAME rate of the video it might be weird like 23.976 or whatever, you will need it at the end.
NOTE: When you run this command you will see which tracks the video has. Let's say in my case Track 1 is the h.264 portion and Track 2 is the audio.
Step 3. Separate the tracks. This will not eat up your CPU but your disk will run wildly.
Step 4. HEXEDIT the video file to be compatible with iTunes [m4v/mp4]
mkvextract tracks Transformers2.mkv 1:video.h264 2:audio.ac3
On the first line you should see this number combination:
"67 64 00 33"
change this to:
"67 64 00 29"
NOTE: This might not be exactly what you see but close. In my case let's say it was already what it needed to be changed to.
Step 5. Converting the Audio to AAC3 compatible. MKV's typically encoded with audio that just won't work with iTunes so we need to convert it to the something that it will understand. I am going to use ffmpeg to convert the audio.
Step 6. Combining the video and audio tracks. Now here is where you need the frame rate from above.
ffmpeg -i audio.ac3 -acodec libfaac -ar 48000 -ab 448k -ac 6 -threads 0 audio.m4a
Now once this is finished you should have a compatible video that will drag and drop right into iTunes. The video will not be much smaller then the original MKV as we did not convert or shrink the video just the audio. Check the beginning of the video or sync of sound and then the end of the video. It took me a couple of tries to get it in sync and also sounding really good. Have fun and hope this helps everyone out there.
MP4Box -add video.h264 -add audio.m4a -fps 23.976 Transformers2.mp4
Just a reminder I do not endorse stealing movies or ripping them, I just like to solve puzzles.