MEMBERS ONLINE: 0
REGISTERED MEMBERS: 18453
REGISTERED MOVIETEAMS: 684
NEWEST MEMBER: johnybravosm
NEWSITEMS: 619
LATEST COMPO-WINNER: bKr[ME]

Auto-login: - Forgot your password?

FORUM

Codecs > Tut: Matroska x264 Encoding
Page: 1 2 3 4 >>
Incognito

Oslo, Norway
Joined: 9. Oct 2006
Posts: 54

Tut: Matroska x264 Encoding

#1 - 10. Mar 2008 16:38
Credits goes out to Sharktooh, Techouse, bokonon and Bobby for their work which made this tutorial possible.


IMPORTANT: Each time the tutorial has been updated, you have to download the "additional files" again to be updated.



Basic Version:


0: Preparations.
Now in order to be able to use this guide you will need to download some software.
MeGUI
Mkvtoolnix
AviSynth 2.5.8 RC4
Additional Files

In order to install Huffyuv right click the "Huffyuv.ini" file and click install.

1: Source Files.
Render the video and audio separate from each other, render the audio as a .mp3 and the video as a lossless .avi using the Huffyuv codec.
To make it as easy as possible for yourself you should put all the files necessary in a folder as close to the C:\ root as possible.
I have a folder called on C:\ i named "Encode" so the path for all the files necessary required are "C:\Encode\filename.filetype"

2: AviSynth Script.
Open Notepad and copy this in:

DirectShowSource("C:\Sourcefile.avi")
spline64resize(1280,720)
Converttoyv12()


- Fill in the correct resolution.

- Fill in the correct location for the lossless ".avi" you just rendered and hit Ctrl+S and save it as a "select_filename.avs" file.

3: MeGUI Part-1.

Before you open MeGUI, move the "x264_dp_ Optimized x264 Settings.xml" file i included into the "MeGUI\allprofiles\x264" folder".
Now open MeGUI and open our little AviSynth Script, a preview should show up but you can close this.
Select the GTA Profile i posted, .mkv as output format and x264 as codec.
Go to "Tools - Bitrate Calculator", de-select the audio and select your desired bitrate instead of output size.
For tips to what bitrate you should use, see the advanced version.

4: MeGUI Part-2.
Click to edit the video profile and, go to the last page and select the Custom Quantizer Matrix "eqm_avc_hr.cfg".
Also set the number of reference frames, use the chart below to see how many you should use:

1920x1200 or less: 3
1920x1080 or less: 4
1280x800 or less: 5
1280x720 or les: 9


Click ok and then Enqueue, you will now be taken to the queue and you can start encoding your video.

5: Muxing.
Once your video is encoded and your .mkv is ready, open mkvtoolnix up.
Import the video and then the audio, give it a new filename and hit Start Muxing and you're done.









Advanced Experimental Version:

If this version gives you any errors, please try the basic version which is made to be as stable as possible as this is an experimental version which will be updated a lot more frequently.



0-2: Preparations.
Do the same as instructed in the basic version. (you won't need MeGUI for this though)
Get the most recent x264 version here: http://x264.tk

3: Encoding.
Put the contents of what i included in the Advanced folder where you have your .avs, lossless.avi and the x264.exe you just got.
Right click the "Encode.bat" file and select "Edit", set the bitrate to what seems right for the resolution you're encoding to according to the list below.


1920x1200= ~ 12000mbps
1680x1050= ~ 10000mbps
1280x720= ~ 6500mbps
960x600= ~ 4500mbps
800x600= ~ 3500mbps
640x480= ~ 3000mbps

The bitrate has to be set for both passes.

Correct the locations of these files "eqm_avc_hr.cfg" "select_filename.avs" "x264.exe".
Change the name of the "select_filename.stats" to the same as the "select_filename.avs" file.
Also fill in the correct number of reference frames where it says "--ref 3",
please consult the basic version about information about what to chose.
Press Ctrl+S to save it once you've done all this.

It's important that you apply the same settings to both passes.

Instructional image here

Hit the windows button and go to Run and type cmd, then cd\ in the window that opens and then cd sourcefolder/address and finally run the Encode.bat

Instructional image here

When the 1stpass is done you will have a log in the command line interface window, look at the instructions below to be sure the bitrate selected is sufficient... if it goes far above 25, kill the process, pick a higher bitrate and start over.

4: Quality Information.
Once each pass is done you will have a log like this:


[info]: slice I:45253 Avg QP:19.05
[info]: slice P:15009 Avg QP:20.08
[info]: slice B:49143 Avg QP:21.23

The Avg QP:xx.xx part tells you how close it is to the source, lower is better.
Anything below 16 is way overkill and if it goes above 25 you'll start to see macroblocks.

5: Muxing.
Do the same as instructed in the basic version.







Change-Log:

1.9
Improvements:
- Both versions has been updated to utilize and be compatible with the most recent x264 updates.

1.8
Improvements:
- AviSynth 2.5.8RC4 has been released and a link for it has been added to both versions.
- "--subme 7" for better and more precision motion estimation instead of a unnecessary prepass.
- New B-Frame decision mode added for the advanced version.

1.7
Improvements:
- AviSynth 2.5.8RC1 has been released and a link for it has been added to both versions.
- ColorMatrix is out as it's not really necessary.
- Avisource is replaced with DirectShowSource which is a lot more forgiving.

1.6
Advanced gets even more advanced:
- Added a Huffyuv patch that fixes a old bug so the last frames doesn't get left out and a link to new and better x264 builds that has a lot of great patches.

PS3, XBOX 360 and so on...:
- Instead of using a unrestricted level, the h.264 level is now set to 4.1 meaning you should be able to stream them to a PS3, XBOX 360, Popcorn Hour or anything like that.

1.5
Advanced version added:
- There is now an advanced version for those who wants slightly better quality and perhaps learn a little more at the same time.

1.4
MeGUI back, several filters gone, command line gone:
- The tutorial is easier to use than ever before with a very minor loss quality-wise most people won't notice.

1.3
MeGUI Gone:
- Since MeGUI doesn't let you pick rate factor instead, i've removed it for now.

CRF18:
- CRF18 (Constant Rate Factor 18) replaces the part where you have to select a bitrate.

1.2
ColorMatrix added for:
- To prevent color loss when converting from RGB to YV12.

Command Line Encoding added for:
- It uses a x264.exe version that lets you add the "aqstrength" options which should prevent blocking in dark areas.
- For those who got stability problems with MeGUI.

1.1
Soothe added for:
- Lower bitrate requirements.
- More steady appearance.
- Smoother motion compared to plain-sharpening, since motion-blurred edges will be less sharpened.
- Less artifacts in moving areas.
- LimitedSharpenFasterMOD can run faster, since one can get away with less supersampling.

AviSynth 2.5.8 added for:
- The new Spline64 is sharper and has less ringing than spline36.

RemoveGrain options added for:
- The different versions are made for CPUs with different SSE versions which will lower the time the encode takes.

MaskTools 2.0.30.0 updated to 2.0.a32.0:
- More precise and efficient sharpening.

Last changed: 25. October 2008 16:11
zeun
panCake

Oslo, Norway
Joined: 7. Oct 2006
Posts: 2666
#2 - 10. Mar 2008 16:47
seems like a pretty decent guide. gj.
Incognito

Oslo, Norway
Joined: 9. Oct 2006
Posts: 54
#3 - 10. Mar 2008 17:20
I used to use the old guide here but it's the same old guide as the commandline version that was posted a couple of years ago, just ported to work with MeGUI.
cZF
Style-Productions

, Germany
Joined: 14. Jul 2006
Posts: 699
#4 - 10. Mar 2008 17:33
May I ask why you're suggesting to use the colormatrix filter in the experimental version? According to the developer it's a filter used to correct colors in mpeg2 streams of DVDs. What's the advantage of using it in computer-generated footage?

http://forum.doom9.org/showthread.php?s=&threadid=82217
Incognito

Oslo, Norway
Joined: 9. Oct 2006
Posts: 54
#5 - 10. Mar 2008 17:52
If you download AvsP (AviSynth Preview) from here: http://avisynth.org/qwerpoi/
You can see a preview of how the encode will look with the current script settings... i ran some tests with different test-clips with different colors (day, night, sunny, rainy, cloudy) with real-life footage and recordings from GTAVC and it looked a lot more spot-on with Colormatrix.
Try it with and without in AvsP and decide for yourself.

When you encode a lossless .avi to a x264.mkv you change colorspace from RGB to YV12 as well so it should prevent clolor loss.
Correct me if i'm wrong though but it's the thing to do judging from what i've learned.

Last changed: 10. March 2008 18:04
cZF
Style-Productions

, Germany
Joined: 14. Jul 2006
Posts: 699
#6 - 10. Mar 2008 18:02
Aight, will do, thanks for the info.
slize
Elegato

somewhere, Poland
Joined: 8. Oct 2006
Posts: 4584
#7 - 10. Mar 2008 18:19
Interesting. I will try that one day
cZF
Style-Productions

, Germany
Joined: 14. Jul 2006
Posts: 699
#8 - 10. Mar 2008 18:31
Seems like an interesting filter although I'm getting the feeling it mostly just increases the amount of red in your image. It adds an almost glowy orangish touch to yellow/white parts of the image. A downside I see though is that the filter requires conversion to YV12 or YUV2 which has the nasty effect on reds in general, i.e. it blurs it out which isn't really handy for deathnotices in CS. At least that's what I see when I compare RGB and YV12 through AvsP and I'm guessing you should trust the application on that one since that's what the tool is for, right? The comparison of filtererd and unfiltered images. Just a heads-up.
cZF
Style-Productions

, Germany
Joined: 14. Jul 2006
Posts: 699
#9 - 10. Mar 2008 18:34
Um, cross the downside I pointed out since it's just a logical observation if you recall the purpose of ColorMatrix :>

Here's a brief comparison.

RGB:


YV12






Last changed: 10. March 2008 20:07
anthony
Style-Productions

The Desert, United States of America
Joined: 9. Aug 2006
Posts: 3339
#10 - 10. Mar 2008 19:03
Post this in the user guides section dude!
cZF
Style-Productions

, Germany
Joined: 14. Jul 2006
Posts: 699
#11 - 10. Mar 2008 20:33
Incognito wrote:
When you encode a lossless .avi to a x264.mkv you change colorspace from RGB to YV12 as well so it should prevent clolor loss.
Correct me if i'm wrong though but it's the thing to do judging from what i've learned.


Yeah I know, but I still find it hard to comprehend if you keep in mind that half of the chroma data is dropped when you convert to YV12. I'd love to see how YV24 works, but the implementation of that filter is announced for Avisynth 2.6 respectively the rewrite known as 3.0.
Hildesheimer

, Germany
Joined: 7. Oct 2006
Posts: 703
#12 - 10. Mar 2008 22:10
Looks pretty good. Will test it out someday.
cZF
Style-Productions

, Germany
Joined: 14. Jul 2006
Posts: 699
#13 - 10. Mar 2008 22:15
Who?
Incognito

Oslo, Norway
Joined: 9. Oct 2006
Posts: 54
#14 - 10. Mar 2008 22:18
Cleric wrote:
Post this in the user guides section dude!

I did but i had to post a link to where it was so i had to post it in the codecs section and link to it.

rykketid wrote:
Yeah I know, but I still find it hard to comprehend if you keep in mind that half of the chroma data is dropped when you convert to YV12. I'd love to see how YV24 works, but the implementation of that filter is announced for Avisynth 2.6 respectively the rewrite known as 3.0.

Indeed AviSynth 3 is going to be sick... so far it does look a bit less "dull" with colormatrix though so i decided to keep it in there.
I'll update the tutorial once AviSynth 3 is released.
speccan

Vara, Sweden
Joined: 12. Nov 2006
Posts: 13
#15 - 13. Mar 2008 19:11
I have no experience at all using x264 and so on, but i get real shit quality with wmv nowadays, so i need to learn it. So i was wondering, which guide is best ? this one or the one s0nkite made ? and whats the diference between them ?
slize
Elegato

somewhere, Poland
Joined: 8. Oct 2006
Posts: 4584
#16 - 13. Mar 2008 22:48
Try it. You will see the difference. If you will have some troubles to achieve great quality , than pm me and I will give you my settings.
juggaknot
Airwalk Media

LOLville, Romania
Joined: 2. Oct 2007
Posts: 2766
#17 - 14. Mar 2008 14:12
will give it a try with a 1920 x 1080 footage captured on a HD2600 PRO at startmovie 400 today.
cZF
Style-Productions

, Germany
Joined: 14. Jul 2006
Posts: 699
#18 - 14. Mar 2008 14:28
Plx, 720p for CS isn't necessary, but 1080p?? A fruitless effort.
juggaknot
Airwalk Media

LOLville, Romania
Joined: 2. Oct 2007
Posts: 2766
#19 - 14. Mar 2008 17:48
don't care :)
cZF
Style-Productions

, Germany
Joined: 14. Jul 2006
Posts: 699
#20 - 14. Mar 2008 18:03
Wow, you rebel, you...

Page: 1 2 3 4 >>

You need to log in to write a post.