transitive-bullshit / ffmpeg-gl-transition

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

Try to keep alpha channel, and added input option「ex… #60

Open asa-charles-ho opened 3 years ago

asa-charles-ho commented 3 years ago

Try to keep alpha channel, and added input option「extra_texture」to set the third texture like displacement.glsl's displacementMap. It can be used by command like: ./ffmpeg -i frames_1/%06d.png -i frames_2/%06d.png -filter_complex "gltransition=duration=2:source=displacement.glsl:extra_texture=radial-tri-lateral.png" -y -start_number 000000 out/%06d.png

Thx your ffmpeg-gl-transition again, it's awesome.

TakeruDavis commented 3 years ago

Uniforms (arguments for transitions, like "displacementMap") have already been pull requested here: #21

Not really sure if it wasn't finished or if there's any problem, I'd need repository owner's insight on this, but I believe adding extra_texture with this pull request might just complicate things, going with more general approach the other pull request suggest would benefit more transitions, especially if there's more than one uniform.

The final decision should be on @transitive-bullshit , but my personal suggestion would be to only add alpha and revert extra texture.

TakeruDavis commented 3 years ago

Also, I would add alpha (and extra_texture, if it's not reverted) to readme.md

In section params, right after source, could be something like this:

  • alpha (optional int; defaults to 0) preserve alpha channel. If set, transitions will preserve alpha channels of inputs.

or something like that. Also not sure about using int, maybe it could just be a bool? C isn't my programming language, so I really don't know how difficult it would be to parse a bool param in this case

asa-charles-ho commented 3 years ago

Also, I would add alpha (and extra_texture, if it's not reverted) to readme.md

In section params, right after source, could be something like this:

  • alpha (optional int; defaults to 0) preserve alpha channel. If set, transitions will preserve alpha channels of inputs.

or something like that. Also not sure about using int, maybe it could just be a bool? C isn't my programming language, so I really don't know how difficult it would be to parse a bool param in this case

displacementMap.glsl and luma.glsl would use the Sample2D uniform that it is other image file, not just a simple parameter. About alpha's type, I just try to test for my work. If the bool type will work too, it would be the better choice. C isn't my programming language too, I try to suit my own needs with this.

TakeruDavis commented 3 years ago

Also, I would add alpha (and extra_texture, if it's not reverted) to readme.md In section params, right after source, could be something like this:

  • alpha (optional int; defaults to 0) preserve alpha channel. If set, transitions will preserve alpha channels of inputs.

or something like that. Also not sure about using int, maybe it could just be a bool? C isn't my programming language, so I really don't know how difficult it would be to parse a bool param in this case

displacementMap.glsl and luma.glsl would use the Sample2D uniform that it is other image file, not just a simple parameter. About alpha's type, I just try to test for my work. If the bool type will work too, it would be the better choice. C isn't my programming language too, I try to suit my own needs with this.

True, there would need to be a way to figure out whether your are passing a filename for image file and not just a string. But that might be solvable by using the right syntax. The other pull request uses uniforms='color=vec3(0.0,0.5,0.0)' to pass a 3d vector, perhaps something like uniforms='displacementMap=sample2d(/path/to/file.png)' could then be used to pass an image, along with name of the uniform

k713927 commented 3 years ago

when i use find yellow warm:"No accelerated colorspace conversion found from yuv420p to argb"

  Stream #1:0 (h264) -> split (graph 0)
  concat (graph 0) -> Stream #0:0 (libx264)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7f9ea2320000] No accelerated colorspace conversion found from yuv420p to argb.
[swscaler @ 0x7f9ef9b50000] No accelerated colorspace conversion found from yuv420p to argb.
[libx264 @ 0x7f9f1ed0f880] using SAR=1/1
[libx264 @ 0x7f9f1ed0f880] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f9f1ed0f880] profile High, level 4.0, 4:2:0, 8-bit
asa-charles-ho commented 3 years ago

when i use find yellow warm:"No accelerated colorspace conversion found from yuv420p to argb"

  Stream #1:0 (h264) -> split (graph 0)
  concat (graph 0) -> Stream #0:0 (libx264)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7f9ea2320000] No accelerated colorspace conversion found from yuv420p to argb.
[swscaler @ 0x7f9ef9b50000] No accelerated colorspace conversion found from yuv420p to argb.
[libx264 @ 0x7f9f1ed0f880] using SAR=1/1
[libx264 @ 0x7f9f1ed0f880] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f9f1ed0f880] profile High, level 4.0, 4:2:0, 8-bit

when i use find yellow warm:"No accelerated colorspace conversion found from yuv420p to argb"

  Stream #1:0 (h264) -> split (graph 0)
  concat (graph 0) -> Stream #0:0 (libx264)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7f9ea2320000] No accelerated colorspace conversion found from yuv420p to argb.
[swscaler @ 0x7f9ef9b50000] No accelerated colorspace conversion found from yuv420p to argb.
[libx264 @ 0x7f9f1ed0f880] using SAR=1/1
[libx264 @ 0x7f9f1ed0f880] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f9f1ed0f880] profile High, level 4.0, 4:2:0, 8-bit

我的改动就是支持透明通道的一种尝试,最近有更新(无需再传 alpha 参数),你可以看看。 警告 No accelerated colorspace conversion found from yuv420p to argb 会出现的原因在于你的输入文件是一个由 libx264 编码的视频,它在输入之前(色彩空间 yuv420p 不带 a)就已经失去了透明通道的数据。 建议输入文件为 frames_1/%06d.png 图片序列,或者你可以使用 libvpx-vp9 处理视频为 webm 来保留透明通道再试试。

asa-charles-ho commented 3 years ago

Also, I would add alpha (and extra_texture, if it's not reverted) to readme.md In section params, right after source, could be something like this:

  • alpha (optional int; defaults to 0) preserve alpha channel. If set, transitions will preserve alpha channels of inputs.

or something like that. Also not sure about using int, maybe it could just be a bool? C isn't my programming language, so I really don't know how difficult it would be to parse a bool param in this case

displacementMap.glsl and luma.glsl would use the Sample2D uniform that it is other image file, not just a simple parameter. About alpha's type, I just try to test for my work. If the bool type will work too, it would be the better choice. C isn't my programming language too, I try to suit my own needs with this.

True, there would need to be a way to figure out whether your are passing a filename for image file and not just a string. But that might be solvable by using the right syntax. The other pull request uses uniforms='color=vec3(0.0,0.5,0.0)' to pass a 3d vector, perhaps something like uniforms='displacementMap=sample2d(/path/to/file.png)' could then be used to pass an image, along with name of the uniform

Haven't got your point yet. I add param like extra_texture to set the addition third-party image file path just like param source. I don't need to set the uniforms value because I can change the glsl file directly, and it's fast and simple.

TakeruDavis commented 3 years ago

And if someone made their custom filter and wanted to use two images, not just one? Not that I have one at the moment, but it is possible to need one, it's possible to write one and it shouldn't be an issue to implement them the way I suggest to allow this, instead of resorting to implementation, which limits the number image files to just 1