[FFmpeg-user] how to blend logo and video with transparent effect

qw applemax82 at 163.com
Sat Jun 27 18:40:44 CEST 2015


At 2015-06-27 00:21:56, "Paul B Mahol" <onemda at gmail.com> wrote:
>On 6/26/15, Paul B Mahol <onemda at gmail.com> wrote:
>> On 6/26/15, qw <applemax82 at 163.com> wrote:
>>> Hi,
>>>
>>> I use the below command to blend logo image and video together with
>>> transparent effect:
>>> ffmpeg -i ./file1.mp4 -i ./logo.jpg -filter_complex
>>> blend=all_mode=overlay
>>> ./file3.mp4
>>>
>>>
>>>
>>> But the command requires the same resolution from logo image and video.
>>> If
>>> the size of logo image is different from or smaller than that of video,
>>> the
>>> command will report error.
>>>
>>>
>>> How to blend image and video with different size? Could you provide some
>>> command examples?
>>
>> You could crop logo and use expressions in blend filter to pick right
>
>Instead of crop I meant pad filter.
>
>> combination of pixels at any position of image.


I try to use pad filter. If the logo image has no transparent background, I can make a video with transparent effect by using the below command:
ffmpeg -i ./video.mp4 -i ./logo.png -filter_complex "[1]pad=640:480:10:10:black[logo];[0][logo]blend=all_expr='A*(if(gte(X,10)*lt(X,256+10)*gte(Y,10)*lt(Y,256+10),0.5,1))+B*(1-(if(gte(X,10)*lt(X,256+10)*gte(Y,10)*lt(Y,256+10),0.5,1)))'" -strict -2 ./output.mp4
But if the background in the logo image is transparent, the resulting video is not good. I can see a clear rectangle around the logo in the resulting video. If the area around logo in resulting video is the pixel of input video, and no rectangle can be seen, the resulting video will be correct.


How to make a resulting video with a transparent logo image, in which:
1) the area around logo is  the pixel of input video;
2) no rectangle around the logo can be seen;
3) the logo is transparent;


How to make it?







At 2015-06-27 00:21:56, "Paul B Mahol" <onemda at gmail.com> wrote:
>On 6/26/15, Paul B Mahol <onemda at gmail.com> wrote:
>> On 6/26/15, qw <applemax82 at 163.com> wrote:
>>> Hi,
>>>
>>> I use the below command to blend logo image and video together with
>>> transparent effect:
>>> ffmpeg -i ./file1.mp4 -i ./logo.jpg -filter_complex
>>> blend=all_mode=overlay
>>> ./file3.mp4
>>>
>>>
>>>
>>> But the command requires the same resolution from logo image and video.
>>> If
>>> the size of logo image is different from or smaller than that of video,
>>> the
>>> command will report error.
>>>
>>>
>>> How to blend image and video with different size? Could you provide some
>>> command examples?
>>
>> You could crop logo and use expressions in blend filter to pick right
>
>Instead of crop I meant pad filter.
>
>> combination of pixels at any position of image.
>_______________________________________________
>ffmpeg-user mailing list
>ffmpeg-user at ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-user


More information about the ffmpeg-user mailing list