Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264
Register FAQ Calendar Today's Posts Search

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 11th November 2005, 01:16   #1  |  Link
Randall
Registered User
 
Randall's Avatar
 
Join Date: Sep 2005
Location: Norwood, MA
Posts: 175
REAL Ultimate Guide to x264 and QuickTime!!!

Here is a guide I have compiled for a successful encodes of x264 that will work on QuickTime 7. A lot of people on these boards don't (and shouldn't if they don't need to) care about QuickTime functionality for their H.264/AVC encodes. But if you do care, here is a detailed step-by-step guide for a successful H.264 encode for QT. This guide is for Windows, but the x264 command lines can be used with Mac OS X just as well.

Before we get started, you should know that QuickTime is fussy when it comes to x264 playback. First of all QT doesn't support anything above Main Profile, meaning that it's built in decoder WILL support multipass, max 2 B-Frames, B-References, Adaptive Quant, multiple slices, CABAC, etc. Essentially everything in the Main Profile settings with some exceptions.

QuickTime WILL NOT support 8x8 dct and intra prediction, b-pyramids, lossless encoding, etc. As well as anything from the High Profile.

That said, you can still get an excellent looking encode if you follow this guide. This guide is assuming that you have a Full Screen (4:3) DVD vob file that is formatted in NTSC (29.970 FPS) and is fully Progressive Scan.

Weapons and Gear:
DVD Decrypter (get .VOB files from DVD)
DGIndex (for .d2v project file and .AC3 dolby audio de-muxer)
BeSweet (audio encoding)
Nero 7 (Aac.dll and aacenc32.dll) or faac for ACC audio encoding
AVIsynth (frame server for almost unlimited ways of editing and processing your video)
x264 Full package (for encoding H.264/AVC video) Sharktooth's latest build also comes with the x264 stripped down version of the MeGUI front end
MeGUI (Encoding front end that will help you automate the encoding process and edit Command Line parameters. Full Version)
MP4Box (tool for muxing audio and video with MPEG-4 compliant container)

Now let's begin the 7 (6) simple steps to making a sweet encode that will be playable in QuickTime 7.0.3.

1) Rip the .vob(s) to your hard drive with DVD Decrypter

2) Use DGIndex to make a .d2v project file. Select your .vob file(s) you have, open with DGIndex, press F4, save your .d2v file and you will also get a de-muxed AC3 audio file.

3) Create an AVIsynth script to serve up to x264. if you have some of the extra plugins for AVIsynth, you can certainly use those as well. Here is my example for a NTSC 29.97 FPS Progressive Scan Video this format is ideal, we don't need to do anything except resize and clean:
Code:
# LOAD THE PLUGINS
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE3.dll")

# VIDEO SOURCE
mpeg2source("C:\VIDEO_TS\test.d2v")

# CROP THE IMAGE
crop(42,0,636,480)

# RESIZE (SHARP) FULLSCREEN SOURCE
LanczosResize(512,384)

# CLEAN THE PICTURE
RemoveGrain(mode=1)
Here is my example for a NTSC 29.97 FPS Teleclined Video (we use Telecide filter to pull down the frame rate to 23.976 FPS, so be aware of the frame rate change) This will remove the Teleclined mice teeth artifacts that were left behind (common on The Simpson’s as well as the Seinfeld DVDs, and many many other 'made for TV' programs):
Code:
# LOAD THE PLUGINS
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\decomb.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE3.dll")

# VIDEO SOURCE
mpeg2source("C:\VIDEO_TS\test.d2v")

# INVERSE TELECLINE OPTIONS 
Telecide(guide=1).Decimate()

# CROP THE IMAGE
crop(42,0,636,480)

# RESIZE (SHARP) FULLSCREEN SOURCE
LanczosResize(512,384)

# CLEAN THE PICTURE
RemoveGrain(mode=1)
Here is my example for a NTSC 29.97 FPS Interlaced Video Some DVDs never even bother to deinterlace the source, relying on your Progressive Scan DVD players to do the dirty work for you. Unfortunately we can't use a hardware deinterlacer, but TDeint and BlendBob are some fine filters that will do it for us.:
Code:
# LOAD THE PLUGINS
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\TDeint.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\BlendBob.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE3.dll")

# VIDEO SOURCE
mpeg2source("C:\VIDEO_TS\test.d2v")

# DEINTERLACE OPTIONS
TDeint(mode=1,order=1,mtnmode=1)
BlendBob()

# CROP THE IMAGE
crop(42,0,636,480)

# RESIZE TO FULLSCREEN 4:3 ASPECT RATIO
LanczosResize(512,384)

# CLEAN THE PICTURE
RemoveGrain(mode=1)
All of these avisynth filters can be downloaded at http://www.avisynth.org/warpenterprises/ if you don't have them. Make sure you give them the proper path when you LoadPlugin("Path to your plug-in here"). Now we save one of these three options as an avisynth filter file named template.avs or whatever you would like. Make sure that you change the filenames and paths used to the correct ones, or avisynth will b0rk when you try to start encoding.


4) Go back and encode the audio now. take the .AC3 dolby de-muxed audio file that was created back in step 2, and transcode it using BeSweet. In my example I use the Nero HE-AAC profile, so you will need to copy Aac.dll and aacenc32.dll from the C:\Program Files\Common Files\Ahead\AudioPlugins\ directory into your BeSweet directory. If you would like to use the Nero AAC Encoder completely independent of Nero 7, then you will also need to add the NeroIPP.dll to your BeSweet directory. That file should be located in the C:\Program Files\Common Files\Ahead\Lib\ directory. The command line that I use for AAC encoding is:
Code:
BeSweet.exe -core( -input "test 2_0ch 192Kbps DELAY 0ms.ac3" -output "test T01 2_0ch 192Kbps.m4a" -logfile "test T01 2_0ch 192Kbps DELAY 0ms.log" ) -azid( -n1 -s stereo -c normal -L -3db ) -bsn( -2ch -vbr_streaming -codecquality_high -aacprofile_he ) -ota( -d 0 -g max )
You can also use the full version of MeGUI as a front end to this BeSweet command line. I recommend using MeGUI, as it's a bit easier to achieve the same results. You can download the latest version on this thread MeGUI .

5) Here is where we set up MeGUI to give ourselves a nice looking x264 video encode in an mp4 container. This part is key, as I have had some problems with certain settings for x264 (as far as QuickTime playback is concerned). I like to use 3-pass encoding, using slow RDO (level 6) to give the best possible looking rip we can make that is still playable in QT. I would post the exact settings that you should use here, but it is up to you on what settings you prefer. Remember that QuickTime is extremely picky on which x264 commands you can actually use out of the Main Profile. You cannot use b-pyramid in QuickTime! Here are my x264 command lines, so that you can make a batch file out of them if you wish. These settings are tested and proven to be 100% QuickTime compatible. About these settings: (pass 1 writes a stats file, pass 3 is also known as Nth pass, which will read the current stats file, and re-write the stats file upon completion of the pass, as well as output to the video file. The pass-2, also known as FINAL pass, will read the stats file and output to your final video .mp4 file. Pass-2 will not update the stats file, so make sure that pass-2 is only used on a final pass!) This is confusing, as the actual order of the passes will go as 1, 3, 2. (First, Nth, Final). To avoid confusion (too late ) you could use the "--pass 3" option for your Nth and your final passes (1, 3, 3). This practice is used in MeGUI under 'Automated 3-Pass' settings. So don't panic if you never see "--pass 2" in your command line when using MeGUI's Automated 3-Pass.
Code:
x264.exe --pass 1 --bitrate 839 --stats "test.stats" --bframes 2 --subme 6 --analyse p8x8,b8x8,i4x4,p4x4 --me esa --progress --no-psnr --output NUL "template.avs"  

x264.exe --pass 3 --bitrate 839 --stats "test.stats" --bframes 2 --subme 6 --analyse p8x8,b8x8,i4x4,p4x4 --me esa --progress --no-psnr --output "test.mp4" "template.avs" 

x264.exe --pass 2 --bitrate 839 --stats "test.stats" --bframes 2 --subme 6 --analyse p8x8,b8x8,i4x4,p4x4 --me esa --progress --no-psnr --output "test.mp4" "template.avs"
6) *NOTE* I have given you an example of 3-pass encoding, which takes a very long time, and some people may not have the patience to wait for it. In my opinion, waiting once for a quality video encode that you can enjoy again and again is always worth it. That said, you can do 2-pass encoding if you wish, simply by removing the second line in my x264 command file. 3-pass encoding is going to take a long time to complete, but it will definitely be worth the wait. Crack open a beer and watch the game, then come back when encoding is complete.

7) Finally! the last step is multiplexing the audio and video feeds together. MP4Box by default likes to mux at an assumed frame rate of 25 fps. We're gonna have to tell it otherwise in our case (NTSC 29.970 FPS). If you used a Teleclined or an Interlaced source that has been decimated, then your source is now 23.97 FPS, so make the appropriate changes to this next command. Here is the command line for muxing the audio and video feeds together on a Progressive source!
Code:
MP4Box.exe -fps 29.970 -add "test.mp4" -add "test.m4a" "final_video.mp4"
Congratulations, if all went well you should have a usable video encode playable in QuickTime 7. Now that's what I call REAL Ultimate Power!!!! I hope that this guide has helped you make QuickTime compatible H.264/AVC MPEG-4 files. I wish that the steps to take will be more automated in the future (less command line stuff). MeGUI is shaping up to be a solid front end to encoding that will help to do just that. Thanks to everyone who worked on these excellent encoding tools, and thanks to the help of all the other people on this forum who helped me with this. And thanks to Doom9.net - The definitive DVD backup resource. *NOTE* I have tested up to 2 B-Frames successfully in QuickTime 7.0.3, I am not certain if you can do more B-Frames then that, but I know that you can do at least that many. Also, for some reason, the mp4 output from x264 won't play (nothing displayed on screen) until you mux it with the audio using MP4Box. I would guess that this is yet another QT bug.

*UPDATE* Despite Sharktooth's strong dislike for QuickTime, he was kind enough to supply us with some useful presets that can be used in MeGUI for full QuickTime compatibility. While the preset settings are 100% compatible with QuickTime, you are not limited to using just those. Remember that you can use up to 2 b-frames, multipass and exhaustive searches in QuickTime too, like my command line examples above. You can find Sharktooth's x264 MeGUI presets available for download here.


Q and A:.

Q: Why is everyone so obsessed about getting their video to work in QuickTime?

A: QuickTime is the ultimate paradox. On the one hand QuickTime doesn't give a crap, but on the other hand, QuickTime can be very careful and precise.

Q: I heard that QuickTime totally sucks. What's Apple's problem?

A: Whoever told you that is a total liar. Just like other media players, QuickTime can suck OR be totally awesome.

Last edited by Randall; 4th December 2006 at 19:19.
Randall is offline   Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:38.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.