MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
mxwrite-opencv-shader.py File Reference

Compute-process OpenCV video in MXVK and encode it with MXWrite. More...

Go to the source code of this file.

Classes

class  mxwrite-opencv-shader.CaptureWindow

Namespaces

namespace  mxwrite-opencv-shader

Functions

 mxwrite-opencv-shader.configure_encoder (args)
 mxwrite-opencv-shader.fourcc_to_string (value)
 mxwrite-opencv-shader.get_file_timestamp (capture, source_fps, frame_index)
 mxwrite-opencv-shader.main ()
 mxwrite-opencv-shader.open_camera_capture (index, width, height, fps)
 mxwrite-opencv-shader.open_file_capture (filename)
 mxwrite-opencv-shader.parse_arguments ()
 mxwrite-opencv-shader.validate_arguments (args)

Variables

str mxwrite-opencv-shader.DATA_DIR = EXAMPLE_DIR / "data"
 mxwrite-opencv-shader.EXAMPLE_DIR = Path(__file__).resolve().parent

Detailed Description

Compute-process OpenCV video in MXVK and encode it with MXWrite.

Feeds captured frames through an MXVK compute post-processing chain, reads back the processed RGBA output, and encodes file input at constant rate while retaining monotonic camera timestamps. The asynchronous readback callbacks retain the presentation timestamp that belongs to each processed frame before passing it to MXWrite.

Running the example

python3 python-examples/opencv_mxwrite_shader/mxwrite-opencv-shader.py \
--input input.mp4 --output processed.mp4 --shader data/compute.comp.spv

Requirements

Requires a CV-enabled mxvk_ext module built from this revision because it uses on_frame_readback() and flush_frame_readbacks(), plus mxwrite_ext, OpenCV, NumPy, and a compatible compute SPIR-V shader.

Processing flow

CaptureWindow uploads each source frame, queues the source sprite, records the compute effect, receives the processed frame through Vulkan readback, and sends that readback to MXWrite. Dragging with the left mouse button supplies the shader mouse state; Escape or Ctrl-C stops capture.

Definition in file mxwrite-opencv-shader.py.