News:

--

Main Menu

Auto Crop via py-scripting

Started by autoCropPlease, December 30, 2020, 09:49:20 PM

Previous topic - Next topic

autoCropPlease

Is there a way to auto crop videos via py-scripting? I've searched through the forum but couldn't find the answer :'(

To crop a video via scripting, I need to do this:

adm.addVideoFilter("crop", "top=0", "bottom=0", "left=240", "right=240", "rubber_is_hidden=False")

The problem is that there may be a lot of videos with bigger or lesser black borders that I need to auto crop as a batch.

It would be great to be able to do something like this:

adm.addVideoFilter("crop", "top=0", "bottom=0", "left=auto", "right=auto", "frame=2", "rubber_is_hidden=False")

eumagga0x2a

Autocrop evaluates the currently loaded preview image in the filter preview of the "crop" filter, it is useless without human supervision and intervention.

autoCropPlease

Quote from: eumagga0x2a on December 30, 2020, 10:55:18 PMAutocrop evaluates the currently loaded preview image in the filter preview of the "crop" filter, it is useless without human supervision and intervention.
Hi, eumagga0x2a,

Thank you for your reply.

It becomes useful in case I'm sure that each of my videos has consistent black borders across all its frames.

"The currently loaded preview image" is just a frame, right? "frame=2" in my previous post's imaginative example means "evaluate the second frame of each video and auto crop it according to that frame".

eumagga0x2a

#3
Quote from: autoCropPlease on December 31, 2020, 09:48:22 AMt becomes useful in case I'm sure that each of my videos has consistent black borders across all its frames.

Are you really sure? I'm not. A lot of videos start black. A lot of black bars contain noise or broadcaster's logo.

Additionally, I would generally advise against cropping for the purpose of removing black bars except of the case of converting hi-res source to standard-resolution DVD video. By all means, avoid non-standard resolutions and display aspect ratios.

eumagga0x2a

Something like detectBlackBars(uint64_t time, uint32_t *top, uint32_t *bottom, uint32_t *left, uint32_t *right) function, exposed via internal python interface, might make sense, however. Maybe :-)

autoCropPlease

eumagga0x2a,

My use case revolves around fullscreen recording browser games (they tend to have different aspect ratios which leads to bigger or lesser black borders). Recording while in Chrome's fullscreen mode means consistent pitch-black borders across all the frames, plus I never start with a blank black screen.

Seems like a valid use case to me ^_^

Quote from: eumagga0x2a on December 31, 2020, 10:07:24 AMSomething like detectBlackBars(uint64_t time, uint32_t *top, uint32_t *bottom, uint32_t *left, uint32_t *right) function, exposed via internal python interface, might make sense, however. Maybe :-)
This is interesting!

eumagga0x2a

Just please don't expect it already in 2.7.7 release :-)

eumagga0x2a

(IMHO there is nothing wrong with black bars, really)

autoCropPlease

Quote from: eumagga0x2a on December 31, 2020, 10:17:50 AMJust please don't expect it already in 2.7.7 release :-)
2.7.8 maybe? :D

OK, I'm not pushing :)