[Ffmpeg-devel] pip.c - PiP (Picture in Picture) v1.0patch.Remakeof watermark.c

Víctor Paesa wzrlpy
Wed Oct 25 11:54:00 CEST 2006


Hi,
> Cheers,
> I hope you like it

Sure.

> This code was taken from pip.c
>                 // Convert the image from its native format to RGBA32
>                 ci->watermark_convert_ctx =
>                     sws_getCachedContext(ci->watermark_convert_ctx,
>                         ci->pCodecCtx->width, ci->pCodecCtx->height,
> ci->pCodecCtx->pix_fmt,
>                         ci->x_size, ci->y_size, PIX_FMT_RGBA32,
>                         sws_flags, NULL, NULL, NULL);
>
> I don't know how you get that ci->watermark_conver_ctx = +
> sws_getCachedContext...
>
> I'm attaching you zipped pip.c
>
It worked strightforward this time.

I have found a few corner cases where it doesn't work as expected:

# Any input PNG will do, the idea is to have a good contrast
# against border so that is easy to see artifacts
pamgradient red green blue yellow 720 576 | pnmtopng  > input.png

# Let's put a border around a square
ffmpeg -loop_input -vframes 25 -f image2 -i input.png -an -vcodec ffv1 \
-s 100x100 -padcolor C0C0FF -padtop 2 -padbottom 2 -padleft 2 -padright 2\
-y 'border_enclosed.avi'

# This produces a wrong 4 pixel black border at bottom
ffmpeg -loop_input -vframes 25 -f image2 -i input.png \
-vhook 'pip.dll -f border_enclosed.avi -m 2 -x 360 -y 288 -w 102 -h 102 ' \
-vcodec ffv1 -y 'border_enclosed_result.avi'

# This produces a wrong 8 pixel black border at bottom
ffmpeg -loop_input -vframes 25 -f image2 -i input.png \
-vhook 'pip.dll -f border_enclosed.avi -m 2 -x 360 -y 288 -w 98 -h 98 ' \
-vcodec ffv1 -y 'border_enclosed_result.avi'

# This produces a wrong black pixel at bottom right corner
ffmpeg -loop_input -vframes 25 -f image2 -i input.png \
-vhook 'pip.dll -f border_enclosed.avi -m 2 -x 360 -y 288 -w 107 -h 106 ' \
-vcodec ffv1 -y 'border_enclosed_result.avi'


# Now let's put a border around a rectangle
ffmpeg -loop_input -vframes 25 -f image2 -i input.png -an -vcodec ffv1 \
-s 144x114 -padcolor C0C0FF -padtop 2 -padbottom 2 -padleft 2 -padright 2 \
-y 'border_enclosed.avi'

# This produces a wrong 4 pixel black border at the right
ffmpeg -loop_input -vframes 25 -f image2 -i input.png \
-vhook 'pip.dll -f border_enclosed.avi -m 2 -x 360 -y 288 -w 148 -h 118 ' \
-vcodec ffv1 -y 'border_enclosed_result.avi'

Could you please check them?

Thanks&regards,
V?ctor




More information about the ffmpeg-devel mailing list