#capture #result #cuda #frame #devices #system #create #nvfbc

nvfbc

Safe bindings for NVFBC, an NVIDIA API for capturing the front buffer from NVIDIA GPUs

4 releases

0.1.3 Nov 18, 2023
0.1.2 Jun 23, 2022
0.1.1 Jun 23, 2022
0.1.0 Jun 23, 2022

#77 in Video

50 downloads per month

BSD-2-Clause

155KB
4K SLoC

nvfbc

This library contains a safe FFI for NVFBC from NVIDIA.

Supported GPUs

As this uses a proprietary NVIDIA API, the supported devices are limited to NVIDIA GPUs. Additionally, the NVFBC API is only officially supported on GRID, Tesla, or Quadro X2000+ GPUs. Unofficial support is possible by applying a patch to the NVFBC library.

Supported capture types

Currently only CUDA and system (RAM) capture types are supported.

Example: Saving an image.

use nvfbc::{SystemCapturer, BufferFormat};
use nvfbc::system::CaptureMethod;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut capturer = SystemCapturer::new()?;

    let status = capturer.status()?;
    println!("{:#?}", capturer.status()?);
    if !status.can_create_now {
        panic!("Can't create a system capture session.");
    }

    capturer.start(BufferFormat::Rgb, 30)?;

    let frame_info = capturer.next_frame(CaptureMethod::Blocking)?;
    println!("{:#?}", frame_info);

    let image = image::ImageBuffer::<image::Rgb<u8>, &[u8]>::from_raw(
        frame_info.width,
        frame_info.height,
        frame_info.buffer,
    ).unwrap();
    image.save("frame.png")?;
    println!("Saved frame to 'frame.png'.");

    capturer.stop()?;

    Ok(())
}

Future work

Support for configuration is currently limited, to keep the code simple and concise. Future releases will add more configuration options.

License: BSD-2-Clause

Dependencies