Add optional Vulkan hardware acceleration for H.264 transcoding#19
Add optional Vulkan hardware acceleration for H.264 transcoding#19khamilowicz wants to merge 4 commits into
Conversation
| System.get_env("MEMBRANE_VK_VIDEO") == "1" or | ||
| match?( | ||
| {_, 0}, | ||
| System.cmd("pkg-config", ["--exists", "vulkan"], stderr_to_stdout: true) |
There was a problem hiding this comment.
It's kind of non-trivial to figure out how to determine if vulkan video extensions are available :D
There is no requirement to use pkg-config but also plain existence of vulkan pkg-config entry does not indicate that Vulkan Video Extensions are available (it's gets even worse - Vulkan Video Extensions might be present, but there might not be H264 encoding and decoding capabilities).
I think we should uncodintionally add an optional dependency to membrane_vk_video_plugin and rely on fact that user will install it only after checking that particular capabilities are delivered.
| module when is_atom(module) -> | ||
| assert_sink_stream_format(pid, :sink, received_format) | ||
| assert received_format.__struct__ == module | ||
| end |
There was a problem hiding this comment.
It would be good to assert on output file content as well
| Use this to guard code that sets `native_acceleration: :if_available`, for example | ||
| to print a diagnostic or pick a different pipeline branch. |
There was a problem hiding this comment.
I am not sure I understand this part :D
| state.output_stream_format, | ||
| state.transcoding_policy | ||
| state.transcoding_policy, | ||
| state.use_vulkan? |
There was a problem hiding this comment.
I would use some other name for that flag than use_vulkan? - sth like use_hardware_acceleration?
b46e513 to
3b5b3c1
Compare
fc53441 to
d7589cc
Compare
native_acceleration: :never | :if_availableoption toMembrane.Transcoderthat routes H.264 decode/encode throughMembrane.VKVideo.Decoder/Membrane.VKVideo.Encoderwhen Vulkan hardware is present.Membrane.Transcoder.vulkan_available?/0— a public helper for callers that need to check GPU availability before building a pipeline.membrane_vk_video_pluginas an optional dependency — software fallback is unchanged when the dep is absent ornative_acceleration: :never.Test plan
mix testmix test --include vulkanexamples/vp8_to_h264.exsproduces valid output with and withoutnative_acceleration: :if_availablevulkan_available?/0returnsfalseon a machine withoutmembrane_vk_video_plugininstalled🤖 Generated with Claude Code