Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#9454 closed defect (wontfix)

sendcmd w/h to crop appears broken

Reported by: Jozef Chutka Owned by:
Priority: normal Component: undetermined
Version: 4.3.2 Keywords: crop sendcmd
Cc: Jozef Chutka Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

Using ffmpeg 4.4, I am trying to crop video and actually animate the width in time using sendcmd + crop. This however leaves artefacts (either green color or the video texture being repainted repeatedly horizontally/vertically) rendered outside of the cropped area.

How to reproduce:

ffmpeg -f lavfi -i color=color=0xff0000:size=1280x720:rate=25 -filter_complex_script filter.txt -map [v] -t 4 out.mp4 -y

filter.txt

movie=video.mp4,sendcmd=c='0 [expr] crop w (N*10)+10',crop[v];
[0][v]overlay=x=n:eof_action=pass:eval=frame[v]

The code above should animate cropped width from small to large over time. However it seems that rendering appears broken and texture is somehow repeated even outside crop area.

It would be also nice if one could access iw/ih when animating crop size either by:

  1. crop w/h can evaluated per frame just like x/y is (without using sendcmd at all)
  2. sendcmd to recognize iw/ih which is probably hard to do

Attachments (1)

out.mp4.jpg (170.6 KB ) - added by Jozef Chutka 2 years ago.

Download all attachments as: .zip

Change History (12)

by Jozef Chutka, 2 years ago

Attachment: out.mp4.jpg added

comment:1 by Elon Musk, 2 years ago

Resolution: wontfix
Status: newclosed

Changing w/h at runtime is not supported.

comment:2 by Elon Musk, 2 years ago

Both crop supports expressions for w/h, and also sendcmd supports expressions.
But changing w/h at runtime is not supported at all.

comment:3 by Gyan, 2 years ago

Resolution: wontfix
Status: closedreopened

crop supports commands for w and h since d2b78fe6b7

sendcmd has a regression since 70209000fd where it forcibly evaluates the expression within sendcmd itself rather than letting the target filter do it. Which is why the reporter can't use it.

But the 2nd observation is incidental to the core issue of this ticket.

Last edited 2 years ago by Gyan (previous) (diff)

comment:4 by Elon Musk, 2 years ago

Resolution: wontfix
Status: reopenedclosed

What 2nd observation? you entry is very unclear at best.

w/h changing is unsupported in general and in particular with overlay. And is ill posed problem at best.

The case of 700whatever you claim is false and invalid, user explicitly requested it.

comment:5 by Jozef Chutka, 2 years ago

Hi Elon Musk,

can you please clarify what do you mean by "w/h changing is unsupported"? I can set crop w/h in runtime using sendcmd but the output seems broken. Should crop be removed from sendcmd if not supported for runtime w/h changes?

Can you please run the example code I provided, that should render strip of cropped video which grows in width in time, however its doing something unexpected.

in reply to:  4 comment:6 by Michael Koch, 2 years ago

Replying to Elon Musk:

w/h changing is unsupported in general and in particular with overlay.

In some cases it does work, as in this example:

ffmpeg -f lavfi -i color=red:s=800x600 -f lavfi -i color=yellow:s=2x2 -lavfi [1]sendcmd="2.0 scale w 400",scale=w=200:h=200[a];[0][a]overlay=x=100:y=100 -t 5 -y out.mp4

comment:7 by Jozef Chutka, 2 years ago

Understood, will avoid animating crop width/height. Would be also good to mention in documentation that [expr] crop w ... is a no go

comment:8 by Michael Koch, 2 years ago

As a workaround, you could use the fillborders filter to cut away those parts of the overlay video that you don't want to see. Use a color with transparency. Then overlay this video over the background.

comment:9 by Jozef Chutka, 2 years ago

Thanks Elon, fillborders is indeed a working alternative. Would be nice if fillborders could accept left/rigth > 1/2 of iw.

comment:10 by Michael Koch, 2 years ago

As a workaround for fillborders you could also use the geq filter to set the alpha channel with a suitable expression, for example:
geq=a='255*lte(X,my_width)'

comment:11 by Jozef Chutka, 2 years ago

Thanks Michael, gec looks even better considering one doesnt need to use sendcmd with it.

Note: See TracTickets for help on using tickets.