This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[Feature Request] FFMpeg 'pad' command
#1
I would like to request the implementation of the equivalent of FFMpeg's 'pad' filter (https://ffmpeg.org/ffmpeg-filters.html#pad-1).  Pad is a valuable tool for use in cropping and repositioning a video stream within a frame.  Most often it is used in conjunction with crop and letterbox.

Pad is essentially a combination 2D translation and padding tool in one.  The user specifies the dimensions of an empty frame, then places (translates) the cropped video into the empty frame at a specified position (using the coordinate of the upper left corner of the video as the origin).  The remaining empty space is set to black by default, but can be any specified color.  The end result is a video with letterboxing.  Most useful for cases where the cropping of the video is assymetrical, or the results of cropping produces a dimension that is incompatible with the output resolution and you cannot resize/scale the cropped video to fit the output resolution.

Example:

A 720 x 480 video is cropped to 696 x 472 because of garbage/noise on the perimeter.  Resizing the cropped video would introduce too much distortion.  Pad would define a new empty 720 x 480 frame, then position the 696 x 472 video within that frame leaving black borders on all sides where the video does not fill it.  The result is the cropped video is centered vertically and horizontally (by default, but can be overriden with parameter adjustments) leaving a nice clean presentation with minimal hassle to the user as they don't have to do complicated math to figure out the DAR, SAR, PAR, and all the other settings.  Significantly easier to use than Hybrid's current letterboxing solution.

I don't use FFMpeg for much these days, but when I do, 'pad' is heavily involved.  This is one area Hybrid could use improvement.
Reply
#2
Sorry, that it hinders your workflow.
I will not add support for all the options pad offers:
39.182 pad
Add paddings to the input image, and place the original input at the provided x, y coordinates.

It accepts the following parameters:

width, w
height, h
Specify an expression for the size of the output image with the paddings added. If the value for width or height is 0, the corresponding input size is used for the output.

The width expression can reference the value set by the height expression, and vice versa.

The default value of width and height is 0.

x
y
Specify the offsets to place the input image at within the padded area, with respect to the top/left border of the output image.

The x expression can reference the value set by the y expression, and vice versa.

The default value of x and y is 0.

If x or y evaluate to a negative number, they’ll be changed so the input image is centered on the padded area.

color
Specify the color of the padded area. For the syntax of this option, check the (ffmpeg-utils)"Color" section in the ffmpeg-utils manual.

The default value of color is "black".

eval
Specify when to evaluate width, height, x and y expression.

It accepts the following values:

‘init’
Only evaluate expressions once during the filter initialization or when a command is processed.

‘frame’
Evaluate expressions for each incoming frame.

Default value is ‘init’.

aspect
Pad to aspect instead to a resolution.

The value for the width, height, x, and y options are expressions containing the following constants:

in_w
in_h
The input video width and height.

iw
ih
These are the same as in_w and in_h.

out_w
out_h
The output width and height (the size of the padded area), as specified by the width and height expressions.

ow
oh
These are the same as out_w and out_h.

x
y
The x and y offsets as specified by the x and y expressions, or NAN if not yet specified.

a
same as iw / ih

sar
input sample aspect ratio

dar
input display aspect ratio, it is the same as (iw / ih) * sar

hsub
vsub
The horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" hsub is 2 and vsub is 1.
see: https://ffmpeg.org/ffmpeg-all.html#pad-1

since it would require a mayor rewrite of the internal logic of all the calculations around PAR, crop, resize to be sure everything works as it does now.


Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)