http://aflux.deltaanime.net/Zero1/MP4/x264.html
Mostly complete but not polished up. I basically need to check that I haven't said anything misleading (I started writing this guide in something like November 2005) and that what I say makes sense (haven't even proof read it yet).
It covers encoding of video to H.264 using x264. You will have to check out audio encoding yourself, but I advise you use LC-AAC, and for that, iTunes is one of the best encoders (believe it or not). If you have the Nero burning ROM suite, that also has an AAC encoder, but do not use high efficiency. It's sort of false economy. It leads you to think it uses some advanced compression features, but it basically cuts the audio at 22.05KHz or 24KHz (depending on whether the source is 44.1 or 48KHz) and interpolates/reconstructs on playback. Often it sounds like the midrange is missing to me.
So when you have your audio and x264 script/batch, you will need to mux using mp4box. The most simple command line is:
- Code: Select all
mp4box -add "video.264" -add "audio.aac" -fps 23.976 "output.mp4"
Remember to change the FPS to what suits your video. You can also do stuff like name the tracks by adding:
- Code: Select all
:name="Name of track"
Similarly, if you are adventurous enough to try anamorphic editing/encoding, here you can specify the aspect ratio too. It works in a similar way to adding the name to the track:
- Code: Select all
:sar=40:33
Also you can define the language of the tracks, say for instance you have Japanese audio, or for a multi track video, you can give each track it's own language. This is done in a similar way:
- Code: Select all
:lang=eng or :lang=jpn
To add multiple tracks, it's simple. Just put an "-add" line in for the track you want to include, for example;
- Code: Select all
mp4box -add "video.264" -add "audioeng.aac" -add "audiojpn.aac" -fps 23.976 "output.mp4"
Now we can put these together. Just like in my guide, it's as simple as building something with Lego. The final product can be huge and complex, but if you handle it a brick at a time and build it up in steps, it's easy. These commands for naming tracks etc, essentially stack up on eachother. If we put the whole command line together now, it might look like this:
- Code: Select all
mp4box -add video.264:par=40:33:lang=jpn:name="H.264 High Profile - 16/9" -add audioeng.aac:lang=eng:name="LC-AAC Stereo" -add audiojpn.aac:lang=jpn:name="LC-AAC Stereo"-fps 23.976 output.mp4
Now a couple of tips. If you followed my guide and put your files to be encoded/muxed in the same folder as mp4box and x264, then you can use short filenames, otherwise you need to specify the full path when muxing, for example:
- Code: Select all
mp4box -add "E:\AMV\encodes\video.264" -add "E:\AMV\encodes\audio.aac" -fps 23.976 "E:\AMV\encodes\output.mp4"
Also if you did store the files in the same place as mp4box, but
do not have spaces in the filenames, you can refer to the files without the "":
- Code: Select all
mp4box -add video.264 -add audio.aac -fps 23.976 output.mp4
I use batches a lot, but for muxing I tend to type the mp4box command by hand. Another tip is that in your command shell you can begin to type the first few letters of the filename and press tab for completion (just like in IRC for peoples nicknames). If you get the wrong file, just tab again to cycle through the matches.
Any problems contact me in the #AMV IRC channel. Any comments, complaints, suggestions are greatly appreciated. Either way, should you do this, I'd like to hear how you went on.
If however you use some of the examples I wrote here and you find they don't work, don't be too surprised, I wrote this off the top of my head without referring to mp4box, but it should be accurate. To view all the options in mp4box, type:
- Code: Select all
mp4box -h all