ffmpeg-gl-transition icon indicating copy to clipboard operation
ffmpeg-gl-transition copied to clipboard

Problems with alpha channel

Open TakeruDavis opened this issue 6 years ago • 9 comments

I am not sure if alpha channel is not supported or if I am just doing something wrong.

If they are not supported, would it be possible to add support for it into the extension?

It's understandable to omit alpha channel for most use cases, but I would like to be able to use transitions on overlays with alpha channel.

Here's a short example of such command:

ffmpeg -i ./video/logo.png -i ./video/logo2.png -i ./video/image.jpg -filter_complex "\ [0:v]scale=w=320:h=240:force_original_aspect_ratio=1,pad=320:240:(ow-iw)/2:(oh-ih)/2:[email protected],loop=125:1:0,split[logo1_split1][logo1_split2]; \ [1:v]scale=w=320:h=240:force_original_aspect_ratio=1,pad=320:240:(ow-iw)/2:(oh-ih)/2:[email protected],loop=125:1:0,split[logo2_split1][logo2_split2]; \ [2:v]scale=w=640:h=480,setsar=sar=4/3,loop=250:1:0[image]; \ [logo1_split1]trim=1.25,setpts=PTS-STARTPTS[logo1_split1_main]; \ [logo1_split2]trim=0:1.25[logo1_split2_out]; \ [logo2_split1]trim=1.25,setpts=PTS-STARTPTS[logo2_split1_main]; \ [logo2_split2]trim=0:1.25[logo2_split2_in]; \ [logo1_split2_out][logo2_split2_in]gltransition=duration=1.25:source=/filters/crosswarp.glsl[logos_tr]; \ [logo1_split1_main][logos_tr][logo2_split1_main]concat=n=3[logos_concat]; \ [image][logos_concat]overlay " -pix_fmt yuv420p -q:v 2 -y -f mp4 logos.mp4

Using scale and pad to ensure both overlays are the same size, then repeating the process of the example for transition and finally overlaying it over the media file. However, purple from pad was showing, despite the alpha channel being set.

To check if problem is not in something else, like with the padding, I tried simplified transitionless version and it worked, the purple area was now transparent

ffmpeg -i ./video/logo.png -i ./video/logo2.png -i ./video/image.jpg -filter_complex "\ [0:v]scale=w=320:h=240:force_original_aspect_ratio=1,pad=320:240:(ow-iw)/2:(oh-ih)/2:[email protected],loop=125:1:0[logo1]; \ [1:v]scale=w=320:h=240:force_original_aspect_ratio=1,pad=320:240:(ow-iw)/2:(oh-ih)/2:[email protected],loop=125:1:0[logo2]; \ [2:v]scale=w=640:h=480,setsar=sar=4/3,loop=250:1:0[image]; \ [logo1][logo2]concat=n=2[logos_concat]; \ [image][logos_concat]overlay " -pix_fmt yuv420p -q:v 2 -y -f mp4 logos2.mp4

TakeruDavis avatar Feb 22 '19 19:02 TakeruDavis

Interesting. I don't think transparent image inputs have been tested with the current version of this extension. I really like this use case, though.

I need some time to double check, but the underlying transition setup code may not take the alpha channel into account because video inputs don't generally support transparency.

I think this should be a simple fix.

Thanks!

transitive-bullshit avatar Feb 23 '19 21:02 transitive-bullshit

Sorry for the late response and thanks, it would be very helpful. I hope it's not too much trouble adding support for this.

TakeruDavis avatar Mar 18 '19 08:03 TakeruDavis

hi, this fix is completed ???

yukesh0505 avatar Jun 18 '19 14:06 yukesh0505

Interesting. I don't think transparent image inputs have been tested with the current version of this extension. I really like this use case, though.

I need some time to double check, but the underlying transition setup code may not take the alpha channel into account because video inputs don't generally support transparency.

I think this should be a simple fix.

Thanks!

Hi, can I do this simple fix myself? Just try to change GL_RGB to GL_RGBA in the vf_gltransition.c file, but it don't work.

Can you please give me some advise? I need the transparency too, though it is not universal.

asa-charles-ho avatar May 07 '21 08:05 asa-charles-ho

Interesting. I don't think transparent image inputs have been tested with the current version of this extension. I really like this use case, though. I need some time to double check, but the underlying transition setup code may not take the alpha channel into account because video inputs don't generally support transparency. I think this should be a simple fix. Thanks!

Hi, can I do this simple fix myself? Just try to change GL_RGB to GL_RGBA in the vf_gltransition.c file, but it don't work.

Can you please give me some advise? I need the transparency too, though it is not universal.

Hi, I thing I fixed to support the alpha channel by below steps ( edit file vf_gltransition.c ):

  1. 'GL_RGB' is replaced by 'GL_RGBA'
  2. Modify second parameter of glPixelStorei() from **/3 to **/4, like fromFrame->linesize[0] / 4
  3. Copy function query_formats from ffmpeg-4.2.4/libavfilter/vf_rotate.c to replace the old query_formats
  4. Remake and reinstall

It can work for now on :) Thank god with the gl-transition, and thanks for your ffmpeg-filter, because it really saved my life.

asa-charles-ho avatar May 10 '21 06:05 asa-charles-ho

Interesting. I don't think transparent image inputs have been tested with the current version of this extension. I really like this use case, though. I need some time to double check, but the underlying transition setup code may not take the alpha channel into account because video inputs don't generally support transparency. I think this should be a simple fix. Thanks!

Hi, can I do this simple fix myself? Just try to change GL_RGB to GL_RGBA in the vf_gltransition.c file, but it don't work. Can you please give me some advise? I need the transparency too, though it is not universal.

Hi, I thing I fixed to support the alpha channel by below steps ( edit file vf_gltransition.c ):

  1. 'GL_RGB' is replaced by 'GL_RGBA'
  2. Modify second parameter of glPixelStorei() from **/3 to **/4, like fromFrame->linesize[0] / 4
  3. Copy function query_formats from ffmpeg-4.2.4/libavfilter/vf_rotate.c to replace the old query_formats
  4. Remake and reinstall

It can work for now on :) Thank god with the gl-transition, and thanks for your ffmpeg-filter, because it really saved my life.

I try to open a pull request, you can take a look and it's my pleasure to do this.

asa-charles-ho avatar May 18 '21 06:05 asa-charles-ho

Interesting. I don't think transparent image inputs have been tested with the current version of this extension. I really like this use case, though. I need some time to double check, but the underlying transition setup code may not take the alpha channel into account because video inputs don't generally support transparency. I think this should be a simple fix. Thanks!

Hi, can I do this simple fix myself? Just try to change GL_RGB to GL_RGBA in the vf_gltransition.c file, but it don't work. Can you please give me some advise? I need the transparency too, though it is not universal.

Hi, I thing I fixed to support the alpha channel by below steps ( edit file vf_gltransition.c ):

  1. 'GL_RGB' is replaced by 'GL_RGBA'
  2. Modify second parameter of glPixelStorei() from **/3 to **/4, like fromFrame->linesize[0] / 4
  3. Copy function query_formats from ffmpeg-4.2.4/libavfilter/vf_rotate.c to replace the old query_formats
  4. Remake and reinstall

It can work for now on :) Thank god with the gl-transition, and thanks for your ffmpeg-filter, because it really saved my life.

I try to open a pull request, you can take a look and it's my pleasure to do this.

Hi asa-charles-ho, thank you so much for the great work! Just a simple question, it seems that if the input are the mov video files with alpha layer, the output mov video will lost 1/4 of the right side. How can I fix that?

anyway, thank you so much for adding the alpha support in this great project

yyc-meng avatar May 25 '21 07:05 yyc-meng

Interesting. I don't think transparent image inputs have been tested with the current version of this extension. I really like this use case, though. I need some time to double check, but the underlying transition setup code may not take the alpha channel into account because video inputs don't generally support transparency. I think this should be a simple fix. Thanks!

Hi, can I do this simple fix myself? Just try to change GL_RGB to GL_RGBA in the vf_gltransition.c file, but it don't work. Can you please give me some advise? I need the transparency too, though it is not universal.

Hi, I thing I fixed to support the alpha channel by below steps ( edit file vf_gltransition.c ):

  1. 'GL_RGB' is replaced by 'GL_RGBA'
  2. Modify second parameter of glPixelStorei() from **/3 to **/4, like fromFrame->linesize[0] / 4
  3. Copy function query_formats from ffmpeg-4.2.4/libavfilter/vf_rotate.c to replace the old query_formats
  4. Remake and reinstall

It can work for now on :) Thank god with the gl-transition, and thanks for your ffmpeg-filter, because it really saved my life.

I try to open a pull request, you can take a look and it's my pleasure to do this.

Hi asa-charles-ho, thank you so much for the great work! Just a simple question, it seems that if the input are the mov video files with alpha layer, the output mov video will lost 1/4 of the right side. How can I fix that?

anyway, thank you so much for adding the alpha support in this great project

Hi, I used mov video to test, but can not resee your situation of lost 1/4 of the right side. I think it may because of the different of the resolution of the input. And I also made some improvement in the pull request: #60 , hope that would work for you too.

asa-charles-ho avatar May 25 '21 08:05 asa-charles-ho

Interesting. I don't think transparent image inputs have been tested with the current version of this extension. I really like this use case, though. I need some time to double check, but the underlying transition setup code may not take the alpha channel into account because video inputs don't generally support transparency. I think this should be a simple fix. Thanks!

Hi, can I do this simple fix myself? Just try to change GL_RGB to GL_RGBA in the vf_gltransition.c file, but it don't work. Can you please give me some advise? I need the transparency too, though it is not universal.

Hi, I thing I fixed to support the alpha channel by below steps ( edit file vf_gltransition.c ):

  1. 'GL_RGB' is replaced by 'GL_RGBA'
  2. Modify second parameter of glPixelStorei() from **/3 to **/4, like fromFrame->linesize[0] / 4
  3. Copy function query_formats from ffmpeg-4.2.4/libavfilter/vf_rotate.c to replace the old query_formats
  4. Remake and reinstall

It can work for now on :) Thank god with the gl-transition, and thanks for your ffmpeg-filter, because it really saved my life.

I try to open a pull request, you can take a look and it's my pleasure to do this.

Hi asa-charles-ho, thank you so much for the great work! Just a simple question, it seems that if the input are the mov video files with alpha layer, the output mov video will lost 1/4 of the right side. How can I fix that? anyway, thank you so much for adding the alpha support in this great project

Hi, I used mov video to test, but can not resee your situation of lost 1/4 of the right side. I think it may because of the different of the resolution of the input. And I also made some improvement in the pull request: #60 , hope that would work for you too.

Yeah, I forget to set the parameter :alpha=1, thank you very much. Very impressive work!

yyc-meng avatar May 25 '21 14:05 yyc-meng