View Full Version : SemiAutoCropAndResize script for DVD2SVCD
gerti67
15th June 2003, 16:32
Hi there,
I made a little script to share here and for testing and opinions from you out there. ;)
Get it at: SemiAutoCropAndResize v1.06 (http://www.gerti67.de.vu/files/SemiAutoCropAndResize v1.06.zip)
See the Readme.txt for more on that.
SemiAutoCropAndResize v1.06 - Readme.txt
========================================
1. What is SemiAutoCropAndResize ?
----------------------------------
SemiAutoCropAndResize first is an AviSynth 2.5 script for DVD2SVCD. I wrote this little
script to increase encoding speed and to slightly increase picture quality too. this is
achieved by leaving out the TV overscan area during encoding, so the used bitrate can be
allocated better by the encoder to other parts. I know there's RB's outrageous AutoFitCD
plugin or even FitCD from shh, but my goal always was and is to just crop without slightly
zooming out of the movie like FitCD does. With FitCD's method you will see a little more
of the movie that usually is hidden inside the overscan area, but this minimal resizing
can cause blurring and/or moirée effects - see "Nyquist effect" for more on that.
Furthermore, when watching your DVD on your standalone, you will also only see the part this
script feeds to the encoder, so you will not loose anything it's nearly a 1:1 copy. You can
achieve this with FitCD too, but I always found it a litle hazzle to make FitCD act the way
I wanted to crop - just stupidly blank the overscan area. For this reason I made this little
script. ;)
2. Installation
---------------
You need the AviSynth 2.5 "AutoCrop" plugin by Glenn Bussell
(at http://www.videofringe.com/autocrop). I've already bundled the AviSynth 2.5 version
of this plugin already in this package as the unmodified "AutoCrop11.zip" file.
1. Step: Unzip the "SemiAutoCropAndResize.zip" file.
2. Step: Unzip the contained "AutoCrop11.zip" file and copy it to the
DVD2SVCD\AviSynth2.5 Plugins\AutoCrop folder (create it if necessary)
3. Step: Copy the "SemiAutoCropAndResize.avs" file to this folder too.
4. Step: Open the "SemiAutoCropAndResize.ini" file, mark all, paste it at the end of the
"dvd2svcd.ini" in your DVD2SVCD folder and save the changes.
5. Step: Run DVD2SVCD, go to "Frameserver" tab and chose the "AutoDetectBorders" script.
At the "LoadPlugin("")" command enter the correct path to the "AutoCrop.dll".
Close DVD2SCVD, otherwise the changes will not be saved correctly.
6. Step: Again, run DVD2SVCD, go to "Frameserver" tab and now chose the "SemiAutoCropAndResize"
script. Scroll down in "AviSynth command" and at "LoadPlugin("")" enter the path to the
"SimpleResize.dll" (make sure it's the AviSynth 2.5 version). At "Import("")" enter the
path to the "SemiAutoCropAndResize.avs" and again close DVD2SVCD for the changes to be
saved correctly.
7. Step: You're done! Now you can use DVD2SVCD the way you want and the way you always did.
3. How to use
-------------
Very easy and quickly:
1. Step: Run DVD2SVCD as usual and load an IFO file at "Conversion" tab.
2. Step: Go to "Frameserver" tab and chose the "AutoDetectBorders" script. Now go
back to "Conversion" tab and hit "Go!|Preview video (still picture)" -
a preview window with a video still appears with the motion area framed by
white lines and some pixel values in the top left corner. Just note down
the "Top" and the "Height" value - nothing else. If the borders weren't
detected correctly hit "New Frame" until they're correctly detected or
adjust the "Threshold" value for the script.
3. Step: Hit "Show DVD2SVCD" to bring the program window back on top and now just
chose the "SemiAutoCropAndResize" script in "Frameserver" tab.
At "DetectedTop" enter the noted value for "Top" and at "DetectedHeight"
enter the one for "Height" - that's all!
4. Step: Close the Preview window and start the conversion as usual. Due to the
optimized script you will notice an increase of encoding speed and a
slight improvement of picture quality as well.
4. Editable parameters
----------------------
DetectedTop : Enter the value for "Top" here from the "AutoDetectBorders" script.
DetectedHeigth : Enter the value for "Height" here from the "AutoDetectBorders" script.
BlocksToCropHorizontal : Specifies the number of rows of macroblocks you wish to crop from the
top and bottom. For SVCD/DVD enter "2" and for VCD/CVD just "1" or you might
see some black borders on the top and bottom. (Default = 2)
BlocksToCropVertical : Specifies the number of columns of macroblocks you wish to crop from the
sides. For SVCD/DVD enter "2" and for VCD/CVD just "1" or you might
see some black borders on the left and right. (Default = 2)
BlockOptimization : Adjust the black bars in a way they can be divided by this value without
a rest. So for a value of "16" you will make them aligned to macroblock
boundaries. (Default = 16) If going for VCD and 4:3 it's better to set
it to 8 or the picture might be aligned to the bottom of the screen.
ResizeMethod : 1 = Use BilinearResize
2 = Use BicubicResize with Bicubic_b_Value and Bicubic_c_Value
3 = Use LanczosResize
4 = Use SimpleResize
Bicubic_b_Value : Only needed when using BicubResize (ResizeMethod = 2)
Bicubic_c_Value : Only needed when using BicubResize (ResizeMethod = 2)
GammaCorrection : Gamma correction for the whole clip. Uses AviSynth's "Level" filter.
Be aware, this will slow down the encoding whenever it isn't set at
default value. (Default = 1.0) (Ranges: 0.1 .. 10.0)
Please see AviSynth "Level" reference for more on it .
Hue : Hue correction for the whole clip. Uses AviSynth's "Tweak" filter.
Be aware, this will slow down the encoding whenever it isn't set at
default value. (Default = 0) (Ranges: -180 .. 180)
Please see AviSynth "Tweak" reference for more on it .
Saturation : Saturation correction for the whole clip. Uses AviSynth's "Tweak" filter.
Be aware, this will slow down the encoding whenever it isn't set at
default value. (Default = 1.0) (Ranges: 0.0 .. 10.0)
Please see AviSynth "Tweak" reference for more on it .
Brightness : Brightness correction for the whole clip. Uses AviSynth's "Tweak" filter.
Be aware, this will slow down the encoding whenever it isn't set at
default value. (Default = 0) (Ranges: -255 .. 255)
Please see AviSynth "Tweak" reference for more on it .
Contrast : Contrast correction for the whole clip. Uses AviSynth's "Tweak" filter.
Be aware, this will slow down the encoding whenever it isn't set at
default value. (Default = 1.0) (Ranges: 0.0 .. 10.0)
Please see AviSynth "Tweak" reference for more on it .
DebugMode : You can watch the script's calculations here - in case you don't
trust the fully automated calculations. ;) (Default = 0)
0 = Doesn't show any informationen.
1 = Shows the calculations of the scripts on the upper left. Attention!
2 = Shows even more calculations of the scripts.
5. Remarks
----------
Comments, suggestions and praises or blames to gerti67@abacho.de or just post them at one of
Doom9 forums (at doom9.de or at doom9.org inside the DVD2SVCD sections).
Else, have fun with it,
gerti67
SemiAutoCropAndResize - History.txt
===================================
- v1.06 : - Re-arranged the parameters inside the DVD2SVCD "Frameserver" tab -
they're much better editable now and grouped.
(Thanx to "seeigel" for the tip!)
- Comes now with most recent version v1.1 of Glenn Bussell's AutoCrop Plugin
- TMPGEnc did crash because the "SemiAutoCropAndResize.avs" did not explicitly
return a clip - fixed now! (Thanx to godosan!)
- v1.05 : - First "stable" version of the script with minor bugfixes concerning
VCD resizing.
(Thanx to "Lord Kinbote" for testing and finding them!)
Cheers,
Gerti
Last Edit: 24.06.2003
gerti67
15th June 2003, 20:35
Ups,
almost forgot to mention of course it does not interfere in any way with all the settings you can change in DVD2SVCD - means, it works with PAL and NTSC and automatically detects it from DVD2SVCD's "TargetWidth" and "TargetHeight" parameters which are set by DVD2SVCD. Also you can chose whatever target you want to go for (DVD,SVCD,CVD,VCD combined with 4:3, 16:9 with 4:3 letterboxing, or 16:9 anamorph), the script should always get it right. (Crossing fingers ;))
So after setting it up once, all you have to do is just enter the top of the motion area and the height you got from the "AutoDetectBorders" script that's all.
Perhaps some NTSC guys could test it as I'm doing PAL only and just could test it in "AviSynth emulated mode".
Cheers,
Gerti
Holomatrix
16th June 2003, 15:40
I can't seem to download the file, any problems?
EDIT: got it now. I'll test it out. Thanks
r6d2
17th June 2003, 01:26
Great work, Gerti,
I was using MovieStacker for the same purpose. It lets you choose to resize or overlap the overscan. It also supports AVISynth 2.0x. Then you paste your script into D2S. MovieStacker uses something called SansGrip filters, which select the top and bottom borders automatically.
Your script requires 2.5x. I use 2.0x because it is D2S default's option, and the install program tells you that 2.5x may be buggy and that not every filter is ported.
Do you recommend moving into 2.5x already?
arlsair
17th June 2003, 08:36
AviSynth is with the version 2.5.2 no longer a beta. So it is quite stable and it is fast. And allmost all filters have been ported and improved, but this doesn`t matter, because you can load every AviSynth 2.0x filter in AviSynth 2.5x with LoadPluginEx.
gerti67
17th June 2003, 16:18
Hi folks,
I uploaded a new version of the script because the old one had some minor bugs - get it from the link in my first post:
[list=1]
In a few cases at 4:3 target resolution the cropped height could be incorrect by 1 macroblock row - should be fixed now.
Also with 4:3 target chosen, the picture was not correctly aligned even when BlockOptimization was set to lower values than 16. Fixed now - thanks to Lord Kinbote for reporting it.
At VCD/CVD target resolution I forgot to correct the aspect ratio as those resolutions are based on 704x480/576 and not on 720x480/576 like DVD and SVCD. So the aspect was very slightly wrong (the same way it is when using DVD2SVCD'S default resizing with those target resolutions) - but anyway you can hardly see this - it was about 1%. ;)
Fixed the Readmes for typos.
[/list=1]
Sorry for the inconvenience - but it should now work as intended. For those that already have the old one working, you just have to replace the "SemiAutoCropAndResize.avs" file - wherever you placed it. ;)
Greetz,
Gerti
gerti67
18th June 2003, 14:12
FWIW, I updated the script.
Thanks to Lord Kinbote (via e-mail) I found another little bug with VCD settings - it is now hopefully fixed and can be considered the stable version of the script.
I added support for AviSynth's "Tweak" and "Level" filters, so you can now play with Gamma, Hue, Saturation, Brightness and Contrast correction too.
As long as you leave them at default settings you will not see a decrease in encoding speed as the filter calls are conditional - but if you change the default values you will see a little decrease in encoding speed due to the Tweak and/or Level filter kicking in.
Else, have fun with it,
Gerti
gerti67
18th June 2003, 14:18
Originally posted by r6d2
...Do you recommend moving into 2.5x already?
As arlsair already said, AviSynth 2.5.2 is no longer Beta - for me it is very stable and I won't give up the improved encoding speed you get with it compared to AviSynth 2.x.
So I only tested the script with 2.5 but I guess it should work with 2.x too (just too lazy to test it now ;))- as described in the Readme.txt you only have to use the AutoCrop.dll for AviSynth 2.x from the link I mentioned and you're done.
Greetz,
Gerti
lordkinbote
21st June 2003, 21:50
The VCD setting does now work with no bugs, so now it seems all modes work perfectly. Thanks, Gerti.
Lord Kinbote
DDogg
22nd June 2003, 03:23
G, this is very slick and works well on my last several encodes. Thanks for the work on it as well as a special thanks for the way in which you documented it.
Thank you for a great tool (SemiAutoCropAndResize v1.05)!:cool:
I want to use this script and SemiAutoCropAndResize, because gripfit (the resizer) only suport 480 x 480...
---------------------------------------------------------------
[AVISYNTH_New252 script]
0=LoadPlugin(!Mpeg2Dec3.dll)
1=LoadPlugin(!StMedianfilter.dll)
2=LoadPlugin(!Asharp.dll)
3=LoadPlugin(!Undot.dll)
4=LoadPlugin(!DGBob.dll)
5=LoadPlugin(!Gripfit_yv12.dll)
6=MaxTreshold=^max_threshold
7=nf=0
8=undot()
9=Limiter()
10=asharp(2,4)
11=DGBob(0,true)
12=GripCrop(^TargeitHeight,^TargetWidth,overscan=^overscan,source_anamorphic=^source_ana) ### resize movie
13=GripSize(resizer="BicubicResize")
14=STMedianFilter(^stm1,^stm2,0,0)
15=MergeChroma(blur(^max_threshold))
16=MergeLuma(blur(0.2))
17=ScriptClip("nf=YDifferenceToNext()"+chr(13)+"nf>2.5?asharp(-(fmin((nf/30),1)),0):TemporalSoften(2,7,7,3,2)")
18=GripBorders() ### Add borders
19=Limiter()
20=function fmin(float f1,float f2){return(f1<f2)?f1:f2}
!Mpeg2Dec3.dll=C:\Filters25\MPEG2Dec3.dll
!StMedianfilter.dll=C:\Filters25\STMedianFilter.dll
!Asharp.dll=C:\Filters25\asharp.dll
!Undot.dll=C:\Filters25\UnDot.dll
!DGBob.dll=C:\Filters25\DGBob.dll
!Gripfit_yv12.dll=C:\Filters25\Gripfit_yv12.dll
^max_threshold=1.50
^TargeitHeight=480
^overscan=1
^source_ana=true
^stm1=8
^stm2=32
?asharp=
?f1=
---------------------------------------------------------------
This script is very good when using one pass encoding.
Do you have any ideas????
gerti67
24th June 2003, 20:29
Hi there,
@lordkinbote:
Glad it works now - again, thanks for testing. ;)
@DDogg:
Thanx for testing it - really appreciated your nice comments. ;)
You know, I just thought: better take half an hour to slap this readme together instead of answering a thousand questions - you know what I mean. :D When watching the server stats it got downloaded nearly 300 times now and only a very few questions so far. :cool:
@kru:
Hi and welcome to the forum. You know kru, it can be easily done by yourself. Just insert all your filters before the "GripCrop" right before the "Import("SemiAutoCropAndResize.avs")" command in the "dvd2svcd.ini" section of my script and all filters after the "GripSize" command from your script right after the "Import(.." statement - of course you have to leave out the "GripCrop" and the "GripSize" commands from your script as this is done by my script now.
Please, try it on your own first and if you don't succeed report back - I'm not that much into this script of yours - seems to be one of the KWAG scripts I guess. And I don't have that much time to combine scripts together for everyone asking - hope you understand it. This could easily become a fulltime job. ;)
Cheers,
Gerti
P.S. Ups, almost forgot, I updated the script to version 1.06 - get it from the first post in this thread. All changes are documented in the "History.eng.txt" file. There was a rather severe bug, when using TMPGEnc with it as the "SemiAutoCropAndResize.avs" did not explicitly return a clip to DVD2SVCD's script and TMPGEnc crashed then. It didn't happen with CCE because the "ConvertToYUY2()" that gets inserted by DVD2SVCD prevented this and made the script return a clip then. But it is fixed now.
And secondly, I rearranged the parameters you can edit at "Frameserver" tab - they're now grouped and much better and easier to adjust.
Have fun,
Gerti ;)
r6d2
27th June 2003, 16:12
Originally posted by gerti67
Furthermore, when watching your DVD on your standalone, you will also only see the part this
script feeds to the encoder, so you will not loose anything it's nearly a 1:1 copy.
Hi gerti,
I followed the advice arlsair and you gave me and moved to 2.5. It was a very clean transition. Thanks.
Now let me get this straight... If I understand this correctly, this script crops "exactly" what the standalone player shows when it plays the original DVD, right?
And obviously if it does the above it should always keep the aspect ratio.
Is this correct?
Doesn't FitCD allow you to do the same if you select "Max Width" or "Max Height"? I'm kind of confused... :confused:
Regards,
gerti67
27th June 2003, 16:37
Originally posted by r6d2
... this script crops "exactly" what the standalone player shows when it plays the original DVD, right? ...Yes, exactly.
Originally posted by r6d2
... And obviously if it does the above it should always keep the aspect ratio.
Is this correct? ...Absolutely correct.
Originally posted by r6d2
... Doesn't FitCD allow you to do the same if you select "Max Width" or "Max Height"? I'm kind of confused... :confused: ...Erm, no. FitCD always tries to resize the movie in a way it perfectly fits inside the TV overscan area you specified with "Blocks TV-overscan" - that means, if you specify 2 blocks of TV overscan borders then FitCD takes the movie and will resize the whole motion area (specified by "Film pixel:") to a width of 448 when your target is SVCD.
This means, if a movie has very small original black borders on the left and right that the black borders on the top and bottom will get slightly bigger then because they have to - just to maintain the aspect ratio. I never liked that behaviour and so always preferred my way - just stupidly blank the TV overscan area and resize the whole movie maintaining the correct aspect ratio to the target size.
With FitCD you'll see what's usually hidden inside the TV overscan area and you cannot see when playing the original DVD on your standalone - but I never wanted it that way. See the difference by watching a DVD on your PC with a software player and watch for details on the left and right edges and then watch this DVD on your standalone - you will see a difference there's some little things missing now on the left and right - but again this is with all DVDs you watch on your standalone and TV combo.
And the "Max Width" and "Max height" option in FitCD only have influence on the "Crop" command in FitCD not on the whole movie or to be exact the motion area. Just play around with FitCD - if you want to test the output of my script you have to pretend the width of the motion area "672" when using 2 blocks overscan and your target is SVCD - the height of the motion area can be entered as detected.
Hope it is clearer now,
Gerti
r6d2
27th June 2003, 18:36
Originally posted by gerti67
you will see a difference there's some little things missing now on the left and right - but again this is with all DVDs you watch on your standalone and TV combo.
OK, I get it now. Seeing "the same" as the standalone sounds great. Makes a lot of sense to me and I also would prefer it that way.
Just play around with FitCD - if you want to test the output of my script you have to pretend the width of the motion area "672" when using 2 blocks overscan and your target is SVCD - the height of the motion area can be entered as detected.
Playing with FitCD if I put 672 as the width and the detected 364 height, no cropping, FitCD says there is an aspect ratio error of 5.49%. It is an Anamorphic movie, according to FitCD (loading the AVS with the Source button).
It FitCD advising wrong? Or am I doing something wrong?
Another thing... I found something that may be a bug (or a badly documented "feature" :)) in your script. When you use Debug, you have to turn it off before encoding! (I learned it the hard way).
gerti67
27th June 2003, 21:30
Originally posted by r6d2
...
Playing with FitCD if I put 672 as the width and the detected 364 height, no cropping, FitCD says there is an aspect ratio error of 5.49%. It is an Anamorphic movie, according to FitCD (loading the AVS with the Source button).
It FitCD advising wrong? Or am I doing something wrong?No, not at all. It is one of FitCDs sometimes strange behaviours if you don't allow letting it crop. It does not switch to the best resize values then. Just click on the arrows on the right of the resize box until the aspect error is almost 0% - then you will see that the script is calculating correctly.
Originally posted by r6d2
...
Another thing... I found something that may be a bug (or a badly documented "feature" :)) in your script. When you use Debug, you have to turn it off before encoding! (I learned it the hard way). Ups, I thought that was clear and the word "Attention!" was a clear warning. Will make this more clear in the next readme. ;) If time allows I want to implement interlaced aware resizing and something like an "upscale" option to make a 2.35:1 movie look like a 1:85:1 movie or a 1.85:1 movie like a 4:3 movie - I think this can be done easily.
Cheers,
Gerti
r6d2
27th June 2003, 21:57
Originally posted by gerti67
No, not at all. It is one of FitCDs sometimes strange behaviours if you don't allow letting it crop. It does not switch to the best resize values then. Just click on the arrows on the right of the resize box until the aspect error is almost 0% - then you will see that the script is calculating correctly.
OK, done already. This is what FitCD says:
BicubicResize(368,224,0,0.6,24,56,672,364)
AddBorders(56,128,56,128)
And this is what your script says:
DetectedTop=56 DetectedHeight=364
BlocksToCropHorizontal=2 BlocksToCropVertical=2 BlockOptimization=16
ResizeMethod=2 Bicubic_b_Value=0.0 Bicubic_c_Value=0.6
GammaCorrection=1.0 Hue=0 Saturation=1.0 Brightness=0 Contrast=1.0
DebugMode=0
DestinationWidth=480
DestinationHeight=360
LoadPlugin("C:\Archivos de programa\DVD2SVCD\Avisynth2.5 Plugins\SimpleResize\SimpleResize.dll")
Import("C:\Archivos de programa\DVD2SVCD\Avisynth2.5 Plugins\AutoCrop\SemiAutoCropAndResize.avs")
Will these produce the same output?
gerti67
27th June 2003, 22:28
Originally posted by r6d2
...
Will these produce the same output? No, the settings you made in FitCD are wrong!
You have to make sure that the aspect value beneath the aspect error is also nearly the same as the real aspect value!
So in your case FitCD should give you something like this:
BicubicResize(448,274,0,0.6,24,58,672,364)
AddBorders(16,96,16,110)
if you've set the slider to "macroblock aligned" for the borders too
And my script will give you this:
BicubicResize(448,272,0,0.6,24,58,672,364)
AddBorders(16,112,16,96)
You see it's pretty equal - only difference is, my sript likes to round down as "273" would be the exact height to resize to (with aspect error 0%) and FitCD likes to round up so you get "274" with FitCD and "272" with my script because in YUV12 colorspace you have to resize vertically to even numbers so "273" is not allowed.
In this case my script is slightly better because the top and the bottom borders are both macroblock aligned and in the script FitCD gives is you only the top border is macroblock aligned. But you can achieve this with FitCd too if you set the rounding to "16" for the resize box. Then FitCD will give you the exact same values like the script - except for the AddBorders - My script shifted the picture slightly downwards and FitCD slightly upwards to align it to macroblock boundaries - just a matter of taste.
So watch closely what you're doing with FitCD - it is a powerful tool but if you don't know what you're doing you can terribly mess things up. That's why I don't use FitCD - its "inner life" is not to my taste it is sometimes not acting predictable to me and that's why I always calculated the values myself or now with my script as I got tired of using my calculator for this - hey, what else are computers good for? ;)
Greetz,
Gerti
r6d2
28th June 2003, 04:19
@gerti67,
Thanks a lot for your advices and willingfulness to share your knowledge.
Originally posted by gerti67
You have to make sure that the aspect value beneath the aspect error is also nearly the same as the real aspect value!
So in your case FitCD should give you something like this:
BicubicResize(448,274,0,0.6,24,58,672,364)
AddBorders(16,96,16,110)
Now I got it. It gave me:
BicubicResize(448,272,0,0.6,24,56,672,364)
AddBorders(16,96,16,112)
The only difference with your script is:
BicubicResize(448,272,0,0.6,24,58,672,364)
AddBorders(16,112,16,96)
Just like you said.
My script shifted the picture slightly downwards and FitCD slightly upwards to align it to macroblock boundaries - just a matter of taste.
Would you parametrize this? Shifting upwards will give you more room for subtitles, so they do not interfere with the movie...
Also, both you and FitCD recommend to align to macroblocks instead of plain centering. The FitCD readme suggests some benefits, like "enhance encoding efficiency". Would you please lecture me a little on this? The encode will be faster? Will it have better quality? Will it play smoother? All of the above?
Regards,
gerti67
1st July 2003, 16:51
Originally posted by r6d2
... Would you parametrize this? Shifting upwards will give you more room for subtitles, so they do not interfere with the movie ...Yepp, good idea. Will do that - I never thought about it as I usually don't need subs.
Originally posted by r6d2
... Also, both you and FitCD recommend to align to macroblocks instead of plain centering. The FitCD readme suggests some benefits, like "enhance encoding efficiency". Would you please lecture me a little on this? The encode will be faster? Will it have better quality? Will it play smoother? All of the above? ...You know in MPEG encoding it's all about macroblocks - roughly spoken. A macroblock is 16x16 pixel and the encoder always uses complete macroblocks for all the encoding steps - motion estimation, DCT, quantization and such.
Only if a macroblock is completely identical compared to a previous or following macroblock in a previous or following frame then the encoder will really save some bitrate as it only has to encode something like a flag called "skip (this) macroblock". This needs very little bitrate and is very efficient. So if you align the motion area to macroblock boundaries for the top border for example you can make sure that the border above is divideable by 16 without a rest and so only consist of completely solid black macroblocks.
If for example the last row of macroblocks above the motion area contain only one line of the motion area the encoder cannot use this bitrate saving trick and he has to encode this complete row of macroblocks as the information in the 16th line of the macroblock is always changing from frame to frame. Only th 15 lines above of this macroblock are always solid black. But due to the specs and the design of MPEG encoding technology the encoder has to use a 16x16 macroblock.
Regarding the picture quality - hmm - you know that depends on the bitrate you use for the encode. The more bitrate you give the encoder to play with the less you can see a difference in picture quality - this will only be visible if you use low bitrates like in SVCD encoding or DVD encoding with low bitrates of around 3500 kbit/s I would say.
Hope it is clear now,
Gerti
Originally posted by gerti67
You know in MPEG encoding it's all about macroblocks ...
Much clearer now, thank you very much. I have just one more question. My TV does not show neither the top 29 lines nor the botton 29 lines (I think most TVs do this).
When encoding 4:3 movies, it would be possible to crop top and botton 24 lines instead of just 16, but the result would not be macroblock aligned. In exchange for that, half of those macroblocks would contain pure black.
Which one of both methods should compress better and hence give better results, in theory?
"Encode what we cannot see" or "messing around with the macroblock optimization"?
Regards,
gerti67
10th July 2003, 13:41
@r6d2:
If a total half of the macroblock is pure black this sure will help compression because the DCT will produce coefficients with more zeros that will compress better afterwards. So no problem with them being not aligned to macroblock boundaries the encoder just can't skip the macroblocks but it will safe more bitrate as if it had to encode a full macroblock.
HTH,
Gerti
r6d2
10th July 2003, 17:08
And I guess the proper way to do this with your script would be:
BlocksToCropHorizontal=2 BlocksToCropVertical=3 BlockOptimization=8
I don't know how sucessful your script has been in terms of users, but I find it pretty confortable, straightforward, and giving almost 1:1 copies.
Thank you very much.
Holomatrix
16th July 2003, 02:08
When adding filters, I would select "Edit before encoding" and put my filters at the end of the script, right? just wondering because with the FitCD script I put them between Resize and Add borders but your script does not have Add borders. Or can I put them somewhere else so I don't need to "Edit before encode"?
Thanks
r6d2
16th July 2003, 03:22
Originally posted by Holomatrix
your script does not have Add borders. Or can I put them somewhere else so I don't need to "Edit before encode"?
Thanks
Hi @Holomatrix (Excuse my intromission, Gerti67 :)),
I did the following, which may be of use to you. I inserted lines 8 and 10 into the DVD2SVCD.ini file:
8=Import("C:\AviSynth 2.5\plugins\pre.avs")
9=Import(!SemiAutoCropAndResize.avs)
10=Import("C:\AviSynth 2.5\plugins\post.avs")
In the pre(resize) and post(resize) scripts I add the filters I need.
Gerti's script does the AddBorders, but internally. If you really need to insert a script before there, I guess you might edit the script file directly, but IMHO you don't need to.
I think filters should go before resize anyway, in order to have more "pure" data to do a good job.
I find the post script useful with filters like avsmonitor.
Hope this helps.
Holomatrix
17th July 2003, 02:05
Ok, thanks I'll give it a try. The reason I put my filters after resize (Undot & Deen) is because I encode from DVD, which for me, so far have been clean source, so since downsizing and low bitrate encoding creates it's own 'Noise', mosquito and other artifacts, that needs to be filtered out at the end.
r6d2
17th July 2003, 03:11
Originally posted by Holomatrix
Ok, thanks I'll give it a try. The reason I put my filters after resize (Undot & Deen) is because I encode from DVD, which for me, so far have been clean source, so since downsizing and low bitrate encoding creates it's own 'Noise', mosquito and other artifacts, that needs to be filtered out at the end.
You are right in a way, but remember that the mosquito noise is probably not added by the resize, but by the encode. You would need to apply a filter after CCE, which is, AFAIK, not possible (unless you use CCE's filters, which to me at least are black magic).
I also mostly encode from DVD, which are in general very clean and require, strictly speaking, no filtering at all. But I filter for increased compressability, and that helps more, IMO, before the resize.
Also, since using gerti67's script I only go for Bilinear, since the resize is only one-dimesional, and it is 20% or so faster.
Regards,
Holomatrix
17th July 2003, 13:50
True, filters before resize help compressability. I use lanczos resize because I find it gives me the sharpness I need from the encode more so than needing the smoothing that Bilinear does. I find that Bilinear smoothes (blur) the whole encode to much but Lanczos + Deen will leave me a more crisp edge enhancement + smooth (blur) where I need it to. i.e. the blocks and low bitrate (HighBitrate wanabi) action areas.
r6d2
17th July 2003, 15:24
Originally posted by Holomatrix I find that Bilinear smoothes (blur) the whole encode to much but Lanczos + Deen will leave me a more crisp edge enhancement + smooth (blur) where I need it to. i.e. the blocks and low bitrate (HighBitrate wanabi) action areas. [/B]
I had not thought of that, since I'm looking for compressability it made little sense to sharp (to me), but if it is good for you, I'll give it a try.
(We are very off-topic now on this, we may get our butts kicked :))
Holomatrix
18th July 2003, 19:43
True :) enough said :)
davidh44
19th July 2003, 22:15
gerti67,
Nice script! Very easy to use. I just used it on an NTSC source, and it worked great.
Besides blanking the TV overscan area, the macroblock optimization and motion area detection seem to provide additional benefits over DVD2SVCD's internal routines when encoding from widescreen/anamorphic -> 4:3. Is this correct?
Holomatrix
10th August 2003, 22:49
Not sure what has happened but when I select my BlocksToCropHorizontal=2 BlocksToCropVertical=1 options then check in DVD2SVCD preview they are opposite. So when I select BTCH=2 it shows blocks taken of the left and right sides. I didn't modify any scripts, what could be going on?
Thanks
Edit: also I should change block align to 8 if doing 4:3 with VCD and SVCD, right? not only VCD because the preview in DVD2SVCD with 4:3 SVCD was also mounted at the bottom of the window.
Holomatrix
21st August 2003, 20:19
Anyone else having the same problem as above?
r6d2
21st August 2003, 20:41
Originally posted by Holomatrix
Anyone else having the same problem as above?
Hi @Holomatrix,
I've experienced similar problems when restarting an encode and changing the output resolution or changing from AutoFitCD to SemiAuto. On the contrary, when changing resolutions and keeping SemiAuto, all works well.
I think the preview gets confused when changing basic stuff after a reload. I guess you have to do it from scratch.
Holomatrix
21st August 2003, 21:31
Even from scratch it is the same for me. I just did a different 4:3 movie last night (SVCD). Have to set BTCH = 2, to remove two blocks from the Left and Right, set BTCV = 1 to remove 1 block from the top and bottom and set BlockOptimization = 8 so it doesn't mount the video to the bottom. Weird. No big deal, I just have to remember when setting up my encodes. Just thought I could change somthing in the SemiAuto AVS to set things right. Oh, well.
r6d2
21st August 2003, 22:37
Originally posted by Holomatrix
Just thought I could change somthing in the SemiAuto AVS to set things right. Oh, well.
I use BO=8, Top/Bottom=3, Left/right=2 for 4:3 movies. fits perfectly in my TV screen without encoding what cannot be seen.
DDogg
21st August 2003, 22:47
For clarity's sake, what do you use for 16:9? Gert's defaults?
r6d2
21st August 2003, 23:47
Originally posted by DDogg
For clarity's sake, what do you use for 16:9? Gert's defaults?
Yep.
Holomatrix
22nd August 2003, 11:48
BTCH=2 (left/right), BTCV=0 (top/bottom), BO=16
DDogg
27th August 2003, 15:12
The Avisynth 2.5x build of Aug 20 and any after will break this script as the method of evaluating multiplication and division had a bug in Pre Aug20 builds and that bug has now been fixed. See these threads for details: http://forum.doom9.org/showthread.php?s=&threadid=59918 and http://forum.doom9.org/showthread.php?s=&threadid=59361
The quick fix (thanks to Sh0dan) is to open SemiAutoCropAndResize.avs and change the line in bold under the heading:
#### Calculate some important base parameters
DestinationSystemHeight = (DestinationHeight % 5 > 0) ? 576 : 480
DestinationSubSystemHeight = (DestinationHeight / 360. < 1) ? DestinationSystemHeight / 2 : DestinationSystemHeight
HorizontalFactor = (DestinationWidth < 480) ? 0.5 : DestinationWidth / 720.
VerticalFactor = DestinationHeight / DestinationSystemHeight * 1.
Correct704Factor = (DestinationWidth == 352) ? 0.977777 : 1.
Change it to this:
VerticalFactor = float(DestinationHeight) / float(DestinationSystemHeight)
Holomatrix
27th August 2003, 16:10
Thanks, I'll check it out.
EDIT: ok, that seemed to fix the breaking but I still need to set blocks to crop opposite to the norm. (BlocksToCropHorizontal=2 takes two off the left and right sides) Oh well, no big deal.
Tyler
2nd September 2003, 11:37
cannot get the script to work. use the latest dvd2svcd version with avisynth 2.5. I unpacked the archives to the folders, added the info to dvd2svcd.ini but after starting the program I can't find the autodetect border script in the frameserver tab
any hints?
tylo
2nd September 2003, 11:58
The new version of DVD2SVCD 1.2.1 build 1, has a new file AVISYNTH.INI in the program directory. You must put the AVISYNTH block there, instead of the dvd2svcd.ini file, I think..
Tyler
2nd September 2003, 12:04
that's the fix - thanks a lot :)
r6d2
8th September 2003, 15:24
Hi there,
On Gerti's absence, and after unsuccessfully trying to contact him, I did some improvements on his excellent script.
Download from http://www.angelfire.com/droid/r6d2
Excerpt from the Readme:
New Features in 1.06.2:
i. Overscan based cropping.
You specify the vertical and horizontal overscan as a percentage. The script then determines the number of blocks to crop in both dimensions. This results in automatic cropping for any resolution you choose.
If you don't know the overscan of your TV, an SVCD image file is available at http://www.angelfire.com/droid/r6d2 which has a scale and you can measure the overscan for the 7 typical resolutions. This way you may also find out which resolutions your player supports. Anyway, the default values are safe for a typical 4:3 TV.
OverscanV: Vertical overscan. Default 0.04 (4%). This specifies left & right cropping.
OverscanH: Horizontal overscan. Default 0.04 (4%). This specifies top & bottom cropping.
ii. Supports any of the 7 popular output resolutions (as in FitCD).
ResizeTo: Specifies the output resolution.
0 = Let DVD2SVCD handle output resolution
1 = 528x480 - 3/4 DVD Small
2 = 544x480 - 3/4 DVD Full
3 = 704x480 - XVCD
iii. Additional filtering
You may use the preresize.avs and postresize.avs scripts to insert any filters you like. The defaults include the KISS recipe, a simple and powerful compression enhancer, and a CCE encoding visualizer.
iv. BlockOptimization auto mode
If you set BlockOptimization to 0, a default of 8 is applied to VCD and 16 to all other resolutions.
Edit: Added 0.2 version and fixed links.
r6d2
8th September 2003, 17:30
Originally posted by Holomatrix
EDIT: ok, that seemed to fix the breaking but I still need to set blocks to crop opposite to the norm. (BlocksToCropHorizontal=2 takes two off the left and right sides) Oh well, no big deal.
@Holo, you were right. In the documentation the meanings were reversed. I fixed it on 1.06.2.
lordkinbote
8th September 2003, 17:35
Sounds excellent! I'll give it a try and let you know how it works for me.
Holomatrix
8th September 2003, 17:42
Is your site down? I can't seem to get there from here :)
EDIT: never mind, you must have been modifying it.
Thanks, I'll check this version out :)
DDogg
9th September 2003, 03:49
r6d2, this is a fine addition to SemiAuto and very fine work on your part. I wondered why you had been so quite lately :)
r6d2
9th September 2003, 03:56
Originally posted by DDogg
r6d2, this is a fine addition to SemiAuto and very fine work on your part. I wondered why you had been so quite lately :)
Well, I've been trying to lower my posts per day count so they are below Pi. I have just accomplished that today. :)
Thanks, DDogg.
BTW, after Tylo's last surprise feature and this modification, the name of this script no longer fits the product! Now it should be called FullyAutomatedCropAndResize, or FACAR, for short ;)
Maybe we'll soon see a thread from Gerti with a poll about "Should I change the program name"? :D
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.