Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st May 2005, 23:19   #1  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,779
Using DeKafka for removing hardburned subtitles question

i played around with dekafka for removing hardburned subtitles

i somehow dont really get what the sense of substracting -2 in the following lines is (and why ybot and xright dont get 2 removed too):
Code:
topline = clip.Crop(Xstart-2, ytop-2, X, 2)
bottomline = clip.Crop(Xstart-2, ybot, X, 2)
leftline = clip.Crop(xleft-2, ytop-2, 2, Y)
rightline = clip.Crop(xright, ytop-2, 2, Y)
especially the top/bottomline -2 is strange, as it leads to that the output overlayed picture is moved to the right for 2 pixels and therefore not being "in sync" anymore with the underlying picture by 2 pixels

i adopted the script for not having to provide a maskclip and for not having the pic moved to the right for 2 pixels:

Code:
function dekafka(clip clip, int Xstart, int Ystart, int X, int Y, int Amount)
{
ytop = Ystart
ybot = Ystart + Y
xleft = Xstart
xright = Xstart + X
topline = clip.Crop(Xstart, ytop-2, X, 2)
bottomline = clip.Crop(Xstart, ybot, X, 2)
leftline = clip.Crop(xleft-2, ytop-2, 2, Y)
rightline = clip.Crop(xright, ytop-2, 2, Y)
logosrc_hor = StackVertical(topline, bottomline).Blur(1.58).BilinearResize(X, Y)
logosrc_ver = StackHorizontal(leftline, rightline).Blur(1.58).BilinearResize(X, Y)
Amount2 = (Y>=2*X) ? 255 : 128*Y/X
# Amount2 is small if X >> Y => logoscr_hor is dominant
logosrc = Layer(logosrc_hor, logosrc_ver, "add", Amount2)
clip = clip.Layer(logosrc, "add", Amount, Xstart, Ystart)
return clip
}
anything wrong with that?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free

Last edited by bond; 22nd May 2005 at 13:01.
bond is offline   Reply With Quote
Old 22nd May 2005, 12:12   #2  |  Link
ppera2
Registered User
 
ppera2's Avatar
 
Join Date: Oct 2001
Location: Lands of confusion
Posts: 1,217
See this: http://forum.doom9.org/showthread.php?s=&threadid=94711

There is small error in Dekafka beside that shift, for example at blurs - it should be so:
logosrc_hor = StackVertical(topline, bottomline).Blur(0, 1.58).BilinearResize(X, Y)
logosrc_ver = StackHorizontal(leftline, rightline).Blur(1.58, 0).BilinearResize(X, Y)

But, I think that blurring does not much impromevent. And is buggy in YUY2.

In case of covering subtitles, I think that no need to crop left and right sides. Script would be like this, but I make it 'on fly'

function desubt(clip)
{

#Position & size & Opacity - enter here values by subtitle position and size

Xp = 88
Yp = 288
X = 448 #Must be dividable by 4
Y = 66
Op = 255

#By need:
#clip = clip.ConvertToYUY2()

top = clip.Crop(Xp, Yp-2, X, 2)
bot = clip.Crop(Xp, Yp+Y, X, 2)

#logoh = StackVertical(top, bot).BilinearResize(X, Y)
logoh = StackVertical(top, bot).Blur(0.2, 1.58).BilinearResize(X, Y)
#logoh = StackVertical(top, bot).ConvertToRGB32.Blur(0.2, 1.58).BilinearResize(X, Y).ConvertBackToYUY2()


clip = clip.Layer(logoh, "add", Op, Xp, Yp)
return clip
}

In case of green artifacts by blur use line above or line under, where colorspace is temporarely converted to RGB, only because of blur.
__________________
Informational value of an advert is in inverted proportion to beauty of playing model(s)/actress(es)

Last edited by ppera2; 22nd May 2005 at 12:19.
ppera2 is offline   Reply With Quote
Old 22nd May 2005, 14:21   #3  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,779
hi ppera2, thanks for your answer and tips

Quote:
In case of covering subtitles, I think that no need to crop left and right sides
good idea, to not need StackHorizontal for removing subs

two things on your comments on blur():
Quote:
But, I think that blurring does not much impromevent. And is buggy in YUY2
i do think that using blur is very useful for removing subs (or other big parts of the picture), as when not using it (or another blurrer) the top and bottom half of the picture dont get mixed and therefor you can very easily see the border between the two, which looks very ugly and "unreal", not fitting in the picture imho
when using blur the transition is more smoother and the filtered part fits more the rest of the picture
Quote:
There is small error in Dekafka beside that shift, for example at blurs - it should be so:
logosrc_hor = StackVertical(topline, bottomline).Blur(0, 1.58).BilinearResize(X, Y)
logosrc_ver = StackHorizontal(leftline, rightline).Blur(1.58, 0).BilinearResize(X, Y)
for the purpose of removing subs i think that blurring only vertically, makes the filtered part also looking wierd (the part where the subs were, shows than spaghetti-like lines)

i would say that therefore a full vertical blur with a slight horizontal should be used (as tradeoff between smoothing too much and reducing line-creation) for removing bigger parts of a picture, like in the case of subs removal

Quote:
In case of green artifacts by blur use line above or line under, where colorspace is temporarely converted to RGB, only because of blur
hm is this a known bug in blur()?
i mean using rgb would have the advantage that you can also choose the to-be-removed part more accurately, as you can than crop also in steps of 1

does converting to rgb (and back again if necessary) really take that much extra time?

lemme modify the script the following way:

Code:
function DeSubt(clip clip, int horizontal_position, int vertical_position, int width, int height)
{
clip = clip.ConvertToRGB()

top = clip.crop(horizontal_position, vertical_position-2, width, 2)
bottom = clip.crop(horizontal_position, vertical_position+height, width, 2)

mask = StackVertical(top,bottom).Blur(0.5,1.58).BilinearResize(width,height)

clip = clip.Layer(mask, "add", 255, horizontal_position, vertical_position)
return clip
}
i renamed the values to be more representing, the values dont need to be set in the script itself anymore, increased the blur, added converttorgb (why does X/width always have to be dividable by 4?) and removed ConvertBackToYUY2(), as this backconversion doesnt have to be necessary always
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 22nd May 2005, 17:30   #4  |  Link
ppera2
Registered User
 
ppera2's Avatar
 
Join Date: Oct 2001
Location: Lands of confusion
Posts: 1,217
Blur improvents visual quality, but by my opinion just slightly, so it's matter of taste - use it, and how much blur.

I observed artifacts only by YUY2 blurring, and it's best viewable on B/W captures. Maybe should to contact AVS development team about it...

I looked for some external blur filters, but didn't find usable until now.

Reason why I modified DeKafka is right RGB conversion. It slows it, because whole clip is converted. When converting only mask part it is much less CPU time consuming. Other reason was that colorspace conversions make some color distorsions.

Don't see that unablity to use odd values by YUY2 is big problem - one line more means nothing.

And: how long names using in scripts (programs) is also matter of taste. I don't like too long names, but like long comments (not to write )
__________________
Informational value of an advert is in inverted proportion to beauty of playing model(s)/actress(es)
ppera2 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.