View Full Version : DVD function, automaticaly add borders and resize
MatLz
5th December 2009, 07:13
Hi, I don't know if a function like that already exists but I wrote a small one which automaticaly adds borders and resizes to matche with dvd resolutions to feed your mpeg2 encoder or dvd rebuilder. I also added an option ('care' Correct Aspect Ratio Estimation) if the input has not the correct aspect ratio, just set it to have only one resizing in the script.
LAST UPDATE (v0.3a) : http://forum.doom9.org/attachment.php?attachmentid=10581&d=1261000196
MatLz
9th December 2009, 13:09
Already 35 downloads and no bug report? Nice!:D
Update:
*Change lanczos4resize to spline16resize to limit halos artifacts
*Add 'hq' mode using nnedi2 upscaling. Particulary usefull for low resolution sources, specialy on animes:
[img=http://img187.imageshack.us/img187/893/00000j.th.jpg] (http://img187.imageshack.us/i/00000j.jpg/)
Here it is:
buzzqw
9th December 2009, 13:13
since script is very small post it as with CODE tag
BHH
MatLz
9th December 2009, 13:20
since script is very small post it as with CODE tag
BHH
I can't write more 500 or 502 bytes in posts, I'm on a crappy phone!
Edit: After PMing myself, it appears my limit is 515 bytes. Good to know.
wonkey_monkey
9th December 2009, 16:23
A very handy little function, but it (first version anyway) doesn't incorporate overscan (edit: sorry, not overscan; nominal analogue blanking (http://en.wikipedia.org/wiki/Nominal_analogue_blanking)). It should scale up to a target of 702x576 (PAL) or 704x480 (NTSC) [these dimensions define the 4:3/16:9 box], then addborders to 720 (or 704, which is also legal for DVD).
David
MatLz
9th December 2009, 19:38
Urrrh:eek:
99% of dvd I've see hadn't these lateral borders...:confused::confused:
If someone else ask for, I will include that as an option.
But that maybe means too much difficulties to code for my tiny brain!:D
Thx for the info.
MatLz
9th December 2009, 21:44
Here it is maybe with 'nominal analogue blanking'...I repeat: maybe...
MatLz
11th December 2009, 13:00
As I said, and as expected:D, my previous code seems to be wrong...
I'm a little lost.
And in some cases, it's a real nonsense to use nominal analogue blanking:
*letterboxing when input aspect ratio is less (there is a proportionnality to calculate) than the output aspect ratio, because we lost height's pixels for nothing...
Examples: 1.2 in 4/3, 1.6 in 16/9....
New attempt:
wonkey_monkey
11th December 2009, 14:26
*letterboxing when input aspect ratio is less (there is a proportionnality to calculate) than the output aspect ratio, because we lost height's pixels for nothing...
The pixels in the blanking area don't have to be blank, it's just that the aspect ratios you were targetting for the 720x[480/576] image were slightly wrong.
Just think of the 720x576 box as having an aspect ratio of either ~16.4:9 or ~4.1r:3 rather than 16:9 or 4:3. The result would be the same as if you'd applied your original script, then scaled down to 704 width (or 702 for PAL) and added borders back to 720. The image's height would be the same.
Of course this all assumes that the video was scaled down correctly in the first place, which may not be the case...
David
MatLz
11th December 2009, 20:50
Well...I don't understand a lot...english is not my native language and it's too much technical...
And you can't see the new code...the attachments aren't approved...it's long very long...
See you later.
Alex_ander
12th December 2009, 10:55
In other words, if you use the final horizontal size 720 (rather than 704), the planned (for DVD) height of a 4:3 or 16:9 image must be first adjusted in 720/704 proportion, then in case of anamorphic - cropped to 480 or 576, in case of letterboxed - rounded to a multiple of 16/8/4 (with addition of horizontal borders).
That is because the standard DV/DVD AR's are defined for the limited area of 704x576(480) within 720x576(480).
MatLz
16th December 2009, 22:52
Thanks, really big thanks for all the explanations guys...but...:confused:
dvd 0.3a
Total reversion of the process order so new calculations of the ratios:
*Depending of the input and the output AR, there is a huge speedup compared to other versions (50% with 2.5:1 in 16/9, 100% in 4/3 !!!)
*Better quality near the added borders (this "kindofsubsamplingartifact" isn't present anymore)
*Maybe Nominal Analogue Blanking at least right coded?:confused:?
dannybz
18th February 2010, 01:45
MatLz, how exactly do I use your script? Open with notepad?
MatLz
18th February 2010, 14:38
Just put the avsi in the Avisynth plugins directory and call the function in your script.
You can simply use:
dvd() for outputing pal 16/9.
If you need other standard, format, quality or the nominal analogue blanking, just write your settings in the ().
dannybz
19th February 2010, 02:33
MatLz, thanks, but I am new in scripting and I am only used to the most common scripts of AVIsynth. How do I call your script?
The way I encode is that I create a simple AVIsynth script and open with CCE and start encoding. How do I work with this? Can you help me?
MatLz
19th February 2010, 03:03
Ok....download the attachement dvd_0.3a.avsi.txt. Rename this txt file in .avsi and put it in the Avisynth plugin directory.
And post your script and tell me the specs you want : if you want pal or ntsc, 16/9 or 4/3, if you need the nominal analogue blanking
Like that I will give you the last line of your script.
dannybz
20th February 2010, 15:46
This is the script I have, its an NTSC 23.976fps clip. Im looking for a 4:3. I don't need the black borders on the left or right (nab).
AVISource("H:\FUN\NEWYEARS2010\BASH.avi",FALSE)
LanczosResize(720,360,0,0,640,352)
AddBorders(0,56,0,64)
ConvertToYUY2()
wonkey_monkey
20th February 2010, 16:32
What's the width and height of original clip, and for what reason are you (it seems) cropping it?
David
dannybz
20th February 2010, 20:43
The clip is 640x352. Im using FitCD to get that script. Sorry for my ignorance about scripting, but I don't want to crop it.
wonkey_monkey
20th February 2010, 20:55
The clip is 640x352. Im using FitCD to get that script. Sorry for my ignorance about scripting, but I don't want to crop it.
The four parameters after the target size on the lanzcosresize line would crop the video, but obviously with those numbers it'll just keep the same size. The script as posted will give you the correct aspect ratio for 4:3 NTSC DVD, though for some reason it won't quite be centred in the letterbox. I'd change the addborders to:
addborders(0,60,0,60)
David
wonkey_monkey
21st February 2010, 13:22
Actually, you might be better off with:
lanczosresize(704,352) # 704 is also a valid width for DVD video
addborders(0,64,0,64)
That way you're not resizing vertically so you keep a little bit more detail.
David
dannybz
21st February 2010, 15:17
Thanks David, and yes Im encoding for a 4:3 TV.
If I were to encode for a widescreen TV, how will the script change? I want to be prepared in the future just in case.
MatLz
21st February 2010, 16:22
As it seems you're in ntsc land, simply change the two lines in the avsi:...
function dvd(clip dvdin,string "far",string "std",float "care",bool "hq",bool "nab")
{
std=default(std,"ntsc")
...Like that, you will just need in your script:source
dvd("4/3")orsource
dvd("16/9")NOTHING ELSE
ALL ALWAYS AUTOMATICALY DONE
It is the goal of my function...:rolleyes:
wonkey_monkey
21st February 2010, 16:41
If I were to encode for a widescreen TV, how will the script change? I want to be prepared in the future just in case.
Just remember that anamorphic widescreen is 1.333x vertically stretched, so you'd resize to either to 704 by 352*1.33~=469, or (more simply) straight to the full 720,480 with no borders.
David
dannybz
2nd April 2011, 18:09
Just remember that anamorphic widescreen is 1.333x vertically stretched, so you'd resize to either to 704 by 352*1.33~=469, or (more simply) straight to the full 720,480 with no borders.
David
Now I got into a problem, my avi source is akwardly 704x288 PAL and Im trying to size and encode to a wide screen PAL. But Im not sure if my script is correct, can you check it for me, which produces a 704,432 size. Then I will flag it as 16:9 using CCE to make it widescreen. Right?
LanczosResize(704,336)
AddBorders(0,48,0,48)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.