Color Channel Expression

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Color Channel Expression

Jon bae
Hello,
is there a way to make simple channel expressions in ffmpeg.
I would need to make something like this:

input > red/alpha , green/alpha , blue/alpha > output

I try this with the geq filter, but without success.

Have you an idea, how I can do this?

Regards
Jonathan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Paul B Mahol
On 7/31/17, Jon bae <[hidden email]> wrote:
> Hello,
> is there a way to make simple channel expressions in ffmpeg.
> I would need to make something like this:
>
> input > red/alpha , green/alpha , blue/alpha > output
>
> I try this with the geq filter, but without success.

What exactly you tried?

Perhaps you want premultiply filter?

>
> Have you an idea, how I can do this?
>
> Regards
> Jonathan
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Jon bae
2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]>:

>
> 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
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Jon bae
2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]>:

>
>>
>> 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.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Paul B Mahol
On 7/31/17, Jon bae <[hidden email]> wrote:

> 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]>:
>>
>>>
>>> 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.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Jon bae
2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]>:

> On 7/31/17, Jon bae <[hidden email]> wrote:
> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]>:
> >>
> >>>
> >>> 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?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Paul B Mahol
On 7/31/17, Jon bae <[hidden email]> wrote:

> 2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]>:
>
>> On 7/31/17, Jon bae <[hidden email]> wrote:
>> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]>:
>> >>
>> >>>
>> >>> 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?

Like providing input and wanted output images and explaining in more detail how
alpha should be manipulated.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Jon bae
In reply to this post by Jon bae


2017-07-31 14:41 GMT+02:00 Paul B Mahol <[hidden email]
<mailto:[hidden email]>>:

    On 7/31/17, Jon bae <[hidden email] <mailto:[hidden email]>>
    wrote:
     > 2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]
    <mailto:[hidden email]>>:
     >
     >> On 7/31/17, Jon bae <[hidden email]
    <mailto:[hidden email]>> wrote:
     >> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]
    <mailto:[hidden email]>>:
     >> >>
     >> >>>
     >> >>> 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.



_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

Universum-comp.jpg (9K) Download Attachment
Universum-ffmpeg.jpg (8K) Download Attachment
Universum.png (96K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Paul B Mahol
On 7/31/17, Jonathan Baecker <[hidden email]> wrote:

>
>
> 2017-07-31 14:41 GMT+02:00 Paul B Mahol <[hidden email]
> <mailto:[hidden email]>>:
>
>     On 7/31/17, Jon bae <[hidden email] <mailto:[hidden email]>>
>     wrote:
>      > 2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]
>     <mailto:[hidden email]>>:
>      >
>      >> On 7/31/17, Jon bae <[hidden email]
>     <mailto:[hidden email]>> wrote:
>      >> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]
>     <mailto:[hidden email]>>:
>      >> >>
>      >> >>>
>      >> >>> 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?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Jon bae
2017-07-31 22:16 GMT+02:00 Paul B Mahol <[hidden email]>:

> On 7/31/17, Jonathan Baecker <[hidden email]> wrote:
> >
> >
> > 2017-07-31 14:41 GMT+02:00 Paul B Mahol <[hidden email]
> > <mailto:[hidden email]>>:
> >
> >     On 7/31/17, Jon bae <[hidden email] <mailto:[hidden email]>>
> >     wrote:
> >      > 2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]
> >     <mailto:[hidden email]>>:
> >      >
> >      >> On 7/31/17, Jon bae <[hidden email]
> >     <mailto:[hidden email]>> wrote:
> >      >> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]
> >     <mailto:[hidden email]>>:
> >      >> >>
> >      >> >>>
> >      >> >>> 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.

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

backgroud.png (1K) Download Attachment
multiplied-alpha.png (99K) Download Attachment
pre-divide-alpha.png (77K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Paul B Mahol
On 8/1/17, Jon bae <[hidden email]> wrote:

> 2017-07-31 22:16 GMT+02:00 Paul B Mahol <[hidden email]>:
>
>> On 7/31/17, Jonathan Baecker <[hidden email]> wrote:
>> >
>> >
>> > 2017-07-31 14:41 GMT+02:00 Paul B Mahol <[hidden email]
>> > <mailto:[hidden email]>>:
>> >
>> >     On 7/31/17, Jon bae <[hidden email]
>> > <mailto:[hidden email]>>
>> >     wrote:
>> >      > 2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]
>> >     <mailto:[hidden email]>>:
>> >      >
>> >      >> On 7/31/17, Jon bae <[hidden email]
>> >     <mailto:[hidden email]>> wrote:
>> >      >> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]
>> >     <mailto:[hidden email]>>:
>> >      >> >>
>> >      >> >>>
>> >      >> >>> 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?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Gyan
In reply to this post by Jon bae
> input > red/alpha , green/alpha , blue/alpha > output
> 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
>

Use

ffmpeg -i video.mp4 -i lowerthird.png -filter_complex
[1:v]geq=r='p(X,Y)/alpha(X,Y)':g='p(X,Y)/alpha(X,Y)':b='p(X,Y)/alpha(X,Y)':a='p(X,Y)'[gq];[0:v][gq]overlay
.. output.mp4
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Jon bae
In reply to this post by Paul B Mahol
2017-08-01 9:53 GMT+02:00 Paul B Mahol <[hidden email]>:

> On 8/1/17, Jon bae <[hidden email]> wrote:
> > 2017-07-31 22:16 GMT+02:00 Paul B Mahol <[hidden email]>:
> >
> >> On 7/31/17, Jonathan Baecker <[hidden email]> wrote:
> >> >
> >> >
> >> > 2017-07-31 14:41 GMT+02:00 Paul B Mahol <[hidden email]
> >> > <mailto:[hidden email]>>:
> >> >
> >> >     On 7/31/17, Jon bae <[hidden email]
> >> > <mailto:[hidden email]>>
> >> >     wrote:
> >> >      > 2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]
> >> >     <mailto:[hidden email]>>:
> >> >      >
> >> >      >> On 7/31/17, Jon bae <[hidden email]
> >> >     <mailto:[hidden email]>> wrote:
> >> >      >> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]
> >> >     <mailto:[hidden email]>>:
> >> >      >> >>
> >> >      >> >>>
> >> >      >> >>> 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?
>

I think to, that my hole description make it more complicate, then my
question to the begin. I was trying to tell you, that my image, what I want
to overlay, need to be process before, because its alpha channel is not in
a way ffmpeg needs it for the overlay filter.

You know that there is different way how a image have its color calculated
with its own alpha channel. The color can be multiplied with the alpha, or
can be straight. (
https://microsoft.github.io/Win2D/html/PremultipliedAlpha.htm )

My image now have a multiplied alpha. To get a correct overlay I have to:

*a.* unmultiply the alpha channel

ImageColor/ImageAlpha
or:

*b.* to overlay the image with a different math operation:


foregroundColor + ( backgroundColor * ( 1 - foregroundAlpha ) )


I have make now more tests and it look like that method *a.* still not
working 100%, even when it should. But method *b.* works.


So my new question is: can ffmpeg combine images with a different math. Or
is there a filter where I can write my own blend expressions (I know the
blend filter, but until now I had no success with this one.)
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Paul B Mahol
On 8/1/17, Jon bae <[hidden email]> wrote:

> 2017-08-01 9:53 GMT+02:00 Paul B Mahol <[hidden email]>:
>
>> On 8/1/17, Jon bae <[hidden email]> wrote:
>> > 2017-07-31 22:16 GMT+02:00 Paul B Mahol <[hidden email]>:
>> >
>> >> On 7/31/17, Jonathan Baecker <[hidden email]> wrote:
>> >> >
>> >> >
>> >> > 2017-07-31 14:41 GMT+02:00 Paul B Mahol <[hidden email]
>> >> > <mailto:[hidden email]>>:
>> >> >
>> >> >     On 7/31/17, Jon bae <[hidden email]
>> >> > <mailto:[hidden email]>>
>> >> >     wrote:
>> >> >      > 2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]
>> >> >     <mailto:[hidden email]>>:
>> >> >      >
>> >> >      >> On 7/31/17, Jon bae <[hidden email]
>> >> >     <mailto:[hidden email]>> wrote:
>> >> >      >> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <[hidden email]
>> >> >     <mailto:[hidden email]>>:
>> >> >      >> >>
>> >> >      >> >>>
>> >> >      >> >>> 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?
>>
>
> I think to, that my hole description make it more complicate, then my
> question to the begin. I was trying to tell you, that my image, what I want
> to overlay, need to be process before, because its alpha channel is not in
> a way ffmpeg needs it for the overlay filter.
>
> You know that there is different way how a image have its color calculated
> with its own alpha channel. The color can be multiplied with the alpha, or
> can be straight. (
> https://microsoft.github.io/Win2D/html/PremultipliedAlpha.htm )
>
> My image now have a multiplied alpha. To get a correct overlay I have to:
>
> *a.* unmultiply the alpha channel
>

I'm just writing this filter. But you could do this really slowly with
geq filter.


> ImageColor/ImageAlpha
> or:
>
> *b.* to overlay the image with a different math operation:
>
>
> foregroundColor + ( backgroundColor * ( 1 - foregroundAlpha ) )

I plan to add this mode to overlay filter.

>
>
> I have make now more tests and it look like that method *a.* still not
> working 100%, even when it should. But method *b.* works.
>
>
> So my new question is: can ffmpeg combine images with a different math. Or
> is there a filter where I can write my own blend expressions (I know the
> blend filter, but until now I had no success with this one.)

blend does not allow for using components from other planes, and
adding such feature
is not trivial.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Color Channel Expression

Jon bae
2017-08-01 11:13 GMT+02:00 Paul B Mahol <[hidden email]>:

> On 8/1/17, Jon bae <[hidden email]> wrote:
> > 2017-08-01 9:53 GMT+02:00 Paul B Mahol <[hidden email]>:
> >
> >> On 8/1/17, Jon bae <[hidden email]> wrote:
> >> > 2017-07-31 22:16 GMT+02:00 Paul B Mahol <[hidden email]>:
> >> >
> >> >> On 7/31/17, Jonathan Baecker <[hidden email]> wrote:
> >> >> >
> >> >> >
> >> >> > 2017-07-31 14:41 GMT+02:00 Paul B Mahol <[hidden email]
> >> >> > <mailto:[hidden email]>>:
> >> >> >
> >> >> >     On 7/31/17, Jon bae <[hidden email]
> >> >> > <mailto:[hidden email]>>
> >> >> >     wrote:
> >> >> >      > 2017-07-31 14:00 GMT+02:00 Paul B Mahol <[hidden email]
> >> >> >     <mailto:[hidden email]>>:
> >> >> >      >
> >> >> >      >> On 7/31/17, Jon bae <[hidden email]
> >> >> >     <mailto:[hidden email]>> wrote:
> >> >> >      >> > 2017-07-31 10:30 GMT+02:00 Paul B Mahol <
> [hidden email]
> >> >> >     <mailto:[hidden email]>>:
> >> >> >      >> >>
> >> >> >      >> >>>
> >> >> >      >> >>> 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?
> >>
> >
> > I think to, that my hole description make it more complicate, then my
> > question to the begin. I was trying to tell you, that my image, what I
> want
> > to overlay, need to be process before, because its alpha channel is not
> in
> > a way ffmpeg needs it for the overlay filter.
> >
> > You know that there is different way how a image have its color
> calculated
> > with its own alpha channel. The color can be multiplied with the alpha,
> or
> > can be straight. (
> > https://microsoft.github.io/Win2D/html/PremultipliedAlpha.htm )
> >
> > My image now have a multiplied alpha. To get a correct overlay I have to:
> >
> > *a.* unmultiply the alpha channel
> >
>
> I'm just writing this filter. But you could do this really slowly with
> geq filter.
>

Yes I see it before, from Gyan (thank you Gyan for this!), this example is
mathematical correct, but my result is far away from what I expected.


>
> > ImageColor/ImageAlpha
> > or:
> >
> > *b.* to overlay the image with a different math operation:
> >
> >
> > foregroundColor + ( backgroundColor * ( 1 - foregroundAlpha ) )
>
> I plan to add this mode to overlay filter.
>
> This would be very great!


> >
> >
> > I have make now more tests and it look like that method *a.* still not
> > working 100%, even when it should. But method *b.* works.
> >
> >
> > So my new question is: can ffmpeg combine images with a different math.
> Or
> > is there a filter where I can write my own blend expressions (I know the
> > blend filter, but until now I had no success with this one.)
>
> blend does not allow for using components from other planes, and
> adding such feature
> is not trivial.
>

Yeah I believe it is not easy. From user perspective it sound sometimes
trivial, because we know this from other software, but from developer
perspective it look totally different.

Then thank you, for your patience!
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Loading...