Archive:HOW-TO:Encode H.264 Videos Compatible With XBMC For Xbox: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>JPSiemer
No edit summary
>JPSiemer
No edit summary
Line 23: Line 23:
12. For the Video Profile, we will configure our own. This is the trick to getting H.264 to play nicely with XBMC. So configure your own video profile with the following settings:
12. For the Video Profile, we will configure our own. This is the trick to getting H.264 to play nicely with XBMC. So configure your own video profile with the following settings:


program --pass 2 --bitrate 1343 --stats ".stats" --level 4.1 --keyint 240 --min-keyint 24 --ref 5 --no-fast-pskip --bframes 6 --b-rdo --weightb --subme 7 --trellis 2 --partitions p8x8,b8x8,i4x4 --ratetol 20.0 --me umh --merange 32 --threads auto --thread-input --progress --no-psnr --no-ssim --output "output" "input"  
program --pass 2 --bitrate XXXX --stats ".stats" --level 4.1 --keyint 240 --min-keyint 24 --ref 6 --no-fast-pskip --bframes 6 --b-rdo --weightb --nf --subme 7 --trellis 2 --partitions p8x8,b8x8,i4x4 --ratetol 20.0 --me umh --merange 32 --threads auto --thread-input --progress --no-psnr --no-ssim --output "output" "input"  


13. Match those settings EXACTLY! The box in the video configuration dialog must match this exactly, so get it right! Also, a couple variables can be changed if you want...
13. Match those settings EXACTLY! The box in the video configuration dialog must match this exactly, so get it right! Also, a couple variables can be changed if you want...

Revision as of 05:43, 15 July 2008

1. Download appropriate software you will need. Use RipIt4Me+DVD Decrypter for ripping DVD's, latest x264 revision for encoding H.264 video, MeGUI as a GUI for x264, Nero Digital Audio Decoder/Encoder (NeroAacEnc.exe) for encoding audio, and AviSynth v2.5.7 for video framserving.

2. Install all of the software. MeGUI should propmt you with updates on first launch. If not, go to Options -> Update and update all the software packages. The MeGUI updater does not update to the newest NeroAacEnc.exe so this must be downloaded and installed manually. To do this, go to this page (http://www.nero.com/eng/down-ndaudio.php) and select "Agree" to download the ZIP archive. There are several files in the ZIP archive, but the files we need are NeroAacEnc.exe or NeroAacEnc_SSE.exe. As the name suggest, the "SSE" version is optimized for processors that support SSE instructions (which is most of them, including all Intel Pentium III or newer CPUs and AMD Athlon XPs or newer). Extract one of these .exe files to your "MeGUI\Tools\NeroAacEnc" folder (eg. "C:\Program Files\MeGUI\Tools\NeroAacEnc\Win32\NeroAacEnc.exe"). Once the files are extracted, you need to tell MeGUI where to find them. So goto Options -> Settings which will bring up the Settings window. Click the Program Paths tab and under this tab click the Audio tab. Find the NeroAacEnc input and tell MeGUI where this file is located. Save your settings and restart MeGUI.

3. Now that all of the software is setup, we need to rip our DVD to our hard drive. I use a program called RipIt4Me that works in conjunction with DVD Decrypter to rip DVD's and strip the copy protection. I will not detail this process, but you shouldn't have trouble finding a guide somewhere on the internet.

4. Next, we will use MeGUI's D2V Creator tool to create a D2V file needed for MeGUI/AviSynth to handle MPEG-2 files (which is what DVD's use). This step is required only for MPEG-2 files, so skip this if your source isn't a DVD. So from the "Tools" menu, select "D2V Creator". In the "Video Input" section, load the first VOB file of the movie title set (the rest of the files in the set will be loaded automatically). You will get an error message about not being able to find "DVD Decrypter Generated Info Files" -- this is fine. Press "OK" to skip this error.

5. Select which audio track(s) to demux - you can select more than one track if you want the encoded file to have multiple audio tracks. Alternatively, you can just select the demux all the tracks and then choose the correct audio track(s) later on.

6. The default save directory is the same directory as your loaded DVD VOB files - change this if you want to. Select both the "On Completion Load Files", "And Close" checkboxes and press the "Queue" button. You are now returned to MeGUI - click on the "Queue" tab and press the "Start" button to start the D2V creation. When processing has finished, the status of the queued job will read "Done" and the created D2V file will be loaded into the AviSynth Script Creator ready for the next step. This can take a while, so please be patient - the status window's progress bar may not move, but don't worry, DGIndex is working.

7. This step will use MeGUI's AviSynth Script Creator tool to create an AviSynth script. If you followed the last step, the AviSynth Script Creator tool should already be started with the D2V file created loaded. Otherwise, you'll need to load the media file you want to convert into the "Video Input" section. The "Input DAR" is the aspect ratio of the input video. In most circumstances, it should be automatically set for you. Anamorphic DVDs will be set to "ITU 16:9", for example. Press the "Auto Crop" button to remove the black bars from the input video if it has any (most widescreen DVDs will).

8. Next, check the "Suggested Resolution" checkbox and change the resolution to one that you require. You can get away with using the maximum standard definition resolution (720x***) if no horizontal bars have been cropped. If horizontal bars have been cropped, then you need to go to the next number that is divisible by 16, which is (704x***). Alternatively, you probably can still maintain really good quality with horizontal values of 720/704/688/672/656/640.

9. Next, click on the "Filters" tab. For films on DVDs, you usually do not need to run a deinterlacing analysis. If the content you have is TV based, then you might need to click on the "Analysis" button to see if the video requires de-interlacing. Select "Source is Anime" if that's what you have. For the Resize Filter, I recommend "Lanczos (Sharp)". If the source has lots of noise, you can choose to enable the Noise Filter and choose how much noise is present in your source. The other options can be left alone ("Colour Correction" should be automatically checked for D2V input sources).

10. Make sure the "On Save Close And Load To Be Encoded" option and press the "Save" button to save the AviSynth script (by default, in the same directory as the D2V file, the filename is not important). Don't worry too much about the AviSynth Script Creator tool's preview window - it can be a little buggy where cropping and resizing and concerned. After saving, the AviSynth file should be loaded automatically into MeGUI - MeGUI's preview window does work fine and please make sure the video looks alright, especially for DVD sources with cropping/resize. If the video looks squashed or the aspect is screwed up, then you can click the "Show DAR" checkbox and play with aspect ratio in the dropdown beside it.

11. In the MeGUI "Input" section, select "x264" as the "Codec" and "MP4" as the "File Format". MP4 is not our container -- just our file format -- we will set our container later on to be "MKV" using the "AutoEncode" function.

12. For the Video Profile, we will configure our own. This is the trick to getting H.264 to play nicely with XBMC. So configure your own video profile with the following settings:

program --pass 2 --bitrate XXXX --stats ".stats" --level 4.1 --keyint 240 --min-keyint 24 --ref 6 --no-fast-pskip --bframes 6 --b-rdo --weightb --nf --subme 7 --trellis 2 --partitions p8x8,b8x8,i4x4 --ratetol 20.0 --me umh --merange 32 --threads auto --thread-input --progress --no-psnr --no-ssim --output "output" "input"

13. Match those settings EXACTLY! The box in the video configuration dialog must match this exactly, so get it right! Also, a couple variables can be changed if you want...

For Film (23.97 FPS) : --keyint 240 --min-keyint 24
For PAL (25 FPS) : --keyint 250 --min-keyint 25
For NTSC (29.97 FPS) : --keyint 300 --min-keyint 30

And finally, the bitrate you set in your Video Profile is dependant on your video resolution. This is the best way to get Xbox-compatible video at the highest resolution and bitrate possible. Suggested Bit Rate settings based on Output Resolutions are:

BitrateChart.jpg

These are MAXIMUM Bitrate values, which means you can set them lower, but that isn't recommended at higher resolutions! I recommend the values highlighted in yellow, as they look great and have little problems playing back.

The codec may crap out on HIGHLY COMPLEX scenes (e.g. Scenes with rain, water, snow, smoke, etc... or complex action scenes with hundreds of cuts within a couple minutes) at lower bitrates, and the only way to combat this is to set a custom "Zone" from the start frame of to the end frame of the complex scene and set that Zone's Quantizer to a value of 20. This can be done in MeGUI's video configuration dialog. Play around with different settings and see which works the best for you...

14. Now it's time to set up the audio encoding options. If you've followed this guide for DVD conversion, then the demuxed audio track we selected in the D2V Creator should already be loaded in (if not, load in the .ac3 file that was created). If you are not converting from a DVD source, then you can either load in a separate audio file or if you edited the AviSynth script (set "audio=true"), then load in the AVS file into the "Audio Input" section (meaning both video and audio inputs are the same AVS file). Repeat if you want a second audio track by clicking on the "2" select option.

15. Now we select an audio codec to use. I prefer AAC audio, especially with H.264 as video - AAC is to MP3 what H.264 is to DivX/XviD, better compression + better quality. So which audio codec should you use? I prefer ND AAC (Nero Digital), so select it if you agree with me. We can now choose an audio profile from one of the "NDAAC" options. "NDAAC-LC-MultiChannel-256Kbps" is the one I prefer.

16. Press the "AutoEncode" button to launch the Automatic Encoder setup window. This is pretty straight forward - just specify the Size And Bitrate to be "No Target Size (Use Profile Settings)" and make sure the Container is set correctly, to "MKV". The output location can be changed as well - this file will be the final output file that you want, so make sure you remember where you put it and don't accidentally delete it when cleaning up (I like to put this file in a different folder to all the other files, just in case). Press the "Queue" button and all the necessary jobs will be added to the encoding queue.

17. Click on the "Queue" tab and all the jobs should be listed there. When you are ready to start encoding, press the "Start" to start the encoding. You can view the status of your workers by selecting the "Workers Summary" option from the "Workers" menu.

18. That's it. It will encode audio, then two pass encode video, and then mux them together for a nice and pretty XBMC-compatible H.264 MKV video file. You can delete all the other files, unless you plan on making more encodings from them.