Overview
ACMX2 is a powerful C++ application for applying real-time OpenGL shader effects to video streams from cameras, video files, or static images. Built on the MX2 Engine (libmx2), it provides both a command-line interface and a Qt6-based GUI for managing shader libraries, recording processed output, and real-time audio reactivity.
The application supports live webcam effects, video file processing with shader effects, 3D model rendering
with shaders, and audio-reactive visual effects (when compiled with AUDIO_ENABLED).
Key Features
🎥 Multiple Input Sources
Support for webcams, video files, and static images with configurable resolution and FPS
🎨 GLSL Shader Processing
Load single shaders or entire shader libraries with real-time switching
🎬 Video Recording
Export processed video using FFmpeg with configurable bitrate (CRF) and audio passthrough
🔊 Audio Reactivity
Real-time audio input processing with RtAudio for music-synchronized effects
🎮 3D Mode
Render shaders on 3D models with camera controls and auto-rotation
🖥️ Qt6 GUI
Intuitive interface with shader editor, library management, and session settings
Architecture
Core Components
- acmx.cpp - Main application with OpenGL rendering loop and shader management
- interface/ - Qt6 GUI application for user-friendly shader management
- audio.cpp - RtAudio integration for audio reactivity (optional)
- MXWrite/ - FFmpeg wrapper library for video encoding/decoding
- shader_generator/ - AI-powered shader generation using Ollama
Shader System
Shaders are GLSL fragment shaders that receive the following uniforms:
sampler2D samp- Input texture (camera/video frame)float time_f/float iTime- Elapsed timevec2 iResolution- Output resolutionvec4 iMouse- Mouse positionint iFrame- Frame counterfloat amp/float uamp- Audio amplitude (when enabled)vec4 iDate- Current date/timefloat iFrameRate- Current FPS
Shader libraries are organized in folders with an index.txt file listing shader filenames:
color_swirl_c.glsl
tremor4.glsl
ripple_a.glsl
Command-Line Arguments
| Short Form | Long Form | Description |
|---|---|---|
-v |
--help |
Display help message and usage information |
-p <path> |
--path <path> |
Assets path (default: current directory) |
-r <WxH> |
--resolution <WxH> |
Output resolution (e.g., 1920x1080) |
-c <WxH> |
--camera-res <WxH> |
Camera capture resolution |
-d <index> |
--device <index> |
Camera device index (default: 0) |
-i <file> |
--input <file> |
Input video file path |
-g <file> |
--graphic <file> |
Input static image file |
-s <path> |
--shaders <path> |
Shader library folder (with index.txt) |
-f <file> |
--fragment <file> |
Single fragment shader file |
-h <index> |
--shader <index> |
Starting shader index in library |
-o <file> |
--output <file> |
Output video file path |
-b <crf> |
--bitrate <crf> |
Video encoding CRF value (default: 23) |
-u <fps> |
--fps <fps> |
Frames per second (default: 24) |
-e <path> |
--prefix <path> |
Screenshot save prefix/directory |
-a |
--repeat |
Loop video playback |
-n |
--fullscreen |
Start in fullscreen mode |
--texture-cache |
Enable texture caching (video mode only) | |
--cache-delay <n> |
Cache delay in frames (default: 1) | |
--copy-audio |
Copy audio track from input to output | |
--enable-3d |
Enable 3D mode with model rendering | |
--model <file> |
3D model file (.mxmod.z format) |
Audio Arguments AUDIO_ENABLED Required
| Short Form | Long Form | Description |
|---|---|---|
-w |
--enable-audio |
Enable audio reactivity |
-l <n> |
--channels <n> |
Number of audio channels (1-32, default: 2) |
-q <val> |
--sense <val> |
Audio sensitivity (default: 25.0) |
-y |
--pass-through |
Enable audio pass-through to output device |
--audio-input <id> |
Audio input device ID (or "default") | |
--audio-output <id> |
Audio output device ID (or "default") | |
--list-devices |
List available audio devices and exit |
Keyboard Controls
Shader Management
| Key | Action |
|---|---|
| ↑ | Previous shader in library |
| ↓ | Next shader in library |
| Space | Toggle shader processing on/off (bypass mode) |
Playback Controls
| Key | Action | Mode |
|---|---|---|
| L | Freeze video (continue shader processing) | Video/Image |
| P | Pause video and shader processing | Video/Image |
Time & Animation
| Key | Action |
|---|---|
| T | Toggle time progression (freeze shader animations) |
| I | Step time forward (when time disabled) |
| O | Step time backward (when time disabled) |
| Q | Toggle audio-reactive time AUDIO_ENABLED |
Camera & View (3D Mode)
| Key | Action |
|---|---|
| W | Look up (pitch up) |
| S | Look down (pitch down) |
| A | Rotate left (yaw left) |
| D | Rotate right (yaw right) |
| V | Toggle auto-rotation |
Capture & Display
| Key | Action |
|---|---|
| Z | Take snapshot (saves PNG to prefix directory) |
| F | Toggle fullscreen mode |
| ESC | Exit application / Exit fullscreen |
Usage Examples
1. Basic Camera with Default Settings
./acmx2
Opens default camera device with 1280x720 resolution.
2. Camera with Custom Resolution & Recording
./acmx2 -c 1920x1080 -o output.mp4 -b 18
Captures at 1080p, records to output.mp4 with CRF 18 (higher quality).
3. Video File with Single Shader
./acmx2 -i video.mp4 -f shaders/effect.glsl -r 1280x720 -o processed.mp4
Processes video.mp4 with effect.glsl shader, outputs at 720p.
4. Shader Library with Looping
./acmx2 -i video.mp4 -s ./filters -h 2 -a
Uses shader library in ./filters, starts at shader index 2, loops video.
5. Audio-Reactive Webcam
./acmx2 -w -l 2 -q 15.0 -y
Enables audio reactivity with 2 channels, sensitivity 15.0, and audio pass-through.
6. 3D Mode with Model
./acmx2 --enable-3d --model cube.mxmod.z -s ./filters
Renders shaders on 3D cube model with camera controls.
7. Fullscreen with Texture Cache
./acmx2 -i video.mp4 -n --texture-cache --cache-delay 2
Fullscreen mode with texture caching (2-frame delay).
8. Copy Audio Track
./acmx2 -i input.mp4 -s ./filters -o output.mp4 --copy-audio
Processes video and copies original audio track to output.
GUI Application (Qt6 Interface)
The Qt6 interface provides a user-friendly way to manage shaders and sessions:
Main Features
- Shader Library Manager - Create, edit, and organize shader collections
- Code Editor - Built-in GLSL editor with syntax highlighting
- Session Properties - Configure camera, resolution, FPS, and output settings
- Audio Settings - Control audio reactivity, channels, sensitivity, and devices
- Live Preview - Run shaders directly from the interface
Building the GUI
cd interface
qmake6
make -j$(nproc)
./interface
GUI Settings
Settings are stored using QSettings under "LostSideDead" organization:
exePath- Path to acmx2 executableshaders- Current shader library folderprefix_path- Screenshot/output directory
Building from Source
Dependencies
- C++20 compatible compiler (GCC 10+, Clang 12+, MSVC 2019+)
- CMake 3.10+
- SDL2
- OpenGL (3.3+) & GLAD
- OpenCV 4.x
- FFmpeg development libraries (libavcodec, libavformat, libavutil, libswscale)
- Qt6 (for GUI application)
- libmx2 (MX2 Engine) - https://github.com/lostjared/libmx2
- RtAudio (optional, for audio reactivity)
Build Steps
# Clone libmx2
git clone https://github.com/lostjared/libmx2.git
cd libmx2/libmx
mkdir build && cd build
cmake .. -DOPENGL=ON
make -j$(nproc) && sudo make install
# Build MXWrite library
cd ../../../ACMX2/MXWrite
mkdir build && cd build
cmake ..
make -j$(nproc) && sudo make install
# Build ACMX2
cd ../..
mkdir build && cd build
cmake .. -DAUDIO=ON
make -j$(nproc) && sudo make install
# Build GUI (optional)
cd ../interface
qmake6
make -j$(nproc)
Enabling Audio Support
To enable audio reactivity, ensure RtAudio is installed and add -DAUDIO_ENABLED=ON to CMake:
cmake .. -DAUDIO_ENABLED=ON
$(sysctl -n hw.ncpu) instead of $(nproc).
A convenience script is provided at macos/build-macos.sh.
Shader Development
Basic Shader Template
#version 330 core
in vec2 tc;
out vec4 color;
uniform sampler2D samp;
uniform float time_f;
uniform vec2 iResolution;
uniform float amp; // Audio amplitude
void main(void) {
vec2 uv = tc;
// Your shader code here
vec4 texColor = texture(samp, uv);
color = texColor;
}
Available Uniforms
| Uniform | Type | Description |
|---|---|---|
samp |
sampler2D | Input texture (camera/video frame) |
time_f / iTime |
float | Elapsed time in seconds |
iResolution |
vec2 | Output resolution (width, height) |
iMouse |
vec4 | Mouse position (x, y, click x, click y) |
iFrame |
int | Current frame number |
iTimeDelta |
float | Time between frames |
iDate |
vec4 | Current date (year, month, day, seconds) |
iFrameRate |
float | Current FPS |
amp |
float | Audio amplitude (0.0-1.0) AUDIO |
uamp |
float | Untouched audio amplitude AUDIO |
iChannelTime[4] |
float[4] | Per-channel time values |
iChannelResolution[4] |
vec3[4] | Per-channel resolutions |
Creating Shader Libraries
Organize shaders in a folder with an index.txt file:
my_shaders/
├── index.txt
├── wave_effect.glsl
├── color_shift.glsl
└── distortion.glsl
index.txt:
wave_effect.glsl
color_shift.glsl
distortion.glsl
AI Shader Generator
The shader_generator tool uses Ollama to generate GLSL shaders from natural language prompts:
Building
cd shader_generator
mkdir build && cd build
cmake ..
make
Usage
./shader_generator [host] [model] [output_file]
# Example:
./shader_generator localhost codellama:7b my_shader.glsl
You'll be prompted to describe the desired shader effect. The generator will create a complete GLSL shader file.
Audio Transfer Utility
The audio_transfer utility copies audio tracks between video files:
./audio_transfer source_video.mp4 destination_video.mp4
This is useful when you've processed video without audio and want to add the original audio track back.
Technical Details
Video Encoding (MXWrite)
ACMX2 uses the custom MXWrite library (wrapper around FFmpeg) for video encoding:
- Codec: H.264 (libx264)
- Format: MP4 or MPEG-TS
- Quality: CRF-based (default: 23, lower = higher quality)
- Frame rate: Configurable (default: 24 FPS)
Texture Caching
When enabled with --texture-cache, ACMX2 maintains a frame buffer cache to improve performance
with certain shader effects. The --cache-delay parameter controls buffer depth (default: 1 frame).
Audio Processing
Audio reactivity (when enabled) uses RtAudio to capture real-time audio input and calculate amplitude values:
- Sample rate: 44100 Hz
- Buffer size: 512 frames
- Channels: Configurable (1-32)
- Sensitivity: Multiplier for amplitude (default: 25.0)
3D Rendering
3D mode uses the MX2 Model system to load and render .mxmod.z files with shaders applied as textures.
Camera controls use quaternion-based rotation for smooth movement.
Supported File Formats
Input Video
Any format supported by OpenCV VideoCapture (MP4, AVI, MOV, MKV, etc.)
Input Images
PNG, JPG, BMP (via OpenCV imread)
Output Video
MP4 (H.264), TS (MPEG Transport Stream)
Shaders
GLSL (.glsl) fragment shaders (GLSL version 330 core)
3D Models
.mxmod.z (MX2 compressed model format)
Troubleshooting
Common Issues
Check the console output for GLSL errors. Ensure your shader uses
#version 330 core
and includes required input/output variables (in vec2 tc, out vec4 color).
Verify the camera index with your system's device manager. Try different values for
-d (0, 1, 2...).
On Linux, check /dev/video* permissions.
Ensure ACMX2 was compiled with
-DAUDIO_ENABLED=ON. List available devices with
./acmx2 --list-devices. Check RtAudio permissions.
Verify FFmpeg libraries are correctly installed. Check write permissions for the output directory. Ensure the output path is valid and has sufficient disk space.
Try lowering resolution with
-r. Disable texture cache. Reduce FPS with -u.
Simplify shader complexity. Check GPU driver updates.
License
ACMX2 is released under the MIT License.
Copyright (c) 2024-2025 Jared Bruni (LostSideDead)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Credits & Libraries
- SDL2 - Window management and OpenGL context
- OpenGL - GPU-accelerated rendering
- OpenCV - Camera/video capture and image processing
- FFmpeg - Video encoding/decoding
- Qt6 - GUI framework
- RtAudio - Real-time audio I/O
- libmx2 - MX2 Engine (https://github.com/lostjared/libmx2)
- Argz - Command-line argument parsing
- libcurl - HTTP client for shader generator
Author
Developed by Jared Bruni (LostSideDead)
Website: https://lostsidedead.biz
This software is dedicated to all who have experienced mental illness.