Compressing video to x264

Have a question you need to ask? Need help? Ask here!

Moderator: Core Staff

Post Reply
User avatar
Tonttu
CJ Newbie
CJ Newbie
Posts: 60
Joined: July 29th, 2005, 1:55 pm
Location: Finland

Compressing video to x264

Post by Tonttu » October 2nd, 2006, 10:03 pm

Tools needed to encode: Install AviSynth to default directory (C:\Program Files\AviSynth 2.5)
Install megui

megui requires Microsoft .NET Runtime 2.0
you can get it from here

When you launch megui it asks you to search for updates. Click yes and you get this window
Image

Select everything and press update
When it asks which profiles to import select all of them
Megui might require to be restarted after updating


Next thing to do is to go Tools --> Settings or press CTRL+S and check the settings, only thing you should need to change is Default Audio Track 1 to English
Image
After changing the settings press save and you should be in the main window again

If you're unfamiliar with AviSynth scripting megui has it's own avisynth script creator which you can access from Tools --> Avisynth Script Creator or by pressing CTRL+R
Image
To input select your video clip and a preview window should open, close it
In the first tab you can set cropping and resizing. If you don't know what mod16 means and anything about aspect ratios you should just always select Suggest Resolution

Image
On the second tab is a useful button to analyze video if it's interlaced, if you don't know if your source video is progressive or interlaced press the button and it checks the video for you and sets proper settings for deinterlacing if needed.
Here you can also choose your the resize filter to use and noise filter if needed

Image
The last tab is for editing the AviSynth script
After you have made the AviSynth script just press save and you're back in main window with the script loaded

Image
Select x264 for codec and change container to MKV and press Config

A new window should open:
Image
Main settings are made on this tab
Most important settings are Mode, Bitrate, AVC Profiles, AVC Levels, fourCC (always change it to x264) and of course the profile selector on bottom left corner
I selected Sharktooths HQ-Slow profile for the video in this tutorial, experiment with different profiles and settings
You probably never need Zones tab so I just skip it

Image
On RC and ME tab the most important settings are M.E. Algorithm, Subpixel Refinement and Keyframe Interval
Use a keyframes less or equal to 20 seconds (just multiply your framerate to with the seconds, 1 keyframe every 10 seconds 25*10=250, 1 keyframe every 20 seconds 25*20=500 if there isn't a scene change before that where it automatically places keyframe)
You don't need to modify these settings if you're using profiles

Image
While using profiles you're probably never going to need to change these settings but if you want experimenting try changing profile to Sharktooth's HQ-Insane and change Number of B-Frames to 16 ;)

When you're done with the settings press OK to return back to main window

Go to Tools --> Bitrate Calculator or press CTRL+B
Image
Select the codec and container that you're using, it should have selectected them automatically
Also all settings in Video should be automatically selected
To audio track select your audio file, sometimes it reads it incorrectly and then you need to manually input the bitrate for it (use the arrows to change it afterwards so it updates the change)

To file size input the target filesize (use arrows in here also to update the settings)

You can see the bitrate on the bottom right corner, the reason I'm using this high bitrate is that I'm using my own AviSynth script and it's going to have 720p resolution

When you're done press apply and it should have updated the bitrate to profile, just to be sure select Config from main window to see if it updated it
Image
In this case it updated it so press OK
Next press Enqueue in main wondow and then go to Queue tab whis looks likt this:
Image
Pres star and wait for the encoding to finish
After the encoding has finished press Clear and go to Tools --> Muxer --> MKV Muxer
Image
Select the encoded video to Video Input
Select your audio file to Audio Input, Language should be English by default but it shouldn't matter if it's different, Delay isn't needed unless you want to delay the audio for some reason

Subtitle and Chapter aren't needed

Just select Muxed Output and press Queue, or you can split the output if you want

Now you are back in main window
Just go to Queue tab and press Start and wait for muxing to finish


To playback x264 encoded video you need H.264 decoder, ffdshow has one (During installation, Video decoder - H.264, X264 enables x264 playback)
SSE optimized version
SSE2 optimized version
http://en.wikipedia.org/wiki/SSE2 wrote:CPUs supporting SSE2

* AMD Athlon 64
* AMD Athlon 64 X2
* AMD Opteron
* AMD Sempron (Socket 754/939/AM2 versions only)
* AMD Turion 64
* Intel Pentium 4
* Intel Pentium D
* Intel Pentium EE
* Intel Pentium M
* Intel Celeron (Socket 478 versions only)
* Intel Celeron D
* Intel Celeron M
* Intel Core Solo/Duo
* Intel Core 2 Solo/Duo/Extreme
* Transmeta Efficeon
* Intel Xeon
* Via C7
If your CPU is older than these CPU's and isn't on this list download SSE optimized version

Matroska Splitter is also required to add support for mkv container

Or instead of ffdshow and Matroska Splitter you can use VLC media player


And finally a video encoded with the settings this tutorial (right click and choose save as): http://www.von-clan.x10hosting.com/x264 ... _final.mkv
Well not exactly these settings since I used my own AviSynth script... the video has 720p resolution (1280x720)

If anyone is interested here's the AviSynth script I used (I cropped the video already in VirtualDub so that's why there isn't cropping in the script):

Code: Select all

#Load source videos
a=AVISource("G:\Tutorial\part1.avi")
b=AVISource("G:\Tutorial\part2.avi")
c=AVISource("D:\Tutorial\part3.avi")
d=AVISource("D:\Tutorial\part4.avi")
e=AVISource("D:\Tutorial\part5.avi")

#Combine source videos
a+b+c+d+e

#Convert to YV12 colorspace for filters and x264
ConvertToYV12()

#Sharpen the image with LimitedSharpen
LimitedSharpen(smode=3, lmode=1, special=true)

#Remove noise
UnDot()
The bitrate could have been little higher or I should have used different profile for encoding
Here's one encoded with a profile modified from Sharktooth's HQ-Insane
The bitrate is almost same as the one in this tutorial, little lower if I remember correctly
Modifications made to HQ-Insane was that B-Frames were set to 16 and I used 3-pass mode
However with these settings the encoding is extremely slow (average Video Rendering Rate was 0,55 fps)
http://www.von-clan.x10hosting.com/enco ... _video.mkv

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests