Quantcast Avisynth: Mergechroma to Gain Compression? - Page 3 - digitalFAQ.com Forums [Archives]
Go Back    digitalFAQ.com Forums [Archives] > Video Production Forums > Avisynth Scripting

Reply
 
LinkBack Thread Tools
  #41  
02-24-2003, 06:56 PM
dazedconfused dazedconfused is offline
Free Member
 
Join Date: Nov 2002
Posts: 316
Thanks: 0
Thanked 0 Times in 0 Posts
I've been doing a bit of testing today with mergechroma(blur(1.58 )), mergeluma(blur(.6)) and DCTFilter combinations on a 1minute 45second, 4:3 letterboxed movie trailer. Here's my $.02 cents for what it's worth:

  • trailer w/o mergechroma/luma or dctfilter=16.96MB(17,783,324bytes)

    trailer w/ dctfilter(1,1,1,1,1,1,.5, 0) before gripsize()=16.94MB(17,758,656)

    trailer w/ dctfilter(1,1,1,1,1,.5,.5,0) before gripsize()=16.79MB(17,603,76

    trailer w/ mergechroma/luma + dctfilter(1,1,1,1,1,.5,.5,0) before gripsize()=15.85MB(16,621,011)

    trailer w/ mergechroma/luma + dctfilter(1,1,1,1,1,.5,.5,0) before gripsize(resizer="lanczosresize")=16.44MB(17,233,4 59)


I found that using dctfilter(1,1,1,1,1,.5,.5,0) gave better compression than dctfilter(1,1,1,1,1,1,.5,0) with no visual difference(at least not to my eyes, but I'm no pro and don't have an hdtv). I also found that using mergechroma/luma softened the picture a bit too much for me(on my monitor...haven't tried on tv yet), but using lanczosresize sharpened it enough to make it acceptable again (again, to my eyes). Blockbuster "sharpen" increased filesize too much, so that's why I used lanczosresize. Also, I found that switching from TemporalCleaner(my usual preference) to Convolution3D(preset="movieLQ") gave an additional 145,060 bytes of compression, for a total of 16.3MB(17,088,399bytes) versus the original 16.96MB(17,783,324). That's a space-savings of 639,421 bytes on this 105-second trailer. Unless my math is wrong, that would be ~ 42MB of additional saved space per 120-minute movie that could be used towards raising the CQ level a bit, upping the audio bitrate, or adding another 2.5 minutes of movie-time at the same CQ. Might not seem like much, but every bit counts, especially with 1-cd encodes.

I'm wondering how much the mergechroma/luma blur values would have to be lowered before it made sharpening via lanczos or other methods totally unnecessary But would any space-savings then totally disappear at that lower blur value?

Kwag, have you given DCTFilter(1,1,1,1,1,.5,.5,0) a try? This is the recommended setting in the docs. It gives a little more compression and I can't really see a quality difference (but maybe you can! ).
-d&c

script used:
Code:
LoadPlugin("C:\Program Files\AviSynth2\plugins\MPEG2DEC2.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\DecombLegacy.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\LegalClip.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\GripFit_preview.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\DustV5.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\Convolution3D.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\TemporalCleanerOld.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\Sampler.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\Blockbuster.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\DctFilter_YUY2.dll")

Mpeg2Source("E:\trailer\trailer.d2v")
Telecide()
Decimate()
LegalClip()
mergechroma(blur(1.58)) 
mergeluma(blur(0.6))
GripCrop(width=544, height=480, overscan=2, source_anamorphic=false)
GripSize(resizer="lanczosresize")
FaeryDust()
#TemporalCleaner()
Convolution3D(preset="movieLQ")
#Blockbuster(method="sharpen", detail_min=1, detail_max=99, strength=15)
DctFilter(1,1,1,1,1,.5,.5,0)
GripBorders()
LegalClip()
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #42  
02-24-2003, 08:06 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by dazed&confused
Kwag, have you given DCTFilter(1,1,1,1,1,.5,.5,0) a try? This is the recommended setting in the docs. It gives a little more compression and I can't really see a quality difference (but maybe you can! ).
-d&c
I think the DCTFilter works great when used in other situations, but with all the filters above in the script, I really can't tell a difference. I think that using Lanczos without blockbuster sharpen, and lowering the blur on mergeluma, will be the key point to get a sharper picture while retaining a very good compression. What I like about this is that artifacts (Gibbs) are almost gone

-kwag
Reply With Quote
  #43  
02-24-2003, 11:53 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by GFR
What about trying the merge* filters after resize?
You're right GFR. It should make things faster

-kwag
Reply With Quote
  #44  
02-24-2003, 11:55 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by urban tec

Maybe a full movie on one floppy is dreaming but how about on one of the 200mb mini disks this could have ramifactions for the pocket pc encodes
With these techniques, I think we can now easily put a 45 to 50 minute episode with KVCD 352x240 PLUS on one of those little CD-Rs

-kwag
Reply With Quote
  #45  
02-25-2003, 06:50 AM
GFR GFR is offline
Free Member
 
Join Date: May 2002
Posts: 438
Thanks: 0
Thanked 0 Times in 0 Posts
Kwag,

As I understand, MergeLuma and MergeChroma allow you to process Luminance and Chrominance separately.

So you could do HEAVY filtering on the Chrominance, and moderate filtering on Luminance to get compression gains without making the picture look too much blurry.

If you blur each channel before resizing, not only it's slower but it has less effect. It's more like a pre-resizing anti-aliasing filtering than really smoothing.

I guess if you move the MergeChrominance to after resizing you can get good compression without the need of MergeLuma (or with just really subtle MergeLuma).

BTW you can use more complicated things with the Merge filters like:

MergeLuma(Convolution3D(preset="movieHQ"))
MergeChroma(FaeryDust())

Reply With Quote
  #46  
02-25-2003, 08:48 AM
GFR GFR is offline
Free Member
 
Join Date: May 2002
Posts: 438
Thanks: 0
Thanked 0 Times in 0 Posts
I've tried moving MergeChroma and MergeLuma to after the resize, and filesize dropt a lot, faster encoding, but it got TOO blurier.

Since I didn't want to tweak the blur parameters, I just moved MergeLuma back to before resize, and kept MergeChroma after the resize. The video looks OK but filesize dropt only 40k (I could up CQ 0.1) compared to both Merge's before resize. Still faster.

I guess the best would be both Merge's after resizing for speed, but the Luma blur has to be much gentler then.
Reply With Quote
  #47  
02-25-2003, 10:34 AM
telemike telemike is offline
Free Member
 
Join Date: Jan 2003
Location: Greensboro, NC
Posts: 214
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to telemike
Have we reached a final consensus yet on whether to use these filters and the best settings so us newbies can use it? Also, should have Maud-dib add it to his proggie
Reply With Quote
  #48  
02-25-2003, 10:54 AM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
I'm pretty sure using MergeChroma and MergeLuma AFTER Resize is the way to go... I tried it with these values:

Mergechroma((blur(1.3)
MergeLuma((blur(0.3)

For me this is the way to go, because it doesn't influence the sharpness that much that it's necessary to use Lanczos, and therefor the compression of Bilinear Resize is provided too... Try it out and tell me what you think.
__________________
j3llyG0053
Reply With Quote
  #49  
02-25-2003, 11:47 AM
heyitsme heyitsme is offline
Free Member
 
Join Date: Jun 2002
Location: pullman, WA
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to heyitsme
This is for some people trying to cram too much onto one cd. I am backing up my friends dvds. There is about 6 episodes on each dvd, about 135-143 minutes of movie on each. Well it was my goal to put these on one cd. It wasnt really possible to do this until mergechroma and luma came into the light. I ran these filters after resize, cause it took way too long the other way, and i see no visible difference between the two. But after adding these two filters and dctfilter i was able to raise the cq by 4 from 70.5 to 74.5. I used less chroma luma then kwag and jellygoose but got great results. I was too concerned about sharpness at this low resolution. Here is my script.

Code:
#==============================================#
# -= AviSynth script by MovieStacker v1.0.0 =- #
#==============================================#

LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\Mpeg2Dec.dll")
LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\DecombLegacy.dll")
LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\Convolution3D.dll")
LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\GripFit_preview.dll")
LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\DustV5.dll")
LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\LegalClip.dll")
LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\Sampler.dll")
LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\BlockBuster.dll")
LoadPlugin("D:\Vcd\MovieStacker\MovieStacker\Filters\DctFilter_YUY2.dll")

Mpeg2Source("D:\Friends1\friendsyeah.d2v")
LegalClip()
telecide()
decimate(5)
GripCrop(352, 240, overscan=1, source_anamorphic=false)
GripSize(resizer="lanczosResize")
mergechroma(blur(1.1)) 
mergeluma(blur(0.3)) 
SpaceDust()
Convolution3D(preset="movieHQ")
#BlockBuster(method="sharpen")
DCTFILTER(1,1,1,1,1,.5,.5,0) 
GripBorders()
LegalClip()

Sampler(length=24)
## MPEG size = ((Total frames/MovieTimeInMinutes)/24) * MPEG sample file size * .98 ##
Branden
__________________
Eat drink and be merry for tomorrow we die
Reply With Quote
  #50  
02-25-2003, 12:25 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Hi guys,

The only change I've done so far is this:

mergechroma(blur(1.58 ))
mergeluma(blur(0.2))


And of course changing the order of these filters AFTER the resizing.
I'm still trying with Lanczos, because I see that using bilinear resize is to soft.

@heyitsme,

Your script is very similar to the one I'm using . Only that I have also been using NoMoSmooth and FluxSmooth. Here it is:


Code:
LoadPlugin("C:\encoding\mpeg2dec.dll")
LoadPlugin("C:\encoding\GripFit_preview.dll") 
LoadPlugin("C:\encoding\blockbuster.dll") 
LoadPlugin("C:\encoding\legalclip.dll") 
LoadPlugin("C:\encoding\sampler.dll") 
LoadPlugin("C:\encoding\dustv5.dll") 
LoadPlugin("C:\encoding\temporalcleanerold.dll")
LoadPlugin("C:\encoding\nomosmooth.dll")
LoadPlugin("C:\encoding\fluxsmooth.dll")
LoadPlugin("C:\encoding\convolution3d")
LoadPlugin("C:\encoding\dctfilter_YUY2.dll")
LoadPlugin("C:\encoding\decomb.dll")

Mpeg2Source("K:\S1M0NE_WS\VIDEO_TS\simone.d2v")
LegalClip() 

GripCrop( width=528, height=480, overscan=2 ) 
GripSize(resizer="lanczosresize") 

mergechroma(blur(1.58)) 
mergeluma(blur(0.2)) 
SpaceDust()
FluxSmooth(7,7)
NoMoSmooth(40,1,6,1,3,false)
Convolution3d(preset="movieHQ")
DctFilter(1,1,1,1,1,1,.5,0)

GripBorders() 
LegalClip() 
Sampler(length=24)
And this is still not a final

-kwag
Reply With Quote
  #51  
02-25-2003, 12:55 PM
heyitsme heyitsme is offline
Free Member
 
Join Date: Jun 2002
Location: pullman, WA
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to heyitsme
@ Kwag what kind of filters are fluxsmooth and NomoSmooth, and would it affect sharpness? The problem is that the Friends DVD lacks sharpness. So when i bring it down to vcd res it looks a little soft. So i am trying to come up with a good script that would compress well, but wont destroy the sharpness.
__________________
Eat drink and be merry for tomorrow we die
Reply With Quote
  #52  
02-25-2003, 01:34 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by heyitsme
@ Kwag what kind of filters are fluxsmooth and NomoSmooth, and would it affect sharpness? The problem is that the Friends DVD lacks sharpness. So when i bring it down to vcd res it looks a little soft. So i am trying to come up with a good script that would compress well, but wont destroy the sharpness.
From SansGrip's documents:

NoMoSmooth:
When it comes to smoothers (as opposed to smoothies) there are two main varieties: temporal smoothers and spatial smoothers. Temporal smoothers work by looking at frames surrounding the current one and averaging corresponding pixels together if they're deemed similar enough (and thus likely to be noise). Spatial smoothers work in a similar way, except they look at nearby pixels within the same frame. A few filters are a hybrid of the two, including this one and the excellent Convolution3D.

Each approach has its advantages and disadvantages. The great thing about temporal smoothers is that they do a fantastic job getting rid of noise when you set them up just right, but they can also generate some very ugly artifacts, particularly when dealing with motion. Spatial smoothers, on the other hand, can be quite destructive to the details in your image, but are great with high-motion areas because those have few details and are moving too quickly to notice artifacts anyway.

Ideally, then, one would like to apply a temporal smoother to relatively static areas and a spatial smoother to moving ones. That's what this filter tries to do, and the aim is for a higher quality result (i.e. less noticible smoothing) than Convolution3D but with correspondingly less of an impact on compressibility.

In addition to this motion-based approach, NoMoSmooth employs another technique to try to retain as much existing detail as possible: only pixels that are "fluctuating" are smoothed. In other words, given three frames in a row with the current one in the centre, the pixel being examined will only be considered for either type of smoothing if it is either greater than both the corresponding pixels in the previous and next frames, or less than both. This could be considered a very simplistic "noise detector" and seems to help reduce temporal smoothing on important details such as those in skin tones.

FluxSmooth:
One of the fundamental properties of noise is that it's random. One of the fundamental properties of motion is that it's not. This is the premise behind FluxSmooth, which examines each pixel and compares it to the corresponding pixel in the previous and last frame. Smoothing occurs if both the previous frame's value and the next frame's value are greater, or if both are less, than the value in the current frame.

I like to call this a "fluctuating" pixel, then I like to wipe that pixel from existence by averaging it with its neighbours. This is (by default) done in a spatio-temporal manner, in that for each fluctuating pixel its 8 immediate spatial neighbours as well as its 2 temporal neighbours (the abovementioned corresponding pixel from the previous and next frames) are considered for inclusion in the average. If the value of each pixel is within the specified threshold, it is included. If not, it isn't.

This filter seems to remove almost all noise from low-noise sources (such as DVD) and a lot of noise from high-noise sources (such as cable TV captures), while maintaining a good amount of detail.

The speed at which it operates depends upon the amount of noise in the clip.

----------------- End ------------------------

-kwag
Reply With Quote
  #53  
02-26-2003, 02:40 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Here's the S1M0NE sample, encoded again with the last .avs I posted above: http://www.kvcd.net/s1m0ne-result.mpg
The complete video size was 688,350MB
Muxed with audio, 795,650MB.
Used CQ=70.5 KVCDx3
That's what the complete movie looks like on one CD

-kwag
Reply With Quote
  #54  
02-26-2003, 08:48 AM
GFR GFR is offline
Free Member
 
Join Date: May 2002
Posts: 438
Thanks: 0
Thanked 0 Times in 0 Posts
I've got a feeling that a somewhat generous dose of MergeLuma and MergeChroma may help a lot when encoding anime/cartoons.
Reply With Quote
  #55  
02-26-2003, 10:24 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by GFR
I've got a feeling that a somewhat generous dose of MergeLuma and MergeChroma may help a lot when encoding anime/cartoons.
Any volunteers , because I don't do animes

-kwag
Reply With Quote
  #56  
02-26-2003, 04:22 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Jellygoose
what is DCT Filter doing?
This may have been answered further in the thread already, but I can't be bothered to look and then come back .

DCTFilter does a discrete cosine transform of the data, then filters in the frequency domain, then converts the data back to pixels. Basically it's quantizing specific frequencies in order to gain compressibility. If you crank up the strength parameters you'll see what happens -- it'll get blocky because you're taking out most of the high-frequency information.

Tom Barry, the author, hasn't done much with it because it turned out to be not so useful with XViD (though this might have changed in my absence). That's not to say it won't work good with TMPGEnc, though. It needs to be tested.
Reply With Quote
  #57  
02-26-2003, 04:37 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
As someone pointed out earlier, MergeChroma and MergeLuma can be used in combination with any other filters. It's often possible to apply extremely heavy filtering to the chroma components without losing noticible detail, because the eyes are much less sensitive to detail in the chroma components.

For example, while kwag finds PixieDust too strong for DVD sources, it probably isn't if it's only applied to chroma:

Code:
Mpeg2Source("blah.d2v")
...

# Do over-the-top chroma smoothing

chroma = PixieDust()
chroma = chroma.TemporalSoften(...)
chroma = chroma.Blur(...)
chroma = chroma.DctFilter(...)

# Do luma smoothing

FaeryDust()
...

# Now merge the two together

MergeChroma(chroma)
...
Obviously I'm exaggerating somewhat, but you get the idea.

Remember also that

Code:
Mpeg2Source("blah.d2v")
...
MergeChroma(Blur(1.5))
MergeLuma(Blur(0.2))
...
is the same as

Code:
Mpeg2Source("blah.d2v")
...
chroma = Blur(1.5)
Blur(0.2)
MergeChroma(chroma)
...
There's nothing magical about "MergeLuma(Blur(...))" as opposed to a simple "Blur(...)". This is why things might start looking, er, blurry if you use too high a value .
Reply With Quote
  #58  
02-26-2003, 04:50 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by SansGrip
Code:
Mpeg2Source("blah.d2v")
...

# Do over-the-top chroma smoothing

chroma = PixieDust()
chroma = chroma.TemporalSoften(...)
chroma = chroma.Blur(...)
chroma = chroma.DctFilter(...)

# Do luma smoothing

FaeryDust()
...

# Now merge the two together

MergeChroma(chroma)
...
Question here! Isn't chroma being assigned 4 times , so then when you call MergeChroma(chroma), it's only applying the last assignment value which is chroma.DctFilter(...)

-kwag
Reply With Quote
  #59  
02-26-2003, 05:03 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
Question here! Isn't chroma being assigned 4 times , so then when you call MergeChroma(chroma), it's only applying the last assignment value which is chroma.DctFilter(...)
Think of the "chroma = chroma.XXX" lines are variable assignments. This code:

Code:
PixieDust()
TemporalSoften(...)
Blur(...)
DctFilter(...)
is simply a short way of saying:

Code:
last = last.PixieDust()
last = last.TemporalSoften(...)
last = last.Blur(...)
last = last.DctFilter(...)
where "last" is a special variable representing the result of the last filter. It's used by default if no clip is specified either via member selection ("last.SomeFilter(...)") or passing the clip as a parameter ("SomeFilter(last, ...)").

So the four lines dealing with chroma above are simply running those filters as usual except instead of using the "last" clip, it uses the clip stored in the "chroma" variable. This way "last" is left untouched, and in this example will contain the output from Mpeg2Source (or the last filter preceeding the first "chroma = " line).

Because DctFilter is applied to the clip stored in the "chroma" variable (which is in turn the result of the Blur filter, which is the result of the TemporalSoften filter, etc.), the "chroma" variable ends up containing the same result as if you'd done this:

Code:
chroma = PixieDust().TemporalSoften(...).Blur(...).DctFilter(...)
and when you do the final MergeChroma, the chroma part of the "last" variable is replaced with the chroma from the "chroma" variable.

I hope that makes sense. The short answer to your question is "no" .
Reply With Quote
  #60  
02-26-2003, 05:40 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, so each assignment is actually an "append"

Thanks,
-kwag
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Avisynth: New compression filters? tengo6dedos Avisynth Scripting 17 04-27-2008 02:56 PM
Avisynth: Good compression? muhali3 Avisynth Scripting 10 10-14-2003 05:18 PM
Avisynth: Is there a filter for increasing compression even more? audioslave Avisynth Scripting 70 08-08-2003 08:39 AM
Avisynth: mergeLuma and mergechroma? Wolfi Avisynth Scripting 7 05-05-2003 04:38 AM
Avisynth: Increasing compression through preprocessing SansGrip Avisynth Scripting 67 01-29-2003 11:00 AM




 
All times are GMT -5. The time now is 05:15 PM  —  vBulletin © Jelsoft Enterprises Ltd