| Crates.io | windows-record |
| lib.rs | windows-record |
| version | 0.1.0 |
| created_at | 2025-03-13 09:17:17.774544+00 |
| updated_at | 2025-03-13 09:17:17.774544+00 |
| description | A library for recording screen and audio on Windows systems |
| homepage | |
| repository | https://github.com/judehek/windows-record |
| max_upload_size | |
| id | 1590665 |
| size | 191,721 |
Windows Record is an efficient Rust library designed for seamless window recording. Using the Windows Desktop Duplication API, it captures window content directly without the yellow recording border caused by the WGC API. The library prioritizes performance and ease-of-use.
use windows_record::{Recorder, Result};
fn main() -> Result<()> {
// Create recorder with builder pattern
let config = Recorder::builder()
.fps(30, 1)
.input_dimensions(1920, 1080)
.output_dimensions(1920, 1080)
.capture_audio(true)
.output_path("output.mp4")
.build();
// Initialize with target window
let recorder = Recorder::new(config)?
.with_process_name("Your Window Name");
// Start recording
recorder.start_recording()?;
// Record for desired duration
std::thread::sleep(std::time::Duration::from_secs(30));
// Stop recording and clean up resources
recorder.stop_recording()?;
Ok(())
}
The replay buffer feature allows you to continuously record in the background and save only the last N seconds when something interesting happens. This is useful for gameplay recording and similar scenarios where you want to capture events after they happen.
use windows_record::{Recorder, Result};
fn main() -> Result<()> {
// Create recorder with replay buffer enabled
let config = Recorder::builder()
.fps(30, 1)
.enable_replay_buffer(true) // Enable replay buffer
.replay_buffer_seconds(30) // Keep last 30 seconds
.output_path("regular_recording.mp4")
.build();
// Initialize with target window
let recorder = Recorder::new(config)?
.with_process_name("Your Window Name");
// Start recording with buffer
recorder.start_recording()?;
// ... Something interesting happens ...
// Save the replay buffer to a file
recorder.save_replay("replay_clip.mp4")?;
// Continue recording or stop
recorder.stop_recording()?;
Ok(())
}
See the examples/replay_buffer.rs file for a complete example of how to use the replay buffer functionality.
The recorder offers extensive configuration options through its builder pattern:
You can create a minimal configuration like this:
let config = Recorder::builder()
.output_path("output.mp4")
.build();
This will use all default settings and just specify the output file.
fps(num, den) - Set frame rate (default: 30/1)input_dimensions(width, height) - Set input resolution (default: 1920x1080)output_dimensions(width, height) - Set output resolution (default: 1920x1080)video_bitrate(bitrate) - Set video bitrate in bits per second (default: 5,000,000)video_encoder(encoder) - Set video encoder (default: H264, options: H264, HEVC)capture_audio(enabled) - Enable/disable system audio capture (default: true)capture_microphone(enabled) - Enable/disable microphone capture (default: false)microphone_volume(volume) - Set microphone volume (0.0-1.0, default: None)system_volume(volume) - Set system audio volume (0.0-1.0, default: None)audio_source(source) - Set audio source (default: ActiveWindow, options: Desktop, ActiveWindow)microphone_device(device_name) - Set specific microphone device (default: None)output_path(path) - Set recording output path (default: current directory)debug_mode(enabled) - Enable debug logging and diagnostics (default: false)enable_replay_buffer(enabled) - Enable replay buffer feature (default: false)replay_buffer_seconds(seconds) - Set replay buffer duration in seconds (default: 30)