transitive-bullshit / ffmpeg-gl-transition

FFmpeg filter for applying GLSL transitions between video streams.
647 stars 125 forks source link

Problems with alpha channel #34

Open TakeruDavis opened 5 years ago

TakeruDavis commented 5 years ago

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:color=purple@0.0,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:color=purple@0.0,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:color=purple@0.0,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:color=purple@0.0,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

transitive-bullshit commented 5 years ago

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!

TakeruDavis commented 5 years ago

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

yukesh0505 commented 5 years ago

hi, this fix is completed ???

asa-charles-ho commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.

yyc-meng commented 3 years ago

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

asa-charles-ho commented 3 years ago

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.

yyc-meng commented 3 years ago

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!