Author Topic: [script] apply partial filters based on [A B] markers  (Read 380 times)


  • Newbie
  • *
  • Posts: 36
[script] apply partial filters based on [A B] markers
« on: April 26, 2017, 03:02:06 PM »
Hi there,

I coded a tiny script to help you adding partial filters; just set up the range where the filter should be applied with the [A & B] markers and run the script.
(Please note that B is is inclusive contrary to ADMs normal behaviour!)

Standard behaviour is to reset the markers afterwards (ie whole video selected again), but you can untick that checkbox (or change the code if you never want it)

Right now, only my four 'favorites' are included: Fade in/ out from/ to black, Replace by solid black & DeLogo as a partial filter.
But you can add any other (which ADM allows to be partial) yourself, see inline comments; or ask me to add it ;)

Attention! Due to a bug in ADM use the script only once per session, otherwise ADM will crash.
If you need it a second time, either on the same video or a new one, you have to close & restart ADM (save your work in progress project script first, if needed).
I hope the bug will get extinguished soon ^^

Code: [Select]
# adds partial filters based on [A B] markers

# basic setup

# helper function to forge the comand to add a filter
def add_filter(f, a, b):
    c = filters[f]
    out = [c['name'],
           c['a'] + '=' + str(a),
           c['b'] + '=' + str(b)

# get marker positions (typecast since // seems broken)
ts_a = int(adm.markerA / 1000)
ts_b = int(adm.markerB / 1000)

# since I wanted to have a custom area as preset for the delogo filter (1/3 of video dimensions)
# I set up those options separately
delogo_opt = ["filterName=mpdelogo2",
    "xoff=0", "yoff=0",
    "lw=" + str(int(adm.getWidth() / 3)),
    "lh=" + str(int(adm.getHeight() / 3)),
    "band=4", "show=False"

### filter list - extend to your needs ###
#       desc:   shows up in the menu
#       name:   the actual filter name
#       a, b:   parameter names for start and end frames
#       opt:    additional parameters for the filter
#  >>   take the values from a saved project with your desired filter

filters = [
    {'desc': 'Fade in from black', 'name': 'fadeToBlack', 'a': 'startFade', 'b': 'endFade',
    'opt': ["inOut=True", "toBlack=True"]},
    {'desc': 'Fade out to black', 'name': 'fadeToBlack', 'a': 'startFade', 'b': 'endFade',
    'opt': ["inOut=False", "toBlack=True"]},
    {'desc': 'Black', 'name': 'black', 'a': 'startBlack', 'b': 'endBlack', 'opt': []},
    {'desc': 'DeLogo', 'name': 'partial', 'a': 'startBlack', 'b': 'endBlack',
    'opt': delogo_opt}

mnu_filters = DFMenu("Filter to add:")
for filt in filters:
toggle_reset = DFToggle("Reset markers afterwards")
toggle_reset.value = True

dlg = DialogFactory("Partial filter helper")
if res == 1:
    filt = mnu_filters.index
    add_filter(filt, ts_a, ts_b)
    if toggle_reset.value:
        adm.markerA = 0
        adm.markerB = Editor().getVideoDuration()

Usage: save that code as .py file (eg in either
  • the custom script folder (Help > Advanced > Open Apllication Data Folder)
  • the Auto scripts folder (\plugins\autoScripts in ADM's application folder)
  • just anywhere & run it by File > Project Script > Run Project...

Please note that you can only add filters, not change an existing one, since there is no script access to the current filter list (at least I haven't found one).

If you have any problems or just find it useful, let me know! ;)


  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10935
Re: [script] apply partial filters based on [A B] markers
« Reply #1 on: April 27, 2017, 08:36:33 AM »