Skip to content

blog.spoRv.com

a blog about video restoration… and something more!

AviSynth scripts

DeSub – automatic hardcoded subtitles removal

by admin 2016-11-29
DeSub – automatic hardcoded subtitles removal (Avisynth script)

Is it too good to be true? Well, it needs two clips, one with subtitles (or logo), and the other without; will create a mask “on the fly”, and the subtitles (logo) will be replaced with the corresponding part of the image of the clip without logo.

For best result, it’s better to limit usage

only to frames with subtitles; clips must be aligned perfectly, both temporally and spatially; must have the same (or very similar) colors; it’s always poss

ible to merge the result and the existing not subbed clip to improve quality.

Save it as DeSub.avsi and put into your

AviSynth plugins folder.

Code:
###########################################################################################
### DeSub 1.0: removes the subtitles with no need to prepare a mask for every line!     ###
###                                                                                     ###
### Two spatially and aligned clips are needed, one with hardcoded subtitles, or logo,  ###
### and the other without; the script creates a mask "on the fly" that will be used to  ###
### cover the subtitles with the corresponding parts of the clip without them.          ###
###                                                                                     ###
### Usage:   DeSub(clipwithsubs,clipwithoutsubs,subcolor)                               ###
###                                                                                     ###
### Example: goodclip.avi has subtitles, badclip.avi has no subtitles, subs color white ###
###                                                                                     ###
###          DeSub(goodclip,badclip,$ffffff)                                            ###
###                                                                                     ###
### It is highly reccomended to use it only on frames with subtitles                    ###
### Possible update: limit the use to a certain area of the frame, perfect for logo!    ###
###                                                                                     ###
### AviSynth script made by spoRv (https://blog.sporv.com) - Created: 2016-11-29         ###
###                                                                                     ###
### Creative Commons 4,0 - Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)      ###
### Link to the licence page: https://creativecommons.org/licenses/by-sa/4.0/           ###
###########################################################################################

function DeSub (clip withsubs, clip nosubs, val "color") {

withsubs=withsubs.converttoyv24
nosubs=nosubs.converttoyv24
color=default(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

}

I tested it, and seems to work well; of course, could still be improved. Waiting for your test results and impressions!Examples – top DeSub result, bottom original:

[Image: desub2.jpg]

[Image: desub4.jpg]

[Image: desub3.jpg]

[Image: desub1.jpg]

Post Views: 347

Tags: delogodesubhardcodedhardsubslogosubssubtitles

You may also like...

1
Hardware Reviews

High-End audio capture cards

0
Movie Reviews

Frankenstein’s Army (2013) – review

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Cinematica  –  What Film Do You See?
 ⟲    ➴
 

  • Next The strange case of Star Wars Rai Tre broadcast…
  • Previous Restoration for dummies

Fundamental links

spoRv gauge calculator (rev. 2022-09-23)
Ultimate Aspect Ratio
Star Wars on laserdisc

FanRes forum
Original Trilogy
LDDB forum
Bad Audio on Blu-ray

spoRv on Vimeo

Master lists

FAN EDITS
OPEN MATTE
THX CERTIFIED
WORKPRINTS

Recent Posts

  • Restoration tips: MergeHdUp™
  • Do we really need 8K?
  • Restoration tips: spoRv Gauge™
  • 4K is not equal to 4K
  • “I was shot today” – surround comparison #2

Recent Comments

  • admin on Disentangling “The Thing”!
  • Sam on Disentangling “The Thing”!
  • admin on Suggestions
  • Jacelyn on OPEN MATTE – Master List
  • AStranger on Suggestions

Categories

  • Articles (8)
  • Audio Guides (7)
  • Audio Restoration (3)
  • AviSynth scripts (1)
  • Hardware Reviews (2)
  • Lists (4)
  • Movie Reviews (48)
  • Projects (16)
  • Uncategorized (11)
  • Video Guides (8)
  • Video Restoration (13)
  • Waveform comparison (3)

Archives

  • September 2022 (1)
  • August 2022 (1)
  • January 2022 (1)
  • November 2021 (2)
  • October 2021 (4)
  • September 2021 (2)
  • April 2018 (1)
  • February 2018 (1)
  • May 2017 (2)
  • February 2017 (1)
  • January 2017 (7)
  • December 2016 (2)
  • November 2016 (4)
  • June 2015 (2)
  • May 2015 (1)
  • March 2015 (1)
  • February 2015 (1)
  • January 2015 (4)
  • October 2014 (2)
  • September 2014 (3)
  • August 2014 (1)
  • July 2014 (15)
  • June 2014 (11)
  • May 2014 (8)
  • April 2014 (17)
  • February 2014 (2)
  • January 2014 (2)
  • December 2013 (13)
  • December 1999 (1)

Tags

4k action alien animation audio tracks capture color grading comedy conspiracy cyborg demons drama family Frankenstein future gargoyles ghost girls horror killer kush gauge laserdisc martial arts master list monster nazi open matte overlap matching post apocalyptic restoration school sci-fi spaceship Star Wars supernatural surround technique the thing thriller time travel uhd upscale vampire waveform zombie

Pages

  • _,,,^..^,,,_
  • “less is more”…
  • About
  • Disclaimer
  • Links
  • Projects
  • Suggestions

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

blog.spoRv.com © 2023. All Rights Reserved.

Powered by WordPress. Theme by Alx.