PDA

View Full Version : XViD Encoding Tutorial, Version 2



Frenchy
11-29-2008, 04:11 AM
Ok Here's a new tutorial one How to encode to XViD format from a MPEG-2 or Lossless .avi Capture.

This tutorial is using meGUI, 2 pass XViD encode and MP3 Audio, and Muxing in nandub.

Note this tutorial isn't easy, spare some time, double check your scripts and you will have a good encode

Programs required:
meGUI
DGMPGDec aka, DGIndex aka, DVD2AVI (Included with meGUI install)
AviSynth (Included with meGUI install)
nanDUB

Optional filters:
YADIF (Regular deinterlace filter included in meGUI)
Restore24 (Best PAL field blend to 23.976fps, VERY HARD TO SETUP)
mrestore (Similar to Restore24, not as good results but faster and easier to setup)
TIVTC (Inverse Telecine Filter for NTSC video to NTSC Film frame rates)

Step 1:
Ensure the video is indexed, .avi captures skip this step (it's already indexed),
to Index an .mpg capture,

Run meGUI, Select Tools, D2V Creator.
Load your MPG video stream, check "No Audio demux".
We want to use our .wav saved from Cool Edit with CD or Edited Live Mix.
http://img372.imageshack.us/img372/4793/45080015hu4.png

Select Queue, and close the D2V creator Window.
Select the Tab "Queues" in meGUI and Press Start to create the D2V.


Step 2:
Now we have an indexed video we can begin an AviSynth Script.
This script is used to Import Video, Add Logo, Dinterlace, Crop, Resize, Noise reduction, Sharpen etc.

To make a basic Script in meGUI.
Select Tools, AviSynth Script Creator.
This is a GUI which fills in basic functions into the AviSynth Script.

We want to open our Indexed videos to create at Script.
Start by opening your .d2v or .avi in "Video Input"

Ensure the correct DAR is selected, eg NTSC or PAL 4:3, 16:9 etc.
Click Autocrop,
Resize the video,
To Calculate the Highest Resolution without Upscaling,
Tick Resize and Suggest Resolution, My Example is 720 Horizontal pixels.
Subtract what is Cropped from left and right and input this value in the Box where input is enable
(make sure its dividable by 16 and click up and down arrow so the GUI knows the new value has been added)

Refer to Screenshot on how this works.

http://img291.imageshack.us/img291/2879/91854437tu6.png

Step 3:
Deinterlacing in AviSynth.
Ok This is made easy by the Analysis button which Automatically determines whether the video is Interlaced, or 3:2 pulldown and the video's field order.

For this example I'm using Yadif as my video is completely interlaced (50 different fields a second)
I'll add an extenstion to this Tutorial on other Methods later.

Finally after this has been done save your script.

The Screenshot is an Example,
Edit your Values depending on your video.

http://img175.imageshack.us/img175/7425/73623301kn5.png


Step 4:
Adding a Logo.
Load your now saved .avs Script in Notepad.
It should look Similar to this screenshot
http://img165.imageshack.us/img165/3507/60032748nk7.png

To add a logo,
This requires Donald Graft's VirtualDub Logo Filter


function VD_Logo(clip clip, int "x", int "y", int "alpha", bool "transparent",
\ int "xr", int "xg", int "xb", int "tolerance", string "filename",
\ bool "animate", int "start", int "duration", int "loops",
\ int "fadeinlen", int "fadeoutend", int "fadeoutlen")
{
LoadVirtualdubPlugin("C:\virtualdub mod\plugins"
\ +"\logo.vdf", "_VD_Logo", 1)
return clip._VD_Logo(default(x,0), default(y,0), default(alpha,128),
\ default(transparent,true)?1:0, default(xr,0), default(xg,0),
\ default(xb,255),default(tolerance,0), default
\ (filename,""),
\ default(animate,false)?1:0, default(start,0), default(duration,0),
\ default(loops,0),default(fadeinlen,0),
\ default(fadeoutend,200), default(fadeoutlen,0))
}
ConvertToRGB()
VD_logo(382,435,240,true,0,0,0,10,"C:\Capture\watermark720x576-Frenchy.bmp",false,1067,0,0,30,1419,13)
ConvertToYV12()This is the logo part of the script i used in the example encode
anyway the line "LoadVirtualdubPlugin" the directory needs to match where your VirtualDub Filters.

The Line "VD_logo(382,435,240,true,0,0,0,10,"C:\Capture\watermark720x576-Frenchy.bmp",false,1067,0,0,30,1419,13)"
is all the values used to logo the video.

A easy way to fill in these values is to Add your logo as you would for A TMPGEnc Encode.
Then save the Processing Values from Virtual Dub.

Open the .vcf File in Notepad,
Scroll Down to a line which looks like this.



VirtualDub.video.filters.instance[0].Config(382, 435, 240, 1, 0, 0, 0, 10, "C:\\Capture\\watermark720x576-Frenchy.bmp", 0, 1067, 0, 0, 30, 1419, 13);Translates to


VD_logo(382,435,240,true,0,0,0,10,"C:\Capture\watermark720x576-Frenchy.bmp",false,1067,0,0,30,1419,13)In the AviSynth Script Logo.

Ok This script will do.

Step 5:
Encoding

Import the Profile I exported
** Check the attached zip file

Import this meGUI profile by selecting File Import Presets and opening the .zip you downloaded.

Ok load your .avs in the AviSynth Script Column,
Select your output .avi in the next column,
Ensure the profile "XviD: VP XviD" is selected,
Click "Enqueue" in the video Encoding Section.

Load your finished .wav in Audio Input,
Select the output .mp3,
Ensure the profile "LAME MP3: VP mp3" is selected,
Click "Enqueue" in the audio Encoding Section.

Now go to the Queues tab and Select Start.

The video and audio will now encode to XViD and mp3 respectively.

Step 6:
Muxing.
Easy Step,
Load your encoded XViD .avi in nanDUB,
Go To Video, Direct Stream Copy.
Go To Audio, (VBR) MP3 Audio and load your encoded .mp3 from meGUI.

Go File, Save As AVI.
Make sure a different file name from the source .avi is selected,
Click ok and In a few seconds You're Done!

Congrats!


Any Questions?
I'll add more deinterlacing fuctions include TIVTC and Restore24 soon.

** Admin Note, url removed & file zipped and attached to post for ease of use.

bensta
11-29-2008, 11:21 PM
Since i have to deinterlace tv addons on triple jtv this is a quick guide how to do it and add to AviSynth script.

Script should look like this: (in red)

DGDecode_mpeg2source("F:\Capping\augie march 06.d2v",info=3)
ColorMatrix(hints=true)
#deinterlace
Load_Stdcall_Plugin("C:\Documents and Settings\Michael Riley\Desktop\Ben's Stuff\megui\tools\yadif\yadif.dll")
main = last
main.Trim(0,0) ++ main.Trim(0,30).Yadif(order=1) ++ main.Trim(31,0)
main = last
main.Trim(0,32) ++ main.Trim(33,449) ++ main.Trim(450,570).Yadif(order=1) ++ main.Trim(571,0)
main = last
main.Trim(0,572) ++ main.Trim(573,5490) ++ main.Trim(5491,7157).Yadif(order=1) ++ main.Trim(7158,31)
function VD_Logo(clip clip, int "x", int "y", int "alpha", bool "transparent",
\ int "xr", int "xg", int "xb", int "tolerance", string "filename",
\ bool "animate", int "start", int "duration", int "loops",
\ int "fadeinlen", int "fadeoutend", int "fadeoutlen")
{
LoadVirtualdubPlugin("C:\Documents and Settings\Michael Riley\Desktop\Ben's Stuff\Watermarks"
\ +"\logo.vdf", "_VD_Logo", 1)
return clip._VD_Logo(default(x,65), default(y,411), default(alpha,240),
\ default(transparent,true)?1:0, default(xr,0), default(xg,0),
\ default(xb,255),default(tolerance,0), default
\ (filename,"C:\David's Folder\virtualdub mod\plugins\Frenchy Logo.bmp"),
\ default(animate,false)?1:0, default(start,0), default(duration,0),
\ default(loops,0),default(fadeinlen,0),
\ default(fadeoutend,200), default(fadeoutlen,0))
}
ConvertToRGB()
VD_logo(10,10,240,true,0,0,0,0,"C:\Documents and Settings\Michael Riley\Desktop\Ben's Stuff\Watermarks\watermark720x576-bensta.bmp",false,450,0,0,20,570,20)
crop( 2, 2, -12, -2)

LanczosResize(704,384) # Lanczos (Sharp)
#denoise

ConvertToYV12()

Info:

"main = last"
Footage that is progressive (before the tv addons or logos)

"main.Trim(0,30).Yadif(order=1)" <--- is part (range) where you have tv addons that need deinterlacing, after the brackets or trim and dot you specify the deinterlace filter can be anything FieldDeinterlace(), Yadif(), TomsMoComp etc. also some deinterlaces cut video a few lines (and leave greenish line on the bottom) so make sure that doesn't happen)

"++ main.Trim(31,0)" first frame after there are no tv addons anymore till end (that's the 0 for)

Some info was passed by serch so give him the credit for this post.

bensta
11-30-2008, 01:21 AM
To check if tv addons need to be deinterlaced you will need the plugin (DeinterlaceAreaBased.vdf).

Load the plugin in VirtualDub and click the box "show deinterlaced areas only", this will show everything that isn't touched by the deinterlace filter.

Everything that isn't touched by the deinterlace filter will be "grey" and everything that will be "deinterlaced" is in "colour."

This is a quick guide to check.

Casper
12-07-2008, 04:10 PM
Thanks, not a bad guide. I'm so used to doing everything within VirtualDub, so don't see this to give better results. But I'll be using this method non-the-less.

One thing is you lost the alpha masking ability of the Logo filter. So what I did was changed the boolean objects in the function to integers. This way it's also more straightforward when "translating" the settings from your saved .vcf file (no more true/false values).

Frenchy
12-22-2008, 03:26 AM
Here's a IVTC script I got for NTSC Video 29.97fps only.


d2vpath = "Insert indexed mpg video here"
mpeg2source(d2vpath)
deint = tdeint()
tfm(d2v=d2vpath,clip2=deint)
TDecimate()I use this method as it has no deinterlace and is compatible with Progressive scenes (Decimates rather than blending like other methods I tested)

Also if a video has more Progressive or Interlaced scenes than Pulldown frames (say more than 1/3 video),
Just deinterlace it normally, it's better to Duplicate frames than Drop then.

I'll put up a reference screens if anyone needs help Identifying Pulldown Frames over Interlaced Frames.

Good Luck.

(Funny IVTC guide coming from a PAL ripper)

bensta
12-22-2008, 04:09 PM
I have just installed the new megui version on my new computer. Hooray i can finally start ecoding :D.
Just thought to mention that you have to manually install MEGUI Updater.

Here is the link: http://sourceforge.net/forum/forum.php?forum_id=898888

Follow the directions and everything will update automatically when you change the links.

rippergreat
05-30-2009, 11:17 PM
hey
i tried it and didn't work... please help

VampYre
05-31-2009, 01:12 PM
hey
i tried it and didn't work... please help

Very informative...maybe try posting exactly what didn't work. Error messages, ect...

rippergreat
05-31-2009, 07:21 PM
sorry i did the avs script exactly as shown but when i encoded it didn't work here is the script

DGDecode_mpeg2source("C:\Documents\Videos\VTS_02_1.d2v", info=3)
ColorMatrix(hints=true, interlaced=true, threads=0)
tfm(order=1).tdecimate(hybrid=3)

function VD_Logo(clip clip, int "x", int "y", int "alpha", bool "transparent",
\ int "xr", int "xg", int "xb", int "tolerance", string "filename",
\ bool "animate", int "start", int "duration", int "loops",
\ int "fadeinlen", int "fadeoutend", int "fadeoutlen")
{
LoadVirtualdubPlugin("C:\VirtualDub\Plugins"
\ +"\logo.vdf", "_VD_Logo", 1)
return clip._VD_Logo(default(x,0), default(y,0), default(alpha,128),
\ default(transparent,true)?1:0, default(xr,0), default(xg,0),
\ default(xb,255),default(tolerance,0), default
\ (filename,""),
\ default(animate,false)?1:0, default(start,0), default(duration,0),
\ default(loops,0),default(fadeinlen,0),
\ default(fadeoutend,200), default(fadeoutlen,0))
}
ConvertToRGB()
VD_logo(382,435,240,true,0,0,0,10,"C:\VirtualDub\Plugins\T.bmp",false,1067,0,0,30,1419,13)
ConvertToYV12()

crop( 4, 58, -4, -54)

LanczosResize(640,272) # Lanczos (Sharp)
Undot() # Minimal Noise

Casper
09-14-2009, 01:01 AM
I just want to find out something with regard to the encoding.
When I encode from VirtualDub, doing just about the same
edits (cropping, resizing, deinterlacing with Yadif if needed),
and encoding with XviD (2-pass) withsame bitrate and settings (as far as I know).
The file sizes / bitrate allocated greatly differ between the two encodings
(i.e. between the one done through meGUI and the one through VirtualDub).
What is being done differently? I'm testing with the VP profile.
It seems as though the meGUI videos vary more drastically from video to video.
Whereas with VirtualDub the videos are usually around the same bitrate (maybe
the 2-pass isn't being performed properly or my settings are problematic).
Otherwise it's just something special with the meGUI setup?
It's the same even if I do the exact same edits by opening the .avs in VirtualDub.
So it all comes down to the encoder settings I believe.

Using a bitrate of 2500 kbps (with 192 kpbs audio) I achieve roughly a 2700 kpbs
overall bitrate. But with meGUI it can vary from 1000 kbps to 3000 kbps depending on the video.
Why is this?

MinhThai
10-17-2009, 11:04 PM
Thanks for the great post, Frenchy :yourock:. This is very useful for me to encode some .mpeg files to avi to share to my friends. But something I don't really understand, for example the script to add logo to the videos. But just leave it behind because my first question is that how you make your watermark image. I have searched some helps by Google but it isn't useful for me because there are almost programs, not any tutorial. Please help me to make my own logo. Thanks in advance!
P/S: Sorry for my bad English if you don't really understand my problems :).

Casper
10-21-2009, 12:44 PM
If you know VirtualDub - you'll know that it can be 'extended' with the use of filters.
The above is making use of a particular filter called Logo (it is not the same as the logo filter which is by default part of VirtualDub) made by Donald Graft (I think), and the Logo filter can be found at neuron2.net (again..I think). It's somewhere under "Mine" (as in his filters) and virtualdub filters.
You don't need VirtualDub, just get the filter.

This is where the filter is loaded in the script:
LoadVirtualdubPlugin("C:\virtualdub mod\plugins"
\ +"\logo.vdf", "_VD_Logo", 1)

airfox1998
02-21-2010, 06:49 PM
i tried it and it works very well but i have a doubt

how you create this code? :

function VD_Logo(clip clip, int "x", int "y", int "alpha", bool "transparent",
\ int "xr", int "xg", int "xb", int "tolerance", string "filename",
\ bool "animate", int "start", int "duration", int "loops",
\ int "fadeinlen", int "fadeoutend", int "fadeoutlen")
{
LoadVirtualdubPlugin("C:\virtualdub mod\plugins"
\ +"\logo.vdf", "_VD_Logo", 1)
return clip._VD_Logo(default(x,0), default(y,0), default(alpha,128),
\ default(transparent,true)?1:0, default(xr,0), default(xg,0),
\ default(xb,255),default(tolerance,0), default
\ (filename,""),
\ default(animate,false)?1:0, default(start,0), default(duration,0),
\ default(loops,0),default(fadeinlen,0),
\ default(fadeoutend,200), default(fadeoutlen,0))
}

i know this code is for donald graft's virtualdub Logo Filter for meGUI

but i wanna try some new filters like "FadeFX (fade-in\fade-out filter" in meGUI but i dont know how to generate that custom script

thanks in advanced

pd. sorry for my poor english