| Crates.io | waycap-rs |
| lib.rs | waycap-rs |
| version | 2.1.2 |
| created_at | 2025-05-26 05:05:43.619947+00 |
| updated_at | 2025-11-16 03:53:38.699335+00 |
| description | High-level Wayland screen capture library with hardware-accelerated encoding |
| homepage | https://github.com/adonca2203/waycap-rs |
| repository | https://github.com/adonca2203/waycap-rs |
| max_upload_size | |
| id | 1688960 |
| size | 199,878 |
A high-level Wayland screen capture library with hardware-accelerated encoding for Linux environments.
Add this to your Cargo.toml:
[dependencies]
waycap-rs = "1.0.0"
crossbeam = "0.8.4"
use waycap_rs::{CaptureBuilder, QualityPreset, VideoEncoder, AudioEncoder};
use std::{thread, time::Duration};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a capture session
let mut capture = CaptureBuilder::new()
.with_audio()
.with_quality_preset(QualityPreset::Medium)
.with_cursor_shown()
.with_video_encoder(VideoEncoder::Vaapi)
.with_audio_encoder(AudioEncoder::Opus)
.build()?;
// Start capturing
capture.start()?;
// Get receivers for encoded frames
let video_receiver = capture.get_video_receiver();
let audio_receiver = capture.get_audio_receiver()?;
// Process frames in separate threads
let video_thread = thread::spawn(move || {
while let Ok(frame) = video_receiver.try_recv() {
// Process video frame (e.g., save to file, stream, etc.)
println!("Video frame: keyframe={}, size={}", frame.is_keyframe, frame.data.len());
}
});
let audio_thread = thread::spawn(move || {
while let Ok(frame) = audio_receiver.try_recv() {
// Process audio frame
println!("Audio frame: size={}", frame.data.len());
}
});
// Capture for 10 seconds
thread::sleep(Duration::from_secs(10));
// Stop capturing
capture.close()?;
// Wait for threads to finish
video_thread.join().unwrap();
audio_thread.join().unwrap();
Ok(())
}
This library was created primarily to support the development of WayCap -- a low-latency screen recorder targeting Wayland Linux DEs. waycap-rs originally lived within this application but was broken out to split library and application logic, you can read more about that project over at its github page
https://github.com/Adonca2203/WayCap
Contributions are always welcome and encouraged, look around for any open issues you want to tackle and feel free to open a PR/Issue yourself.
If you would like to contribute, the following system dependencies are needed to compile the application:
sudo pacman -S \
pipewire \
ffmpeg \
wayland \
wayland-protocols \
pkgconf
After installing the required dependencies you can clone and compile with
git clone https://github.com/Adonca2203/waycap-rs.git
cd waycap-rs
cargo build
To run any of the examples, you can do so with
cargo run --example example_name
Please run the examples before making a PR, to test and debug your changes.
main branch./examples if applicable.