View Full Version : AutoResize v.1.7 (ideal for use with ffdshow) [Last Updated: 2/4/2011]
dansrfe
12th November 2010, 03:56
This function will resize to any aspect ratio (AR), and add black borders, if needed, to reach any destination resolution, primarily for full-screening video to maximum screen resolution. This function was initially designed to make possible high-quality subtitle rendering at maximum possible resolution with optimal placement area, to be used with ffdshow video decoder. AutoResize can be used with any renderer to deliver automated high-quality spline36 resizing on-the-fly.
Features:
- Compatible with any version of AviSynth 2.5.8+
- Borders appended in a mod2 fashion with right-hand justification for boxed clips (+ 1 pixel) and top justification for letterbox clips with (+ 1 pixel).
- High quality Spline36Resize function used for any resizing
- If necessary, colorimetery conversions are taken care of automatically when changing from SD -> HD or any other upscale/downscale situation.
- OSD displays Resolution changes, Borders information, AR changes, and FPS information in upper left corner.
Prerequisites:
AviSynth 2.5.8+ (Preferably MT version) http://www.mediafire.com/file/kjdzqyz4dyj/AviSynthMT_258.exe
ColorMatrix (For SD->HD conversions) http://avisynth.org/warpenterprises/files/colormatrix_20070828.zip
Syntax:
AutoResize(clip, bool "Info", bool "Borders", float "AR", string "DAR", int "SW", int "SH")
Info: Enables/disables OSD. (default: "false")
Borders: Allows you to resize with or without borders. (default: "true")
AR: Changes AR with respect to "screen" variable values. (default: input AR)
DAR: Sets display aspect ratio of input. Options: PAL/NTSC DVD Only: ["letterbox" for 16/9 (1.777) ,"box" for 4/3 (1.333)]. (default: null)
SW: Screen width in pixels. (default: 1920)
SH: Screen height in pixels. (default: 1080)
Some Important Notes:
AutoResize is meant to be run at all times. It is designed to use it's logic in every possible resizing situation for the best output. AutoResize will not resize unless it is absolutely needed; the same goes for appending black borders. If you pass a video through AutoResize that matches the sw and sh variables or default conditions then it will pass the video through untouched and simply be equivalent to "last" in AviSynth notation. Resizing takes place if needed (see below) then black borders are appended if needed (see below). AR changes are shown in the OSD denoted by "Input AR -> Output AR".
How to know if resizing is taking place:
In order to absolutely know that the input is or is not being passed through the resizer you should check the OSD. If you see "Resolution: Input x Resolution -> Output x Resolution" the input is being passed to the resizer. If you just see "Resolution: "Input x Resolution" then the input is not being passed through a resizer whatsoever.
How to know if borders are being added:
In order to absolutely know that black borders are or are not being appended is by checking the OSD. If you see "Borders: off" then there are no black borders being appended to the output. If you just see "Borders: on, (x,x,x,x)" then black borders are being appended to the output.
Here are some examples:
SW = 1920, SH = 1080; Input = 1280 x 720 [OSD: Resolution: 1280 x 720 -> 1920 x 1080 ; Borders: off]
SW = 1280, SH = 720; Input = 1280 x 720 [OSD: Resolution: 1280 x 720 ; Borders: off]
What works best for me performance wise in using this function and other functions in AviSynth on-the-fly:
This is my script that I have in ffdshow (hats off to Didée for finding the magic performance juice ;)):
setmtmode(5)
ffdshow_source()
changefps(last,last,true)
setmtmode(2)
[...other functions if needed...]
AutoResize()
I have 3:2 Pulldown set to "Apply Pulldown" and have unchecked the "Buffer back/ahead:" along with "Add ffdshow video source". The changefps does nothing but cache a few frames but it has a drastic performance boost in the overall script.
Download: AutoResize v1.7.avsi (http://www.mediafire.com/?50xpcpv78te0je7)
Changelog:
2/4/11 - Major code rewrites. PAR changed to DAR (only "letterbox" and "box" modes exist now). Added "Borders" variable. OSD massively improved and cleaned up. Variable names shortened to abbreviations. Housekeeping and labeling of different parts of code.
1/2/11 - Added new PAR parameters and error message on invalid par parameter input or when par is fed a non-square pixel NTSC or PAL source.
12/21/10 - Fixed some bugs. Could result in faster speeds for some.
11/25/10 - Removed ThreadRequest.
11/16/10 - Removed mode setting & changed function name to "AutoResize".
11/16/10 - Major changes. Added input PAR setting for flagged content. Optimized code.
11/15/10 - Minor bugfixes, one variable input changed and added documentation in script.
11/12/10 - Code updated from creaothceann's adjustments. Thanks!
creaothceann
12th November 2010, 08:55
DVDs can also have a width of 704.
function Resize(clip c, int "Mode", bool "Info", float "AR", int "ScreenWidth", int "ScreenHeight") {
Info = Default(Info , False)
Mode = Default(Mode , 0)
ScreenWidth = Default(ScreenWidth , 1920)
ScreenHeight = Default(ScreenHeight, 1080)
SetMTMode(2)
last = c
AR_Screen = Float (ScreenWidth) / ScreenHeight
AR_norm = Float ( Width) / Height
AR = Default(AR, AR_norm)
Resize_BoxWidth = Round(Float(ScreenHeight) * AR)
Resize_LetterboxHeight = Round(Float(ScreenWidth ) / AR)
Mod2Box = Resize_BoxWidth + (Resize_BoxWidth % 2)
Mod2Letterbox = Resize_LetterboxHeight - (Resize_LetterboxHeight % 2)
Border_Letterbox = (ScreenHeight - Mod2Letterbox) / 2
Border_Box = (ScreenWidth - Mod2Box ) / 2
Resize_Letter = Spline64Resize(ScreenWidth, Mod2Letterbox).ThreadRequest
Resize_Box = Spline64Resize(Mod2Box , ScreenHeight ).ThreadRequest
Upscale_Letterbox = (Border_Letterbox == 0) ? Resize_Letter.ThreadRequest : Resize_Letter.ThreadRequest.AddBorders( 0, Border_Letterbox, 0, Border_Letterbox).ThreadRequest
Upscale_Box = (Border_Box == 0) ? Resize_Box : Resize_Box .ThreadRequest.AddBorders(Border_Box, 0, Border_Box, 0).ThreadRequest
Letterbox_or_Box = (AR >= AR_Screen) ? Upscale_Letterbox : Upscale_Box
DVD_or_SD = ((Width == 720 || Width == 704) && (Height == 480 || Height == 576)) ? Spline64Resize(1920, 1080).ThreadRequest : (Width > 1280) ? Letterbox_or_Box : Letterbox_or_Box.ColorMatrix("Rec.601->Rec.709").ThreadRequest
HD_BorderWidth = (ScreenWidth - Width ) / 2
HD_BorderHeight = (ScreenHeight - Height) / 2
ResizeHeight = (Height == ScreenHeight) && (AR_norm == AR) ? AddBorders(0, HD_BorderWidth , 0, HD_BorderWidth ).ThreadRequest : DVD_or_SD
ResizeWidth = (Width == ScreenWidth ) && (AR_norm == AR) ? AddBorders(0, HD_BorderHeight, 0, HD_BorderHeight).ThreadRequest : ResizeHeight
HD = ((Width == ScreenWidth) && (Height == ScreenHeight)) && (AR_norm == AR) ? last : ResizeWidth
SelectRes = (AR >= AR_Screen) ? Resize_Letter : ((Width == 720 && (Height == 480 || Height == 576)) ? Spline64Resize(1920, 1080) : Resize_Box)
ChangeAR = (AR_norm == AR) ? String(AR_norm) : (String(AR_norm) + " -> " + String(AR))
ChangeRes = (SelectRes.Width != Width) || (SelectRes.Height != Height) ? String(Width) + " x " + String(Height) + " -> " + String(SelectRes.Width) + " x " + String(SelectRes.Height) : String(Width) + " x " + String(Height)
SourceInfo = HD.Subtitle("Source res: " , x= 19, y=25, Size=22, Font="Arial", Text_Color=$DC143C)
\. Subtitle(String(ChangeRes) , x=140, y=25, Size=22, Font="Arial" )
\. Subtitle("A/R: " , x= 92, y=49, Size=22, Font="Arial", Text_Color=$DC143C)
\. Subtitle(String(ChangeAR) , x=141, y=49, Size=22, Font="Arial" )
\. Subtitle("FPS: " , x= 88, y=72, Size=22, Font="Arial", Text_Color=$DC143C)
\. Subtitle(String(framerate(c)), x=141, y=72, Size=22, Font="Arial" )
(Mode == 1) ? (Info ? SourceInfo.ThreadRequest : HD) : last
}
PS: You shouldn't assign anything to "last", it's a predefined variable that contains the result of the last operation that wasn't assigned to another variable:
AVISource(...)
AudioDub(last, WAVSource(...))
tmp = AddBorders(1, 0, 1, 0, $123456)
StackHorizontal(last, tmp)
Gavino
12th November 2010, 10:50
PS: You shouldn't assign anything to "last", it's a predefined variable that contains the result of the last operation that wasn't assigned to another variable
Agreed that you shouldn't use a variable called 'last' for some unrelated purpose, but I don't see anything wrong with writing
last = c
where the purpose is to set the 'real' last, needed in the later use of 'width' (ie last.width()) and 'height'.
You could just write
c
on its own to get the same result, but that looks a bit odd.
creaothceann
12th November 2010, 12:34
You could just write
c
on its own to get the same result
Yeah, I do that in my functions.
Gavino
12th November 2010, 13:05
It's debatable which is 'better', 'c' on its own or 'last=c' - I do it either way, more or less at random.
Another possibility is
/* last = */ c
which shows the intent without explicitly assigning to 'last'.
It's really a matter of taste, and I wouldn't lose sleep over the issue. :)
noee
12th November 2010, 13:50
What benefit to pic quality does madVR bring to the table in this case (besides 3DLut)? Why not use EVR or EVR-CP as the renderer and output RGB from ffdShow (and use it's HQRGB and dithering)?
dansrfe
12th November 2010, 14:56
madVR is basically the smoothest renderer for me and *does* actually look better in terms of gradient reproduction and minimal banding. But you can do that with gradfun in ffdshow as well. It boils down to personal preference I guess if you don't use the 3DLUT.
Also, any other changes I could make to it? I wish there was some way I could combine some if statements to get it to run a bit faster and just want to point out that this script will not work with AviSynth unless the AddBordersMod function is applied to is from the Development section. I don't use 2.6 at this time therefore I didn't use AddBodersMod.
henryho_hk
14th November 2010, 17:03
I have written a similar function and it accepts both source and destination pixel aspect ratio:
function parresize(clip c, int dst_w, int dst_h, string "dst_par", string "src_par", bool "ss")
{
unit_w = c.isRGB() ? 1 : 2
unit_h = c.isRGB() || c.isYUY2() ? 1 : 2
assert(dst_w % unit_w == 0, "Destination width must be divisible by " + string(unit_w))
assert(dst_h % unit_h == 0, "Destination height must be divisible by " + string(unit_h))
ss = default(ss, false)
src_par = default(src_par, "vga11")
dst_par = default(dst_par, "vga11")
cvt_par = \
( \
dst_par == "pal43" ? 12.0/11.0 : \
dst_par == "ntsc43" ? 10.0/11.0 : \
dst_par == "pal169" ? 16.0/11.0 : \
dst_par == "ntsc169" ? 40.0/33.0 : \
1.0 \
) / \
( \
src_par == "pal43" ? 12.0/11.0 : \
src_par == "ntsc43" ? 10.0/11.0 : \
src_par == "pal169" ? 16.0/11.0 : \
src_par == "ntsc169" ? 40.0/33.0 : \
1.0 \
)
src_dar = float(c.width) / cvt_par / c.height
dst_dar = float(dst_w) / dst_h
temp_w = floor((src_dar >= dst_dar ? dst_w : round(1.0 * dst_h * src_dar))/unit_w)*unit_w
temp_h = floor((src_dar >= dst_dar ? round(1.0 * dst_w / src_dar) : dst_h)/unit_h)*unit_h
r_factor = ss ? int(pow(2,ceil(log(max(float(temp_w)/c.width,float(temp_h)/c.height))/log(2.0)))) : 1
s1 = r_factor == 1 \
? c.blackmanresize(temp_w,temp_h) \
: c.nnedi3_rpow2(rfactor=r_factor,cshift="spline64resize",fwidth=temp_w,fheight=temp_h)
pad_l = floor(0.5*(dst_w-temp_w)/unit_w)*unit_w
pad_r = dst_w - pad_l - temp_w
pad_t = floor(0.5*(dst_h-temp_h)/unit_h)*unit_h
pad_b = dst_h - pad_t - temp_h
return s1.addborders(pad_l, pad_t, pad_r, pad_b)
}
Thanks Gavino for the suggestion.
Gavino
14th November 2010, 17:39
assert(dst_w == floor(dst_w/unit_w)*unit_w, ...)
assert(dst_h == floor(dst_h/unit_h)*unit_h, ...)
'floor' is redundant here - since dst_w and unit_w are both integers, so is dst_w/unit_w.
So you could simplify it to
assert(dst_w == (dst_w/unit_w)*unit_w, ...)
or even more simply
assert(dst_w % unit_w == 0, ...)
BatKnight
25th November 2010, 00:24
Can you explain me how to use this script in ffdshow? Because I've loaded the script to ffdshow, in the Avisynth window, enabled it, but it' doesn't resize the video.
Bat
dansrfe
25th November 2010, 08:46
load the script in ffdshow, write "AutoResize()" without quotes and you're good to go. if you are trying to play a 16:9 dvd then just enter par="wide" or if you're trying to view a 4:3 dvd then add par="[any string]" where basically you can add any string to signal 4:3 flagged content. If par is left blank then it won't override the AR setting. Also read the what the parameters mean inside of the script.
Note: If you're resolution is NOT 1920 x 1080 then you will need to specify the ScreenWidth & ScreenHeight parameters.
dansrfe
26th November 2010, 04:32
If someone could download and optimize the script via changing calling methods or whatever you feel will have it running as fast as possible then please do so. Unfortunately, I'm inexperienced in the optimization area and still learning different techniques.
gnol009
26th November 2010, 09:17
This is my scrip error. how can i fix it?
http://image.hdvnbits.org/graphic/images/2010/November/26/5EB1_4CEF6BD2.jpg
dansrfe
26th November 2010, 18:26
^ install this: http://www.mediafire.com/file/kjdzqyz4dyj/AviSynthMT_258.exe. You must have an MT version of AviSynth 2.5.8 or higher in order for this to work
Frank K Abbott
6th December 2010, 21:30
This functions works well for me thanks!
Mark Regalo
22nd December 2010, 07:35
THis is a good function. I use with madvr. Will there be any more features coming out??
dansrfe
22nd December 2010, 19:09
For right now I'm fairly sure I have perfected the functions that currently exist. As for more functions, I'll add them if it is something that would help others as well. Suggestions are welcome. Please test it and see if it works for you.
PS: All colorimetery conversions etc. are ALL taken care of internally in the script. You will always get the right output from madVR with respect to what is coming out of the function.
Usedocne
22nd December 2010, 22:11
Nice function dansrfe, thanks for sharing it.
Sharc
31st December 2010, 11:32
Nice function, dansfre. Thanks for sharing it.
I assume the script does not automatically de-interlace interlaced video before resizing. Means interlaced video should be de-interlaced before applying this script, correct?
THX-UltraII
31st December 2010, 12:37
I think I m missing (because my English is not good) but what is the exact pupose of this tool? Why would someone want to change the aspect ration of a movie if you get a incorrect result ('long heads') of the picture?
dansrfe
1st January 2011, 06:51
Nice function, dansfre. Thanks for sharing it.
I assume the script does not automatically de-interlace interlaced video before resizing. Means interlaced video should be de-interlaced before applying this script, correct?
Yes, you are correct. I want to keep this as an exclusive resizing script for the sake of simplicity.
I think I m missing (because my English is not good) but what is the exact pupose of this tool? Why would someone want to change the aspect ration of a movie if you get a incorrect result ('long heads') of the picture?
The aspect ratio of the original source file may be incorrect or the user wants to change the aspect ratio for whatever reason. As for the purpose, please refer to the original post for more information.
Sharc
1st January 2011, 10:23
One application would be to resize a square pixel (PAR=1:1) input to DVD anamorphic output with PAR either "Generic", "ITU", or "MPEG4".
Screen size would be 720x576 or 704x576 for PAL, and 720x480 or 704x480 for NTSC.
At present PAR supports "wide" or "4:3" only. Perhaps something to consider for a future release?
dansrfe
1st January 2011, 21:05
One application would be to resize a square pixel (PAR=1:1) input to DVD anamorphic output with PAR either "Generic", "ITU", or "MPEG4".
Screen size would be 720x576 or 704x576 for PAL, and 720x480 or 704x480 for NTSC.
At present PAR supports "wide" or "4:3" only. Perhaps something to consider for a future release?
I'm currently only aware of 16/9 and 4/3 anamorphic scaling. Could you please list the corresponding "Generic", "ITU", and"MPEG4" destination aspect ratios?
Sharc
2nd January 2011, 13:22
I'm currently only aware of 16/9 and 4/3 anamorphic scaling. Could you please list the corresponding "Generic", "ITU", and"MPEG4" destination aspect ratios?
Never mind. I found that I will get what I need by setting the AR parameter accordingly, e.g. 1.25 ("Generic") or 1.22222 ("MPEG4") or 1.21875 ("ITU") for PAL anamorphic resizing of sources with square (1:1) pixels :)
dansrfe
2nd January 2011, 18:31
Are the above AR's also valid for NTSC anamorphic sources with square pixels?
dansrfe
2nd January 2011, 19:52
I've added the following parameters "letterbox" for 16/9, "box" for 4/3, "generic" for 1.25, "mpeg4" for 11/9, and "itu" for 1.21875. (Note that the "wide" parameter has been changed to "letterbox" and 4/3 has been given the "box" string). An error statement has also been added if something other than these strings or a null string is passed onto PAR. If all these destination resolutions are the same for PAL and NTSC sources then I will release v1.6.
Sharc
2nd January 2011, 21:14
Are the above AR's also valid for NTSC anamorphic sources with square pixels?
I would say for resizing to anamorphic NTSC DVDs the AR values in your script would be:
"Generic": AR=1.5
"MPEG4": AR=1.46667
"ITU": AR=1.4625
dansrfe
2nd January 2011, 22:40
AutoResize v1.6 released!
* New PAR modes:
"letterbox" = 16/9
"box" = 4/3
"generic" = 1.25 (PAL)
"mpeg4" = 11/9 (PAL)
"itu" = 1.21875 (PAL)
NTSC has a multiplication factor of 1.2 for all of the above modes excluding "letterbox" and "box". When using the PAR parameter the input must be a square pixel NTSC or PAL source.
Feel free to download the new script, test and post any comments or questions you may have! :)
Sharc
3rd January 2011, 00:33
I think there is a misunderstanding.
The values I gave should be applied to the AR, not to the PAR in your parameter list.
The application is to resize a square-pixel input picture (like from a 1920x1080 blu-ray source) to an anamorphic DVD picture.
2 Examples (for version 1.5):
- resizing of a 1920x1080 square-pixel input to a "Generic"-PAL DVD:
AutoResize(AR=1.25,ScreenWidth=720,ScreenHeight=576)
- resizing of a 1920x1080 square-pixel input to a "MPEG4"-NTSC DVD:
AutoResize(AR=1.46667,ScreenWidth=704,ScreenHeight=480)
dansrfe
3rd January 2011, 03:09
I think there is a misunderstanding.
The values I gave should be applied to the AR, not to the PAR in your parameter list.
The application is to resize a square-pixel input picture (like from a 1920x1080 blu-ray source) to an anamorphic DVD picture.
2 Examples (for version 1.5):
- resizing of a 1920x1080 square-pixel input to a "Generic"-PAL DVD:
AutoResize(AR=1.25,ScreenWidth=720,ScreenHeight=576)
- resizing of a 1920x1080 square-pixel input to a "MPEG4"-NTSC DVD:
AutoResize(AR=1.46667,ScreenWidth=704,ScreenHeight=480)
Ah I see, well the PAR modes basically just change the AR. I can add in the DVD downsize parameter and remove the restriction parameter that allows only NTSC/PAL DVD's to be inputted when using the PAR parameter. I'll post an updated one tomorrow.
Sharc
3rd January 2011, 10:29
In case you are looking for another goodie you could include a 'mod=' parameter and make the resizing mod-compliant, e.g. mod 2,4,8,16. ;)
henryho_hk
3rd January 2011, 13:07
AutoResize v1.6 released!
* New PAR modes:
"letterbox" = 16/9
"box" = 4/3
....
When using the PAR parameter the input must be a square pixel NTSC or PAL source.
PAR usually means "pixel aspect ratio", i.e., the shape of a pixel. And in your script, it appears to be the picture aspect ratio (i.e., the shape of the whole picture) or the display aspect ratio .... DAR. Would you consider renaming the parameter?
dansrfe
4th January 2011, 00:12
Ok so after some thought on all this I've decided to remove all (should be correctly labeled DAR) modes except for letterbox and box. The reason for this is because the point of this function is not to take a source and make it DVD ready which is essentially what "generic", "mpeg4", and "itu" are meant to do as per Sharc. That's going away from the main purpose or related purposes of this script. Furthermore, if I implement mod restricted resizing the ScreenWidth and ScreenHeight parameters will effectively become useless. The point is to resize exactly to the ScreenWidth and ScreenHeight specified to the script with black borders, regardless of whether they are mod2, mod4, mod6, etc. Now I understand that AviSynth 2.6 has some problems with the Addborders function and non-mod2 border additions, that will be fixed in the next update.
Sharc
4th January 2011, 00:48
... The reason for this is because the point of this function is not to take a source and make it DVD ready which is essentially what "generic", "mpeg4", and "itu" are meant to do as per Sharc. That's going away from the main purpose or related purposes of this script.
ok, no problem.
I proposed this because a poster has been asking for practical applications of the script .....
dansrfe
4th January 2011, 02:48
The practical purposes of this script are to take an input source and resize it to any resolution while adhering to the default/specified AR for final resizing to the video renderer. Of course you can always do AutoResize(AR=1.25, ScreenWidth=720, ScreenWidth=576) and make it "dvd spec ready" for input to a dvd encoder, even if it does deviate from the original purpose of the script.
I might release a separate function that is for different resizing applications with specific presets already defined in the future.
henryho_hk
4th January 2011, 06:27
AR: Changes AR with respect to "screen" variable values. - (default: input AR)
Actually, I can't catch the meaning of this parameter.
Does it mean that the input clip will be resized to the specified AR (DAR) while fitting inside the specified "screen" width and height, and then padded to fill that box completely?
If I use my own function to resize and pad a PAL 4:3 DVD for realtime 720p viewing, I use:
clip.parresize(1280, 720, src_par="pal43", dst_par="vga11", ss=false)
How can I do the same in dansrfe's multithreaded function?
dansrfe
4th January 2011, 08:05
Yes, the AR parameter will resize the video to the screenwidth or screenheight depending on the aspect ratio of the screen size and the aspect ratio specified in the function and then it will pad the remaining vertical or horizontal area with black bars. (I should change the original wording of the description for the AR parameter)
In order to achieve what you want in AutoResize v1.6 you can do one of the two:
1) AutoResize(ar=1.3333, screenwidth=1280, screenheight=720)
2) AutoResize(par="box", screenwidth=1280, screenheight=720)
Now as you pointed out earlier the par is supposed to mean picture aspect ratio but it can be easily confused for pixel aspect ratio and therefore the parameter name will be changed in v1.7 in which I'm planning on implementing some other new tweaks as well.
dansrfe
3rd February 2011, 20:20
AutoResize 1.7 has been released with massive improvements and exciting new features. Please check out the original post and post your feedback today! Enjoy! :)
TheElix
4th February 2011, 12:52
I have no clue about avisynth scripting and this topic is so confusing. Would you mind answering a few noob questions?
1) What's the purpose of this script? What are the benefits of using it? To get high resolution subtitles in ffdshow? To get any improvements with picture quality or performance? The player resizes the video for you when you enter fullscreen even without this script, does it not?
2) I installed AviSynthMT_258.exe (even though it wasn't noted in the 1st post that it is necessary) and now my player doesn't crash when I add the script in ffdshow. But it does nothing. I posted the code from AutoResize v1.7.avsi to ffdshow in AviSynth tab (I had to rename it to .avs for ffdshow to be able to see the file; it doesn't see .avsi files) and activated the AviSynth option. Furthermore, as the 1st post suggests to use some sort of optimizing script, I copy-pasted these lines to the end of the AutoResize v1.7.avsi script:
setmtmode(5)
ffdshow_source
changefps(last,last,true)
setmtmode(2)
AutoResize
}
I did it because the first post gave no hints as how to activate this script.
Well, I did that and it produced no effect. Would you mind giving a small tutorial for people like me who doesn't know about avisynth scripting but wants to take advantage of anything to make their video watching experience better?
dansrfe
4th February 2011, 18:08
1.a) What's the purpose of this script? What are the benefits of using it? To get high resolution subtitles in ffdshow? To get any improvements with picture quality or performance?
All of the above is correct.
1.b) The player resizes the video for you when you enter fullscreen even without this script, does it not?
The player resizes the video after the subtitles have already been "imprinted" onto the video. This only happens in video renderers that do not support internal subtitle rendering. So something like ffdshow's subtitle renderer (which uses vsfilter) would take the original resolution video and hard sub the video with whatever attributes you have set (font, font size, text positioning, etc.).
Now suppose you have a 720 x 304 mkv with subtitles, if you are using madVR with ffdshow and want to have subtitles, ffdshow will take the video, hard code (overlay) the subtitles on a 720 x 304 resolution (boxed into a smaller area where the text is). Then that video ships out to the renderer and gets resized to 720p (your max screen resolution in this example, so 1280 x 540) with your subtitles getting massively blurred.
Now this situation is completely removed if you use renderers that support subtitle rendering because it will automatically do what my script does when you fullscreen and automatically go back with you go back to windowed. The only quality difference there is that most other renderers that have internal subtitle rendering use a bilinear or bicubic resizer instead of the high-quality spline resizer that madVR and my script use.
2) Make sure you have unchecked add ffdshow source and add the script to "C:\Program Files (x86)\AviSynth 2.5\plugins" for 64bit or "C:\Program Files\AviSynth 2.5\plugins" for 32bit OS. Then put:
setmtmode(5)
ffdshow_source
changefps(last,last,true)
setmtmode(2)
AutoResize()
Make sure you have checked the "AviSynth" checkbox on the left column in ffdshow and have dragged the "Subtitles" tab/checkbox below the AviSynth tab/checkbox. Also be sure to customize the subtitle rendering the way you want. (font, font size, text position, etc.)
Matching_Mole
4th February 2011, 21:10
Hi,
I had an issue with the version 1.7 of this script.
You declare a bool variable "Borders" and after that you use the variable name "BlackBorders" instead of the declared one. So Avisynth show an error message because it doesn't know what is the variable "BlackBorders".
I changed the declared variable by "BlackBorders" and now all is fine. Please, correct your script for other people.
dansrfe
4th February 2011, 21:46
Hi,
I had an issue with the version 1.7 of this script.
You declare a bool variable "Borders" and after that you use the variable name "BlackBorders" instead of the declared one. So Avisynth show an error message because it doesn't know what is the variable "BlackBorders".
I changed the declared variable by "BlackBorders" and now all is fine. Please, correct your script for other people.
Yes, you are correct. I have updated the script and link. My mistake :o
TheElix
4th February 2011, 22:59
1.a) What's the purpose of this script? What are the benefits of using it? To get high resolution subtitles in ffdshow? To get any improvements with picture quality or performance?
All of the above is correct.
Thank you for your answer. I get the subtitles part, but how does this script possibly affect (read - improve) video quality or performance? Sorry, can't find out this by myself because:
Script error: There is no function named 'Colormatrix' (...line 84)...
fairchild
4th February 2011, 23:25
Thanks for this script. It seems to be working with 720p but, SD and 1080p is spitting out errors. I used the script which you linked for a poster a few posts down:
setmtmode(5)
ffdshow_source
changefps(last,last,true)
setmtmode(2)
AutoResize()
SD files are spitting this error out:
Script error: there is no function named 'colormatrix'(,line 84)(ffdshow_filter_avisynth_script,line5)
and also sometimes
Resize: YV12 width must be multiple of 4.(,line 77)(ffdshow_filter_avisynth_script,line 5)
So the script is resizing videos to 1920x1080 (1080p) to give subtitles more quality when using MadVR so that they don't blur as bad. Is there anything I can do or change with the script to remove the errors?
Oh one last thing, in my ffdshow filter list, should avisynth be last after sharpen or subtitle or before? this is how I currently have it setup:
deband
sharpen
avisynth
subtitles
Thanks
dansrfe
5th February 2011, 00:20
Thank you for your answer. I get the subtitles part, but how does this script possibly affect (read - improve) video quality or performance? Sorry, can't find out this by myself because:
Script error: There is no function named 'Colormatrix' (...line 84)...
You need the ColorMatrix dll. I will have to link that to the op later on. http://avisynth.org/warpenterprises/files/colormatrix_20070828.zip
Thanks for this script. It seems to be working with 720p but, SD and 1080p is spitting out errors. I used the script which you linked for a poster a few posts down:
setmtmode(5)
ffdshow_source
changefps(last,last,true)
setmtmode(2)
AutoResize()
SD files are spitting this error out:
Script error: there is no function named 'colormatrix'(,line 84)(ffdshow_filter_avisynth_script,line5)
and also sometimes
Resize: YV12 width must be multiple of 4.(,line 77)(ffdshow_filter_avisynth_script,line 5)
So the script is resizing videos to 1920x1080 (1080p) to give subtitles more quality when using MadVR so that they don't blur as bad. Is there anything I can do or change with the script to remove the errors?
Oh one last thing, in my ffdshow filter list, should avisynth be last after sharpen or subtitle or before? this is how I currently have it setup:
deband
sharpen
avisynth
subtitles
Thanks
Add this to your plugins directory. I'll have to link this to the op later on. http://avisynth.org/warpenterprises/files/colormatrix_20070828.zip
The order you have is correct.
TheElix
5th February 2011, 00:48
I don't get it. There's no visible change between using this script or plain fullscreen:
AutoResize v.1.7 on: http://rghost.ru/4210378/image.png
AutoResize v.1.7 off: http://rghost.ru/4210411/image.png
Furthermore, CPU usage goes from 15-20% to a whopping 60-80%! All that for just subtitles quality? When you can use DirectVobSub which have the option to double the resolution of subtitles?
I guess it's not for me.
fairchild
5th February 2011, 01:18
Add this to your plugins directory. I'll have to link this to the op later on. http://avisynth.org/warpenterprises/files/colormatrix_20070828.zip
The order you have is correct.
Thanks that worked. But I'm still seeing this error on everything but 720p. Any ideas?
Resize: YV12 width must be multiple of 4.(,line 77)(ffdshow_filter_avisynth_script,line 5)
fairchild
5th February 2011, 01:20
When you can use DirectVobSub which have the option to double the resolution of subtitles?
I guess it's not for me.
This script works good for those of us who can't get DirectVobSub to work. I never have been able to get it to work on Win7 64-bit using Potplayer and MadVR.
dansrfe
5th February 2011, 01:48
I just found a bug in the script involving HD Resizing and spent some time fixing it. The new script has been linked, yet again.
Thanks that worked. But I'm still seeing this error on everything but 720p. Any ideas?
Resize: YV12 width must be multiple of 4.(,line 77)(ffdshow_filter_avisynth_script,line 5)
Tell me what the input resolution is of what you're trying to play and what you're using in the AviSynth window in ffdshow including the script area.
Gavino
5th February 2011, 01:52
Resize: YV12 width must be multiple of 4.(,line 77)(ffdshow_filter_avisynth_script,line 5)
Avisynth 2.57 restricts YV12 resizing to mod4 widths.
You need to update to Avisynth 2.58 or higher.
Alternatively, perhaps the function could be changed to use only mod4 widths - I don't know what effect this would have on its operation.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.