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

qw applemax82 at 163.com
Sat Jun 27 19:53:14 CEST 2015


At 2015-06-28 00:50:30, "Paul B Mahol" <onemda at gmail.com> wrote:
>On 6/27/15, qw <applemax82 at 163.com> wrote:
>> 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?
>
>Can you provide link to logo.png ?

http://image.baidu.com/i?ct=503316480&z=0&tn=baiduimagedetail&ipn=d&word=%E9%80%8F%E6%98%8E%20png&step_word=&pn=15&spn=0&di=24863833610&pi=&rn=1&is=0%2C0&istype=0&ie=utf-8&oe=utf-8&in=23891&cl=2&lm=-1&st=-1&cs=630043753%2C2759659245&os=1637287401%2C3456218485&adpicid=0&ln=1993&fr=%2Cala&fmq=1435427460192_R&ic=0&s=undefined&se=1&sme=0&tab=0&width=&height=&face=undefined&ist=&jit=&cg=&bdtype=0&objurl=http%3A%2F%2Fup.ekoooo.com%2Fuploads2%2Fallimg%2F080730%2F0718443.png&fromurl=ippr_z2C%24qAzdH3FAzdH3Fooo_z%26e3Bjh5555_z%26e3Bv54AzdH3Fp7ktw5xtwg2f7p7h7AzdH3Frg2AzdH3Fda8aa9AzdH3Fa9-9c9d89_z%26e3Bip4s








At 2015-06-28 00:50:30, "Paul B Mahol" <onemda at gmail.com> wrote:
>On 6/27/15, qw <applemax82 at 163.com> wrote:
>> 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?
>
>Can you provide link to logo.png ?
>_______________________________________________
>ffmpeg-user mailing list
>ffmpeg-user at ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-user


More information about the ffmpeg-user mailing list