1

I am using ffmpeg to overlay a picture on a movie. The requirement is to rotate the picture through an arbitrary angle. Using filter_complex, I can overlay the rotated picture now. However, the output area of the picture is filled in black and not transparent. I checked the docs, it says can specify the fill color, according to this, but I failed to do so. Any ideas?

I copy my command line here:

./ffmpeg -i mersyvideo.mp4 -i avatar.jpg -filter_complex "[1:v] rotate=-30*PI/180:c=black@'0x00':ow=rotw(iw):oh=roth(ih) [rotate];[0:v][rotate] overlay=40:10" -codec:a copy output/overlayavatar.mp4
2
  • Have you tried this? -vcodec png -pix_fmt bgra overlayavatar.mov Jul 2, 2014 at 10:23
  • sorry, but i am not using any PNGs with alpha channel. besides, I do not want to transparent the picture itself.
    – xftzg
    Jul 3, 2014 at 4:55

1 Answer 1

2

To fill the non-covered areas with transparent, use the option c=none:

ffmpeg \
  -i mersyvideo.mp4 \
  -i avatar.jpg \
  -filter_complex "
  [1:v]rotate=-30*PI/180:c=none:ow=rotw(iw):oh=roth(ih)[rotate];
  [0:v][rotate]overlay=40:10
  " \
  -codec:a copy \
  output/overlayavatar.mp4

See the rotate filter help:

fillcolor, c

Set the color used to fill the output area not covered by the rotated image. For the general syntax of this option, check the (ffmpeg-utils)"Color" section in the ffmpeg-utils manual. If the special value "none" is selected then no background is printed (useful for example if the background is never shown).

Default value is "black".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .