Crate waycap_rs

Source
Expand description

§waycap-rs

waycap-rs is a high-level Wayland screen capture library with hardware-accelerated encoding. It provides an easy-to-use API for capturing screen content on Wayland-based Linux systems, using PipeWire for screen capture and hardware accelerated encoding for both video and audio.

§Features

  • Hardware-accelerated encoding (VAAPI and NVENC)
  • No Copy approach to encoding video frames utilizing DMA Buffers
  • Audio capture support
  • Multiple quality presets
  • Cursor visibility control
  • Fine-grained control over capture (start, pause, resume)

§Platform Support

This library currently supports Linux with Wayland display server and requires the XDG Desktop Portal and PipeWire for screen capture.

§Example

use waycap_rs::pipeline::builder::CaptureBuilder;
use waycap_rs::types::config::{AudioEncoder, QualityPreset, VideoEncoder};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a capture instance
    let mut capture = CaptureBuilder::new()
        .with_audio()
        .with_quality_preset(QualityPreset::Medium)
        .with_cursor_shown()
        .with_video_encoder(VideoEncoder::H264Vaapi)
        .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 as needed...
     
    // Stop capturing when done
    capture.close()?;
     
    Ok(())
}

Modules§

capture 🔒
encoders 🔒
pipeline
types
utils 🔒
waycap_egl 🔒

Structs§

Capture
Main capture instance for recording screen content and audio.
CaptureControls
Controls for the capture, allows you to pause/resume processing
DmaBufEncoder
“Encoder” which provides the raw DMA-Buf pointers directly.
NvencEncoder
Encoder which provides frames encoded using Nvenc
ReadyState
State of audio/video readiness, used internally
Resolution
Target Screen Resolution
RgbaImageEncoder
“Encoder” which outputs image::RgbaImage
VaapiEncoder
Encoder which encodes frames using Vaapi

Enums§

DynamicEncoder

Constants§

TIME_UNIT_NS

Traits§

VideoEncoder
Base trait for video encoders. defines the output type of an encoder.

Functions§

audio_encoding_loop 🔒