Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AviSynth DeSub - automatic hardcoded subtitles removal
#11
And then put those in the DeSub script?
Reply
Thanks given by:
#12
First you have to understand if the problem is in the file itself or in the script...

So, make a new .avs file, put the first code, load it in virtualdub; if it shows, it means no problems.
Same for second code.
If there is an error in first or second, you must find out what is the problem in the file.
Sadly my projects are lost due to an HDD crash... Sad
Fundamental Collection | Vimeo channel | My blog
Reply
Thanks given by:
#13
Thanks spoRv! VirtualDub is just hanging while trying to load the script. The problem must be in the first script.
Reply
Thanks given by:
#14
(2021-11-23, 06:33 AM)Serums Wrote: VirtualDub is just hanging while trying to load the script.

Big Grin 

ffvideosource needs to write an index file first; depending on the clip lenght/size/complexity and your PC speed, it could take from few to many minutes to finish, so leave it alone (read: do not close virtualdub!); this is a one time process, so next time would take only few seconds to load it!
Sadly my projects are lost due to an HDD crash... Sad
Fundamental Collection | Vimeo channel | My blog
Reply
Thanks given by:
#15
Thanks, spoRv!

I can load the individual scripts but VirtualDub still shows that the DeSub script doesn't have a video stream. The problem must be somewhat deeper.
Reply
Thanks given by:
#16
I checked the script, and it worked - but I swapped the clips with and without subs by mistake... by bad! Blush 

Now you have the revised version in the first post; as you can see, I added also that it works only with white subtitles.

To check if it works:

Code:
nosubs=ffvideosource("F:\Desktop\Projects\old\ivtc.mkv")
# IF IT'S NOT WORKING, REPLACE IT WITH ANY OTHER FILE!!!

withsubs=nosubs.subtitle("SAMPLE SUBTITLE!", font="georgia", size=48, text_color=$ffffff, align=5)
# THIS ADDS SUBTITLES

stackhorizontal(withsubs,desubTEST(withsubs,nosubs))
# THIS TEST IF THE SCRIPTS DELETE SUBTITLES

function DeSubTEST (clip nosubs, clip withsubs) {

withsubs=withsubs.converttoyv24
nosubs=nosubs.converttoyv24
color=$ffffff

subs = withsubs.converttorgb

mask = ColorKeyMask(subs, color, 20)
blk = blankclip(length=withsubs.FrameCount,width=withsubs.width,height=withsubs.height)

over=Overlay(withsubs, blk, mask=mask.ShowAlpha, mode="blend", opacity=1)

mk=over.levels(235,1,255,1,255)

w=2

a=mk.addborders(0,0,w,w).crop(w,w,0,0)
b=mk.addborders(0,0,0,w).crop(0,w,0,0)
c=mk.addborders(w,0,0,w).crop(0,w,-w,0)
d=mk.addborders(w,0,0,0).crop(0,0,-w,0)
e=mk.addborders(w,w,0,0).crop(0,0,-w,-w)
f=mk.addborders(0,w,0,0).crop(0,0,0,-w)
g=mk.addborders(0,w,w,0).crop(w,0,0,-w)
h=mk.crop(w,0,0,0).addborders(0,0,w,0)

x= overlay(b, f, mode="add")
y= overlay(d, h, mode="add")
xx=overlay(a, e, mode="add")
yy=overlay(c, g, mode="add")
z= overlay(x, y, mode="add")
zz=overlay(xx,yy,mode="add")

nu=overlay(z,zz,mode="add")

mk=nu.levels(235,1,255,1,255)

w=3

a=mk.addborders(0,0,w,w).crop(w,w,0,0)
b=mk.addborders(0,0,0,w).crop(0,w,0,0)
c=mk.addborders(w,0,0,w).crop(0,w,-w,0)
d=mk.addborders(w,0,0,0).crop(0,0,-w,0)
e=mk.addborders(w,w,0,0).crop(0,0,-w,-w)
f=mk.addborders(0,w,0,0).crop(0,0,0,-w)
g=mk.addborders(0,w,w,0).crop(w,0,0,-w)
h=mk.crop(w,0,0,0).addborders(0,0,w,0)

x= overlay(b, f, mode="add")
y= overlay(d, h, mode="add")
xx=overlay(a, e, mode="add")
yy=overlay(c, g, mode="add")
z= overlay(x, y, mode="add")
zz=overlay(xx,yy,mode="add")

nu=overlay(z,zz,mode="add")

mk=nu.levels(235,1,255,1,255)

w=4

a=mk.addborders(0,0,w,w).crop(w,w,0,0)
b=mk.addborders(0,0,0,w).crop(0,w,0,0)
c=mk.addborders(w,0,0,w).crop(0,w,-w,0)
d=mk.addborders(w,0,0,0).crop(0,0,-w,0)
e=mk.addborders(w,w,0,0).crop(0,0,-w,-w)
f=mk.addborders(0,w,0,0).crop(0,0,0,-w)
g=mk.addborders(0,w,w,0).crop(w,0,0,-w)
h=mk.crop(w,0,0,0).addborders(0,0,w,0)

x= overlay(b, f, mode="add")
y= overlay(d, h, mode="add")
xx=overlay(a, e, mode="add")
yy=overlay(c, g, mode="add")
z= overlay(x, y, mode="add")
zz=overlay(xx,yy,mode="add")

nu=overlay(z,zz,mode="add").levels(235,1,255,1,255)

numask = ColorKeyMask(nu.ConvertToRGB32, color, 30)

Overlay(nosubs, withsubs, mask=numask.ShowAlpha, mode="blend", opacity=1)

converttoyv12

}
Sadly my projects are lost due to an HDD crash... Sad
Fundamental Collection | Vimeo channel | My blog
Reply
Thanks given by:
#17
Thanks spoRv, I'll test it out!

Edit: I got the sample script to work. I can see the added subtitles in the first preview window of Virtualdub and I can see they've been deleted in the second.
Reply
Thanks given by:
#18
Hi spoRv,

Just an update on my end. Managed to get the script running using a different file. Though the frames didn't match up exactly so it didn't work out. Good to know that I can test it a bit more now.
Reply
Thanks given by:


Forum Jump:


Users browsing this thread: 1 Guest(s)