I assume you know something about video compression with VirtualDub so I don't explain step-by-step what to do
What you need?
AviSynth
VirtualDub
Decomb Plugin for Avisynth
XviD Codec
At this point you might ask what is AviSynth?
First you need to install the programs/codecshttp://www.avisynth.org/ wrote:AviSynth is a powerful tool for video post-production. It provides almost unlimited ways of editing and processing videos. AviSynth works as a frameserver, providing instant editing without the need for temporary files.
AviSynth itself does not provide a graphical user interface (GUI) but instead relies on a script system that allows advanced non-linear editing. While this may at first seem tedious and unintuitive, it is remarkably powerful and is a very good way to manage projects in a precise, consistent, and reproducible manner. Because text-based scripts are human readable, projects are inherently self-documenting. The scripting language is simple yet powerful, and complex filters can be created from basic operations to develop a sophisticated palette of useful and unique effects.
I recommend to install them to default directory or at least AviSynth to it's default directory which is C:\Program Files\AviSynth 2.5
Then you need to install "Decomb Plugin for Avisynth", don't know how?
Extract the .zip file in your C:\Program Files\AviSynth 2.5\plugins folder if you don't have plugins folder just create it
I assume you have edited your video with some video editing software. At least some of them interlaces the video so that's why you need the Decomb Plugin
Now to the guide
I assume your source is PAL (25 fps).
Uncompressed video is usually in RGB colorspace but video editing programs might convert it to YUY2 or YV12 when saving.
That's why I give you two different AviSynth scripts to determine if it's interlaced TFF (Top Field First) or BFF (Bottom Field First)
Copy the code to notepad and save it as .avs
All the scripts needs to be saved the same way
Check in which colorspce your source video is
Open the source video with VirtualDub and go to "File" --> "File information..." and check "Decompressor"
If it's captured with Fraps or some similiar program that uses it's own codec then you should use the following script to open the video file
Code: Select all
AVISource("C:\video.avi")
Use this script to check YUY2 and RGB material if it has been interlaced Top Field First or Bottom Field First
Code: Select all
function CheckTopFirst(clip v1) {
v2 = v1.subtitle(v1.GetParity()?"TF":"BF")
v3 = v2.GetParity()?v2.ComplementParity():v2
t0 = v3.ComplementParity()
t1 = t0.separatefields()
t2 = compare(t1.trim(1,0),t1)
b1 = v3.separatefields()
b2 = compare(b1.trim(1,0),b1)
return stackvertical(t2,b2)
}
v=AviSource("C:\video.avi")
CheckTopFirst(v)
http://www.avisynth.org/ wrote:Then preview a few frames. It will use Compare to evaluate the two possibilities and vertically stack the results. This shows 2 useful pieces of info. First the preview of either the top or bottom half of the screen will probably be jerky, so choose the other one.
But just as reliable is the "Avg Mean Abs Dev" value that is displayed for each. Choose either the top (TopFirst=1) or bottom (TopFirst=0) clip that has the LOWEST value for Avg Mean Abs Dev.
Use this script to check YV12 material if it has been interlaced Top Field First or Bottom Field First
Code: Select all
function CheckTopFirst(clip v1){
global top_hits=1
global bot_hits=1
global uk_hits=1
global text = ""
global text2 = ""
global text3 = ""
v1 = assumeframebased(v1)
global tff=assumetff(v1).separatefields().bob()
global bff=assumebff(v1).separatefields().bob()
istff = tff.subtitle("Is frame TFF: TRUE").frameevaluate("top_hits=top_hits+1.0")
isnottff = tff.subtitle("Is frame TFF: FALSE").frameevaluate("bot_hits=bot_hits+1.0")
isunknown = tff.subtitle("Is frame TFF: Unknown").frameevaluate("uk_hits=uk_hits+1.0")
outclip = conditionalfilter(tff,istff, isnottff, "yDifferenceFromPrevious(tff)+ydifferenceToNext(tff)","<","yDifferenceFromPrevious(bff)+yDifferenceToNext(bff)",false)
outclip = conditionalfilter(tff,outclip, isunknown, "abs((yDifferenceFromPrevious(tff)+ydifferenceToNext(tff))-(yDifferenceFromPrevious(bff)+yDifferenceToNext(bff)))",">","0.5",false)
outclip = frameevaluate(outclip,"text = "+chr(34)+"STATS: TFF = "+chr(34)+" + string(100.0*top_hits/(top_hits+bot_hits)) + " + chr(34) + "%"+chr(34))
outclip = frameevaluate(outclip,"text2 = "+chr(34)+"STATS: BFF = "+chr(34)+" + string(100.0*bot_hits/(top_hits+bot_hits)) + " + chr(34) + "%"+chr(34))
outclip = frameevaluate(outclip,"text3 = "+chr(34)+"Certainty = "+chr(34)+" + string(100-(100.0*uk_hits/(uk_hits+top_hits+bot_hits-2))) + " + chr(34) + "%"+chr(34))
outclip = scriptclip(outclip, "Subtitle(text,y=50)")
outclip = scriptclip(outclip, "Subtitle(text2,y=70)")
outclip = scriptclip(outclip, "Subtitle(text3,y=100)")
return outclip
}
v=AviSource("C:\video.avi")
CheckTopFirst(v)
Lets assume the video is TFF and that you want to make widescreen (16:9) video.
Good resolution for it would be 640x352 you can use different resolutions if you want but remember that they should allways be multiplies of 16
Also remember that Telecide requires that the input width be a multiple of 2. Deviation from this will cause Telecide to throw an exception.
Do not resize vertically before applying Decomb. Decomb needs to see the original line spacing to properly detect combing.
Code: Select all
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Decomb.dll")
AVISource("C:\video.avi")
AssumeTFF()
ConvertToYV12()
Telecide(guide=2,post=2,vthresh=25,show=false)
LanczosResize(640,352)
Telecide requires YUY2 or YV12 color format as input.
That's why I have added ConvertToYV12() in the script if your source isn't YUY2 or YV12
For BFF just change AssumeTFF() to AssumeBFF()
DecombTutorial wrote:Often you know from the nature of a clip what telecining pattern (if any) is used and therefore what the pattern of field matches should be. Telecide()'s pattern guidance feature uses that information to improve the field matching. Pattern guidance is controlled by the optional guide parameter. It has 4 possible values: guide=0 means disable pattern guidance; guide=1 means use 3:2 pulldown guidance (24fps->30fps); guide=2 means use 2:2 guidance (PAL); and guide=3 means use 3:2:3:2:2 guidance (25fps->30fps).
What does the above script do?DecombTutorial wrote:Postprocessing is the process by which frames that come out of the field matching process still combed can be detected and deinterlaced. The postprocessing modes are controlled by the post parameter: post=0 means disable postprocessing; post=1 means calculate the metrics but don't deinterlace; post=2 means calculate the metrics and deinterlace accordingly; and post=3 means calculate the metrics, deinterlace accordingly, and show a deinterlacing motion map for frames that are detected as combed.
1. Loads Decomb Plugin that is used for deinterlacing
2. Loads the video file called "video.avi" that is located at C:\
3. AssumeTFF() is used to tell to Telecice that video is interlaced TFF
4. Converts the video to YV12 colorspace because Telecide requires YUY2 or YV12 color format to work
5. Telecide() deinterlaces the video (check above quotes and read the DecombReferenceManual and DecombTutorial that came with Decomb Plugin to see what the varibles for it do)
6. Resizes the video to 640x352 using lanczos method you can also use BicubicResize(640,352,1./3,1./3)
For more advanced resizing check this link: http://www.avisynth.org/Resize
You can also use Crop to take lines off the video using it after Resize
Code: Select all
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Decomb.dll")
AVISource("C:\video.avi")
AssumeTFF()
ConvertToYV12()
Telecide(guide=2,post=2,vthresh=25,show=false)
LanczosResize(640,512)
Crop(0,160,-0,-0)
Now all you need to do in VirtualDub is is to open the saved script and adjust the compression settings for XviD
No need to add filters anymore.