Video Crop Filter Presets

Started by drivetheory, March 09, 2024, 09:46:53 AM

Previous topic - Next topic


2 really basic traditional aspect ratio presets from the photography world are missing

5x8 and 8x5

This is a really minor feature, but adding it would be a huge improvement.

OR why not add a [text]:[text] numeric input box pair for such from the drop down menu?

Current Crop workflow:
1) calculate 8 less than video width, enter into Right input box.
2) calculate 5 less than video height, enter into Bottom input box.
3) change lock aspect ratio to current selection.
4) re-adjust crop to desired area.

This one little change would reduce the number of steps in my workfow by 50% and would significantly improve efficiency.


Avidemux is a video editor, not a photo editor. You could argue for any standard print size being included. Just a bit too niche I think.
Having said that, it is probably possible with a .py script run from the custom menu. You can easily adapt files. but only for a given size, not a specific aspect ratio, as they use a reference number for the default ratios


Adding more predefined crop aspect ratios will invalidate existing projects, unfortunately. This approach doesn't scale with the current filter implementation, not happy with that, the filter configuration needs a redesign.

The only immediate help I can offer is a script (briefly tested) to preset the rubber band on condition that
1. the source video uses square pixel (non-anamorphic) and
2. no filter which would change video size has been added yet (scripts get video size from the editor, not from the filter chain)

You must select an encoder prior to using this script.

#PY  <- Needed to identify #
ui = Gui()
adm = Avidemux()

if not adm.isFileOpen():
    return 0

if ((adm.getPARWidth() != 1) or (adm.getPARHeight() != 1)):
    ui.displayError("Error", "Anamorphic input is not supported by this script")
    return 0

w = adm.getWidth()
h = adm.getHeight()

if ((w < 64) or (h < 64)):
    ui.displayError("Error", "Width or height smaller than 64 px is not supported by this script")
    return 0

# -------- select aspect ratio --------
ars = ["8:5","5:8"]
mx = len(ars)

menuAr = DFMenu("Select aspect ratio:")
for entry in range(0, mx):
dia = DialogFactory("Preset crop filter")
if not
    return 0

idx = menuAr.index

if idx < 0 or idx >= mx:
    ui.displayError("Oops", "Internal error: invalid menu index")
    return 0

ratio = float(w) / h
marginr = 0
marginb = 0

if idx == 0:
    if ratio > float(8) / 5:
        marginr = int(w - h * float(8) / 5)
        marginb = int(h - w * float(5) / 8)
elif idx == 1:
    if ratio > float(5) / 8:
        marginr = int(w - h * float(5) / 8)
        marginb = int(h - w * float(8) / 5)
    ui.displayError("Error", "Unhandled aspect ratio \"" + ars[idx] + "\"")
    return 0

if marginr < 0:
    marginr = 0
if marginb < 0:
    marginb = 0

stringBottom = "bottom=" + str(marginb)
stringRight  = "right="  + str(marginr)

adm.addVideoFilter("crop", "top=0", stringBottom, "left=0", stringRight, "ar_select=1")
ui.displayInfo("Crop preset", "Crop filter added with right margin set to " + str(marginr) + " and bottom margin set to " + str(marginb) + ".")
return 1

This would automate the first three steps from your crop workflow.