Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alpha channel to saved PNGs #51

Closed
csillag opened this issue May 30, 2020 · 4 comments
Closed

Add alpha channel to saved PNGs #51

csillag opened this issue May 30, 2020 · 4 comments

Comments

@csillag
Copy link

csillag commented May 30, 2020

I would like to create visualizations with animated backgrounds.

The end result is something like this:

https://www.youtube.com/watch?v=WIqP2BWB628

Since there is no support for this in the current version, this is how I work around this:

  • I generate the PNG files with MIDIVisualizer, with a solid background
  • I use ffmpeg to compile the video out of it. (Adding all the other effects, the sound, etc.)

There is currently no alpha channel in the generated PNG files, so I use ffmpeg's colorkey filter to remove the solid background from the visualization, so that I can overlay it on the animated background.

The problem with this approach is that some parts of the animation are semi-transparent (ie. the blur effect, the regions around the flashes, etc.) In these cases, removing the solid background using colorkey doesn't work well. So, for now, I had to disable the blur effect, and I also used a solid bg that is similar to the color of the animated bg in the region of the flashes, so that the flashes don't look weird.

With these workarounds, the process kind of works, but it would be must easier if the alpha channel value could be saved into the generated PNG files.

Then I could simply use them as an overlay, without any further tricks.

Now I am not sure whether the OpenGL renderer is able to export this information. It definitely has it, because when drawing the flashes and the blur effect over an existing bg image, it applies alpha correctly... but maybe the end result is flattened? If that's the case, then there is no way to save the alpha channel into the generated PNG files... we would have to check and see.

What do you think about this?

@csillag
Copy link
Author

csillag commented May 30, 2020

For an alternate approach to achieve the same end result, please see #52.

@kosua20
Copy link
Owner

kosua20 commented Jul 20, 2020

Hello again! Thank you for this detailed feedback (and the associated #52)! Implementation-wise, exporting transparent PNGs was the simplest of both options, as the information was already almost entirely available to the renderer.
I've added this option (in the GUI and as a command-line flag) in the latest v5.1 release, let me know if you find it useful or if you have additional suggestions!

@kosua20 kosua20 closed this as completed Jul 25, 2020
@csillag
Copy link
Author

csillag commented Mar 5, 2021

Hi @kosua20,

Yes, I have tested this, and it mostly works: I can now get transparency working for PNG export, but I can't get it to work for MP4 export.

My goal is to use the generated video as an overlay in ffmpeg, and for that, I need transparency in the video output. Would it be possible to achieve that somehow?

I could probably take the series of generated PNG files and use it somehow, but this route is a lot slower than the direct video export, and it's also more complicated from the user's POV...

Thanks.

@csillag
Copy link
Author

csillag commented Mar 5, 2021

I have created a separate issue for this: #94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants