digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: CQ Matic static script? (http://www.digitalfaq.com/archives/avisynth/6329-avisynth-cq-matic.html)

audioslave 10-25-2003 03:18 PM

Avisynth: CQ Matic static script?
 
I saw you posted a static script in the CQ Matic section of the forum. To not be totally off topic I decided to post my questions here instead.
The script you posted was this:
Quote:

BlindPP(cpu=4)
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(...)
Undot()
TemporalSoften(2,7,7,3,2)
DCTFilter(1,1,1,1,1,1,0.5,0)
AddBorders(...)
I tried it on "The Matrix Reloaded" and got a higher CQ than with the latest Optimal Script :!: Great work, man! Are there anything more I can do with the script to gain a few CQ units? What is your oppinion on adding the MergeChroma/Luma lines? The movie is watchable with a CQ of 56,36 but it would be nice if the CQ was up in the 60's.
Can't wait for your reply! :)

P.S. I will be away for a couple of hours (cover band gig) but I will rejoin the forum after we're done. :wink:

Dialhot 10-25-2003 07:57 PM

Sorry for the delay :-)

I also had good impact on the CQ for a couple of encoding a did with this script. The only fear I have is that usually a gain in CQ is the result of a loss in details.

It seems in this case that it is not the case. So the script seems quite good. Now, if you had too much filter after that perhaps it will be "too much".

I'm pretty sure you can had a blur on the chroma, but a blur on the luma... I don't know. That have to be tested :-)

Note: you can also use BicubicResize insteed of LanczosResize. You will gain 1 or 2 point on your CQ.

audioslave 10-25-2003 08:56 PM

I'm back...
Okay, guess I will be up all night testing then :)
Yes, I really think your static script preserves the details very well! Surprisingly well, in fact. I will try encoding with both MergeChroma and MergeLuma just to see how it turns out.
While I'm at it, do you use 2000 for max. bitrate and 300 for min. bitrate with the script (480x576 resolution). And do you use CalcuMatic to get the average bitrate for CQMatic?
Sorry to bother you with all these questions, but I got VERY excited when I tried the script.

kwag 10-25-2003 09:01 PM

Hi audioslave,

I wouldn't use anything less that 2,500Kbps, if I'm not using the MA script.
With a static script, you won't gain compresion on high speed scenes, and you will have some visible macro blocks if you use a MAX of 2,000Kbps.
If you use the MA scrip, or a combination of dialhot's script with some MA lines included, then you can lower your MAX to 2,000Kbps.

-kwag

audioslave 10-25-2003 09:04 PM

Good evening kwag! Glad to see someone else but me is awake at this late hour (03:02 in Sweden). Okay, then I have to change the bitrate coz I did a test encode with 2000 MAX and I did get some blocks. Not much, but they were clearly there.

kwag 10-25-2003 09:12 PM

Try something like this:

Code:

BlindPP(cpu=4)
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(...)
Undot()
SwitchThreshold = (Width<=352) ? 3 : (Width<=480) ? 2 : 1
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= SwitchThreshold ? \
unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
STMedianFilter( 3, round(3/nf), 1, 1 )
DCTFilter(1,1,1,1,1,1,0.5,0)
AddBorders(...)

See what that does ;)

-kwag

audioslave 10-25-2003 09:15 PM

Great! Thanks a lot. Will try it right away. :wink:

Dialhot 10-25-2003 09:18 PM

Quote:

Originally Posted by audioslave
While I'm at it, do you use 2000 for max. bitrate and 300 for min. bitrate with the script (480x576 resolution). And do you use CalcuMatic to get the average bitrate for CQMatic?

As I told you in an other thread, I did 3 movies, but only remember two of them :

1 PAL 25fps 544*576 1h28 min=64 max=2300 CQ=79 (:!:)
1 NTSC 23.976fps 480*480 1h38 min=64 max=2200 CQ=71
(I used 3:2 pulldown while playback for this one)

For both of them I used calcumatic for finding the average setting for an audio bitrate of 128 kb/s and a target size of 807 MB.

CQmatic found the correct CQ and gave me two movie of 796 and 802 MB in near 5 hours for each movie (on a P4 1.3Ghz).

Smart, quick and perfect :-)

audioslave 10-25-2003 09:21 PM

Hmmm, "Parse error: string missing closing quotation mark (line 11, column 46)"...???

Quote:

## Test script ##

MPEG2Source("D:/Rippat/Reloaded/The Matrix Reloaded.d2v")

BlindPP(cpu=4)
ConvertToYUY2()
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(448, 302, 6, 76, 708, 424)
Undot()
SwitchThreshold = (Width<=352) ? 3 : (Width<=480) ? 2 : 1
ScriptClip("nf = YDifferenceToNext()"+chr(13)+"nf >= SwitchThreshold ? \
UnFilter(-(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
STMedianFilter(3, round(3/nf), 1, 1)
DCTFilter(1, 1, 1, 1, 1, 1, 0.5, 0)
AddBorders(16, 137, 16, 137)
ConvertToRGB24()
EDIT: @Dialhot. You didn't get any macroblocks with 2300 MAX bitrate?

Dialhot 10-25-2003 09:27 PM

Quote:

Originally Posted by kwag
Code:

ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= SwitchThreshold ? \
unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
STMedianFilter( 3, round(3/nf), 1, 1 )

See what that does ;)

Be careful : 3/nf with nf < 3 is something between [1,inf[. You should put a limit there !
Something like :
Code:

STMedianFilter( 3, fmin(32,round(3/nf)), 1, 1 )

kwag 10-25-2003 09:29 PM

:oops: Sorry :!:
Wrong Cut&Paste :x
Try this:

Code:

## Test script ##

MPEG2Source("D:/Rippat/Reloaded/The Matrix Reloaded.d2v")

BlindPP(cpu=4)
ConvertToYUY2()
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(448, 302, 6, 76, 708, 424)
Undot()
SwitchThreshold = (Width<=352) ? 4 : (Width<=480) ? 3 : 2
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= SwitchThreshold ? \
unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")
STMedianFilter(3, 3, 1, 1)
DCTFilter(1, 1, 1, 1, 1, 1, 0.5, 0)
AddBorders(16, 137, 16, 137)
ConvertToRGB24()

-kwag

kwag 10-25-2003 09:31 PM

Quote:

Originally Posted by Dialhot
Something like :
Code:

STMedianFilter( 3, fmin(32,round(3/nf)), 1, 1 )

Sorry again, should have read: STMedianFilter( 3, 3, 1 , 1) because it's outside the MA part :)

-kwag

Dialhot 10-25-2003 09:32 PM

Quote:

Originally Posted by audioslave
Hmmm, "Parse error: string missing closing quotation mark (line 11, column 46)"...???

Look at the optimal MA script and you will see that you missed ") on the next lineafter StMedianfilter.
Quote:

EDIT: @Dialhot. You didn't get any macroblocks with 2300 MAX bitrate?
In very rare cases. I always used 2300, never 2500. I don't really know why.

audioslave 10-25-2003 09:37 PM

So, kwag, the script should look something like this?
Quote:

nf=0

MPEG2Source("D:/Rippat/Reloaded/The Matrix Reloaded.d2v")

BlindPP(cpu=4)
ConvertToYUY2()
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(448, 302, 6, 76, 708, 424)
Undot()
ConvertToYV12()
SwitchThreshold = (Width<=352) ? 4 : (Width<=480) ? 3 : 2
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= SwitchThreshold ? \
UnFilter(-(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften(fmin( round(2/nf), 6), round(1/nf), round(3/nf), 1, 1)")
STMedianFilter(3, 3, 1, 1)
AddBorders(16, 137, 16, 137)
DCTFilter(1, 1, 1, 1, 1, 1, 0.5, 0)
ConvertToRGB24()

function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2
}

kwag 10-25-2003 09:40 PM

Yes. that should do it.
It's too much filtering for me :mrgreen:
But if you really want to cram the most "Bang for the buck" ( :lol: ), that should squeeze the crap out of your movie :D

-kwag

Dialhot 10-25-2003 09:47 PM

Quote:

Originally Posted by audioslave
BlindPP(cpu=4)
ConvertToYUY2() <- YOU DO NOT NEED THIS !
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(448, 302, 6, 76, 708, 424)
Undot()
ConvertToYV12()<- AND THAT EITHER :-) !
SwitchThreshold = (Width<=352) ? 4 : (Width<=480) ? 3 : 2
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= SwitchThreshold ? \
UnFilter(-(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften(fmin( round(2/nf), 6), round(1/nf), round(3/nf), 1, 1)")
STMedianFilter(3, 3, 1, 1)
AddBorders(16, 137, 16, 137)
DCTFilter(1, 1, 1, 1, 1, 1, 0.5, 0)
ConvertToRGB24()

Some comments :

1/ C3D and STMedianfitler are quite the same filters. Really don't need both.
2/ try temporalcleaner insteed of temporalsoften. I find it faster and smarter. (use TemporalCleaner(round(5+nf), round(11+nf))
3/ Normally the last converttoRGB24 is useless. Try without it and let see if TMPGEnc does not complain. All is matter of codecs installed on your PC. I never use it !
4/ Your borders aren't block aligned : you aren't in the best configuration and your CQ suffer from this.
EDIT: 5/ use Bicubic precise if you want to raise a little your CQ

audioslave 10-25-2003 09:47 PM

:D It might be too much for me too. But what the hell, that's a price you'll have to pay for squeezing The Matrix Reloaded (PAL) onto 1 CD-R! :wink:

Dialhot 10-25-2003 09:58 PM

You should also try a CD90min : 100 MB more for your movie :-)

audioslave 10-25-2003 10:11 PM

Yes, that would be fantastic. But my burner doesn't support 90-99min CD-R's :cry:

audioslave 10-25-2003 10:30 PM

Dialhot wrote
Quote:

audioslave wrote:

BlindPP(cpu=4)
ConvertToYUY2() <- YOU DO NOT NEED THIS !
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(448, 302, 6, 76, 708, 424)
Undot()
ConvertToYV12()<- AND THAT EITHER !
SwitchThreshold = (Width<=352) ? 4 : (Width<=480) ? 3 : 2
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= SwitchThreshold ? \
UnFilter(-(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften(fmin( round(2/nf), 6), round(1/nf), round(3/nf), 1, 1)")
STMedianFilter(3, 3, 1, 1)
AddBorders(16, 137, 16, 137)
DCTFilter(1, 1, 1, 1, 1, 1, 0.5, 0)
ConvertToRGB24()



Some comments :

1/ C3D and STMedianfitler are quite the same filters. Really don't need both.
2/ try temporalcleaner insteed of temporalsoften. I find it faster and smarter. (use TemporalCleaner(round(5+nf), round(11+nf))
3/ Normally the last converttoRGB24 is useless. Try without it and let see if TMPGEnc does not complain. All is matter of codecs installed on your PC. I never use it !
4/ Your borders aren't block aligned : you aren't in the best configuration and your CQ suffer from this.
EDIT: 5/ use Bicubic precise if you want to raise a little your CQ
If I don't use the ConvertToX() in my script I get errors. What codecs can I install so I don't have to use these lines?
What do you mean with "Your borders aren't block aligned : you aren't in the best configuration and your CQ suffer from this." How do I correct this?

kwag 10-25-2003 11:28 PM

Quote:

Originally Posted by audioslave
What do you mean with "Your borders aren't block aligned : you aren't in the best configuration and your CQ suffer from this." How do I correct this?

He means this: AddBorders(16, 137, 16, 137)
The borders are not divisible by 16. Where did you get the 137 from :?:

-kwag

audioslave 10-25-2003 11:33 PM

I loaded the d2v file into TMPGEnc and then went to clip frame. I cut the borders out and then entered the numbers in MovieStacker.
Kwag, what codec do I need to be able to run the script without having to use ConvertToX()?

EDIT: Downloading FFdshow right now. Hopefully this codec will solve the issue.
EDIT 2: Nope, didn't work... :cry:

audioslave 10-26-2003 12:22 AM

Can this thing be related to that I demuxed the VOB's in DVD2AVI as RGB? Shall I demux as YUV instead?

bman 10-26-2003 04:10 AM

@ AudioSlave
To gain 2-3 CQ points try : min - 100 & and max - 2500 ( as DialHot suggested )
U'll get CQ close to 60 or even more :wink: :wink: :wink: !!!
bman

Dialhot 10-26-2003 06:24 AM

Okay, let see point after point.

1/ it is not possible you have error without the converts :
- blindPP need to be in YV12 so you are in such colorspace when you reach this line
- Convolutin3d has a YV12version called "Convolution3DYV12.dll". Do you have it ?
- Undot also work in YV12 colorspace

==> no need to convertToYUY2 then back to YV12 :!:

2/ FFDshow is a DIRECTSHOWFILTER and whatever you set in it, it will never affect your encoding has avisynth use CODECS only !
(except if you use "directshowsource" in the script, or if you uncheck the ReadAVS.dll in tmpgenc and you work in DirectShow mode in it. But that i sHIGHLY recommended to not do that.

3/ for finding your borders, use moviestacker ! This tool is for that ! And more, with avs2.52, Moviestacker has only ONE purpose : to determinate the borders :-)

4/ yes, you have to demux as YUV. At least, that what I always do but I don't really know what is the impact there.

audioslave 10-26-2003 02:34 PM

I've just downloaded the correct version of Convolution3D (YV12) and it works like a charm :D No more color space errors. Thank you for your help. I'm also test encoding the script with MergeChroma and MergeLuma to see how much I gain in compression and to find out how the quality is effected.
I also re-demuxed the movie to YUV colorspace (instead of RGB), and got correct resizing values from MovieStacker (as far as I know).
So, this is how my (Dialhot's) script currently look:
Quote:

## Static script ##

MPEG2Source("D:/Rippat/Reloaded/The Matrix Reloaded (YUV).d2v")

BlindPP(cpu=4)
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(448, 414, 9, 0, 702, 576)
Undot()
TemporalSoften(2, 7, 7, 3, 2)
MergeChroma(blur(1.50))
MergeLuma(blur(0.1))
AddBorders(16, 81, 16, 81)
DCTFilter(1, 1, 1, 1, 1, 1, 0.5, 0)
I will post my results as soon as the testing is finished.

Dialhot 10-26-2003 04:48 PM

No, your borders are still not block aligned ! They must be divisible by 16 !
There is a slider in moviestacker to adjust how the margin are fixed : it seems that you choosed "centered" and that is not what you have to do. Choose "block aligned".

PS: I did a test with the blurs and the CQ_VBR raised from 19.27 to 19.37. No a great gain.

audioslave 10-26-2003 05:05 PM

@Dialhot

Thank you for informing me. I'm not very used to MovieStacker, but thanks to you I think I figured it out.
Now the script looks like this:
Quote:

MPEG2Source("D:/Rippat/Reloaded/The Matrix Reloaded (YUV).d2v")

BlindPP(cpu=4)
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)
LanczosResize(448, 416, 11, 0, 698, 576)
Undot()
TemporalSoften(2, 7, 7, 3, 2)
MergeChroma(blur(1.50))
MergeLuma(blur(0.1))
DCTFilter(1, 1, 1, 1, 1, 1, 0.5, 0)
AddBorders(16, 80, 16, 80)
Is this correct?

EDIT: Oh, I forgot. I also removed the MergeChroma/Luma lines.

Dialhot 10-26-2003 05:20 PM

It seems perfect :-)

audioslave 10-26-2003 05:55 PM

Phew. At last... :D
I used the script I posted in my lastest reply, and this is what I found out:
(I ran prediction with CQMatic)

* Without MergeChroma, MergeLuma I got CQ 57,43.
* With MergeChroma, MergeLuma I got CQ 58,72.

That's not bad for a 132 minutes PAL movie in SVCD resolution (480x576). :D
Is it worth using MergeChrom/Luma to gain ~1.3 in CQ :?: My guess would be that it's better to use BicubicResizer than MergeChroma/Luma to gain a few CQ points, but I would like to know what you guys think.

Thank you VERY much for all your help so far, Dialhot and kwag :!: :wink:

Edit: I used 64 for MIN bitrate and 2500 for MAX bitrate.

Dialhot 10-26-2003 06:53 PM

I think a raise in CQ than more than .5 point woths the work.

Using bicubic will affect the visual result more than using the mergechroma/luma blur. It's better to keep your script as it is now.

audioslave 10-26-2003 07:03 PM

Okay, then I guess the testing phase is over. :D Time for the real encode.
Thank you once again. :wink:

incredible 10-26-2003 07:03 PM

Quote:

Originally Posted by audioslave
AddBorders(16, 81, 16, 81)

Well gentlemen borders with a height of 81 isn't that bad as it seems theoretically ;-)

CAUSE! There seems to be a bug im TmpgENc refering to macroblock orientated border encoding.
So as its shown above the perfect borders at top and bottom each should be a result devidable by 16 +1

In this thread I quoted a site where its very well explained and proofed :wink:
http://www.kvcd.net/forum/viewtopic.php?t=6070

But I think woun't give you that amount of CQ advantage.

audioslave 10-26-2003 08:21 PM

Here we go again... My previous prediction was made with the intention of using 128kbps audio. I made a new prediction for 112kbps audio. And what do you know, the CQ jumped up to 62,55 and the quality of the movie is quite amazing if you consider it's 132 minutes long :!:

Edlund 10-27-2003 04:23 AM

Quote:

Originally Posted by audioslave
Yes, that would be fantastic. But my burner doesn't support 90-99min CD-R's :cry:

Have you tried this: in Nero->Preferences->General->uncheck "Start with new compilation" + "Check for correct disc format before burning" + "Check joilet filenames before burning" AND in Nero->Preferences->Expert features enable overburn 99 minutes?

When I first did this I recorded succesfully a 90 min cd which then played flawless on my dvd-player. The strange thing is that when I tried this second time Nero didn't accept the 90 min cd.
Anyway a 90 min cd costs here as much as two 80 min cds so this is not a big problem:)

audioslave 10-27-2003 09:35 AM

Hi Edlund! No, I haven't tried your suggestion yet. But you can be sure I will. If this works I will be SO happy! Thanks for the tip. :wink:

cweb 02-02-2004 10:14 AM

Quote:

Originally Posted by Dialhot
2/ try temporalcleaner insteed of temporalsoften. I find it faster and smarter. (use TemporalCleaner(round(5+nf), round(11+nf))

I know this is old -- but was this correct? It doesn't seem to be, for me at least... I tried to use temporalcleaner in the MA script but it slowed down the encode by 2000%!

ScriptClip(" nf = YDifferenceToNext()" +chr(13)+ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ).TemporalCleaner( round(5+nf), round(11+nf)) ")

Edit: oops - the big delay was due to my replacing of STMedianFilter with MipSmooth... That was way slow..
I replaced it back, and I'm using temporalcleaner now... it's fast again...

Dialhot 02-02-2004 10:33 AM

note : I never tried to use temporalcleaner on the last version of MA script.

Before we had "unfilter ? temporalsoften", and now "Unfilter.temporalsoften". The results with temporalcleaner can be different.

cweb 02-02-2004 04:19 PM

Quote:

Originally Posted by Dialhot
note : I never tried to use temporalcleaner on the last version of MA script.

Before we had "unfilter ? temporalsoften", and now "Unfilter.temporalsoften". The results with temporalcleaner can be different.

The CQ result didn't look bad..
I haven't made a comparison with both methods however...

bigggt 02-02-2004 07:34 PM

@ Dialhot

could you please post your script here that you use for dvd rips.there was too many different versions in this thread so i'm not sure which one you use now.

Thanx


All times are GMT -5. The time now is 07:58 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.