Compressing video files (advanced)

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 files (advanced)

Post by Tonttu » February 16th, 2006, 12:08 pm

Here is an advanced way of compressing video files to XviD
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?
http://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.
First you need to install the programs/codecs
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)
Open the script with VirtualDub and play the video few seconds and it tells you if the video is TFF or BFF

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)
If AVISource("C:\video.avi") doesn't work you can use DirectShowSource("C:\video.avi")

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).
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.
What does the above script do?
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)
This script would result to same resoultion (640x352) but it takes 160 lines off at top of the video; Crop(left,top,right,bottom)

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.

Pedsdude
Site Admin
Site Admin
Posts: 15908
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » February 16th, 2006, 5:56 pm

Very nice m8 - made it a sticky ;)
Image
Image

User avatar
St.Anger
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 431
Joined: November 7th, 2005, 3:28 pm
Location: Den Hague - Netherlands
Contact:

Post by St.Anger » February 17th, 2006, 12:44 pm

Very nice tut.

For those who what to know more about this.

http://www.videohelp.com
St.Anger [TW]

Image
Image

chelseamm
CJ Wannabe
CJ Wannabe
Posts: 1
Joined: April 15th, 2006, 9:34 pm
Location: England

Post by chelseamm » April 15th, 2006, 9:46 pm

Hey
Can any one here tell me how to watch the cod jumper videos?? No matter what i click it wont open and i downloaded lots of different video players to try it but nothing has worked yet. Any one know plz reply or email me at michaelmoss88@hotmail.com because enjoy jumping meself and want to view new ways but cant. Thanks

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » April 15th, 2006, 11:26 pm

1) Wrong place to post

and

2)
Image
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

Soviet
Core Staff
Core Staff
Posts: 7760
Joined: April 23rd, 2005, 9:12 pm
Location: Plano, Texas
Contact:

Post by Soviet » April 16th, 2006, 2:20 pm

and 6, spam being deleted as this is a sticky
Image
ImageImageImage
Image
"Zaitsev is a cunt." - Pedsdude

User avatar
[SoE]_Zaitsev
Core Staff
Core Staff
Posts: 14220
Joined: October 21st, 2004, 7:17 pm
Location: Holland
Contact:

Re: Compressing video files (advanced)

Post by [SoE]_Zaitsev » October 11th, 2008, 10:37 am

Damn this bot >_>
matt101harris wrote:big cock was the first thing that came to my head lol

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Re: Compressing video files (advanced)

Post by JDogg » October 11th, 2008, 12:01 pm

[SoE]_Zaitsev wrote:Damn this bot >_>
I love it.
Image
Image

User avatar
[SoE]_Zaitsev
Core Staff
Core Staff
Posts: 14220
Joined: October 21st, 2004, 7:17 pm
Location: Holland
Contact:

Re: Compressing video files (advanced)

Post by [SoE]_Zaitsev » October 11th, 2008, 1:56 pm

I deleted all posts apart of one so you know what profile to delete.
matt101harris wrote:big cock was the first thing that came to my head lol

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Compressing video files (advanced)

Post by Drofder2004 » October 11th, 2008, 3:42 pm

Just delete the post and pretend nothing happened.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Compressing video files (advanced)

Post by Drofder2004 » October 12th, 2008, 1:50 pm

KillerSam wrote:
Drofder2004 wrote:Just delete the post and pretend nothing happened.
I can't delete the bot then.
Why not?

Admin Panel < Members < Delete?
or do you mean, if you do not see the bot, you wouldn't know one needed deleted?

---

In that case.
- Edit Bots Post
- Temporarily lock thread (to avoid further spam)
- Delete bot
- Unlock thread
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pedsdude
Site Admin
Site Admin
Posts: 15908
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Compressing video files (advanced)

Post by Pedsdude » October 12th, 2008, 3:14 pm

How about a separate hidden forum to move bot posts into?
Image
Image

Pedsdude
Site Admin
Site Admin
Posts: 15908
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Compressing video files (advanced)

Post by Pedsdude » October 12th, 2008, 5:58 pm

I know, I can't be bothered to do it so won't be enacting it myself. It's probably the most effective solution, though.
Image
Image

User avatar
Lancast
CJ Worshipper
CJ Worshipper
Posts: 360
Joined: October 23rd, 2009, 1:56 am

Re: Compressing video files (advanced)

Post by Lancast » October 23rd, 2009, 1:59 am

God tut for newbies but this is not advance. Xvid first of all is not advance, and this is too much messing around, there are many other formats that can get way better quality and smaller size, and example: x264. Use program called, Mediacoder, few clicks u compress the video, the size is extremly small and no quality loss.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 9 guests