[FFmpeg-user] How to create trapezoid videos with ffmpeg?

Moritz Barsnick barsnick at gmx.net
Sat Oct 18 14:36:33 CEST 2014


On Fri, Oct 17, 2014 at 11:18:04 -0700, Nicholas Robbins wrote:

> Ok, I'm not sure what you meant by an easy way, but the formula for
> what to put into the perspective filter options to essentially have
> it be the inverse (where to send the corners, not what to send to the
> corners) is huge mess, so it can't be done easily for any given
> picture (just change the x0 to a -x0 or whatever).

You basically got it right. (I happened to follow the thread on
ffmpeg-devel, thanks for forwarding it.)

a) An inverse calculation, like in your example given. But that's just
totally over the top, no-one can be expected to be capable of such a
calculation. I tried to figure it out from the code, but couldn't.

> be able to be hardcoded into a different filter (vf_keystone?) I'll
> inquire on ffmpeg-devel if that is possible, to have one filter
> basically just call another filter with different options.

b) What I meant - and you got it totally right on ffmpeg-devel - is to
re-use the code from the perspective filter, because it contains all
the transformations, considerations, and colorspace cruft. Just the
wrong parameters. So the questions regarding "how to re-use a filter's
algorithms/mechanisms without duplicating its code" are spot-on.

That said, I pointed out that the perspective filter is doing peculiar
things with the color edges when using such "negative" parameters. Have
a look at my testsrc example's output. Possibly the perspective filter
was only written with "inside" reference points in mind. The opposite
filter would also need to be able to fill the remaining "empty" space
with some kind of transparency/alpha channel, so that overlaying the
warped frame over another stream is possible. That's basically what the
original poster was looking for, and what makes sense to me from a user
perspective.

I'm happy to try coding, but don't know nearly enough about the libav*
code to cope. ;-)

Moritz


More information about the ffmpeg-user mailing list