[FFmpeg-user] Color Channel Expression
Paul B Mahol
onemda at gmail.com
Tue Aug 1 10:53:26 EEST 2017
On 8/1/17, Jon bae <jonbae77 at gmail.com> wrote:
> 2017-07-31 22:16 GMT+02:00 Paul B Mahol <onemda at gmail.com>:
>
>> On 7/31/17, Jonathan Baecker <jonbae77 at gmail.com> wrote:
>> >
>> >
>> > 2017-07-31 14:41 GMT+02:00 Paul B Mahol <onemda at gmail.com
>> > <mailto:onemda at gmail.com>>:
>> >
>> > On 7/31/17, Jon bae <jonbae77 at gmail.com
>> > <mailto:jonbae77 at gmail.com>>
>> > wrote:
>> > > 2017-07-31 14:00 GMT+02:00 Paul B Mahol <onemda at gmail.com
>> > <mailto:onemda at gmail.com>>:
>> > >
>> > >> On 7/31/17, Jon bae <jonbae77 at gmail.com
>> > <mailto:jonbae77 at gmail.com>> wrote:
>> > >> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <onemda at gmail.com
>> > <mailto:onemda at gmail.com>>:
>> > >> >>
>> > >> >>>
>> > >> >>> What exactly you tried?
>> > >> >>>
>> > >> >>> Perhaps you want premultiply filter?
>> > >> >>>
>> > >> >>> Yes I have a video and a lower third, and I want to overlay
>> > the lower
>> > >> >> third. But my alpha channel from the lower third is not
>> > pre-devided
>> > >> >> with
>> > >> >> the alpha channel, so I need to do a channel division in
>> > ffmpeg.
>> > >> >> Something like:
>> > >> >>
>> > >> >> ffmpeg -i video.mp4 -i lowerthird.png -filter_complex
>> > >> >> [1:v]geq=r=r/a:g=g/a:b=b/a[gq];[0:v][gq]overlay ...
>> output.mp4
>> > >> >>
>> > >> >> I see that you wrote a filter for this, but can you please
>> > give me an
>> > >> > example of how it works? I don't get it to run.
>> > >>
>> > >> "I don't get it to run" means nothing to me.
>> > >>
>> > >> I'm not sure if I use the filter correct... But with this:
>> > >
>> > > ffmpeg -i video.mp4 -i image.png -filter_complex
>> > > "[0:v]format=rgba[a];[1:v]format=rgba[b];[a][b]premultiply"
>> > >
>> > > My result is, that everything what had alpha = 0, in my image,
>> > is
>> > now
>> > > black. Mybe I understand the use case wrong, but how you would
>> > use this
>> > > filter?
>> >
>> > Try harder to explain your use case?
>> >
>> > Sorry, my english is not so good, but I will try it. In the attachment
>> > you found 3 images. Universum.png is my original lower third, it comes
>> > out from blackmagic fusion. Universum-comp.jpg show the composite of a
>> > background video with the lower third, this is the correct result. The
>> > Universium-ffmpeg is the version from ffmpeg, as you see ffmpeg handles
>> > the alpha channel different so the lower third is more dark.
>> >
>> > I can simulate the same effect, from ffmpeg, in my compositing program,
>> > when I load the lower third image with the option "Post-Multiply by
>> > Alpha". I guess this is what ffmpeg does in Background, when it load
>> > images with alpha channel.
>> > To get rid of this effect now in my composition program I have to
>> > divide
>> > the color channel from the lower third with its own alpha:
>> > red/alpha;green/alpha;blue/alpha. Now I can overlay the lower third and
>> > the result is correct.
>> >
>> > This division now I would need in ffmpeg. I though I can do it with
>> > your
>> > premultiply filter, but maybe not.
>>
>> Perhaps you want overlay filter?
>>
>
> No the overlay filter don't handle the alpha channel correct, that is what
> I was trying to say.
>
> You can try it by your own - get this 3 images and run this command:
>
> ffmpeg -loop 1 -f image2 -i backgroud.png -i multiplied-alpha.png
> -filter_complex overlay -pix_fmt rgb24 -f sdl "multiplied alpha"
>
> ffmpeg -loop 1 -f image2 -i backgroud.png -i pre-divide-alpha.png
> -filter_complex overlay -pix_fmt rgb24 -f sdl "divide alpha"
>
> The second one overlay the image correct. The first one overlay the image
> different, because the alpha channel is not the same.
>
I stll do not know what you are trying to tell me.
Do you have equatition how should R/G/B be calculated with Alpha?
More information about the ffmpeg-user
mailing list