pub struct VideoRecorder { /* private fields */ }Expand description
MP4 Video Recorder
Records screenshots as video frames and exports to MP4 format.
§Example
ⓘ
use jugar_probar::media::{VideoRecorder, VideoConfig};
let config = VideoConfig::new(1280, 720).with_fps(30);
let mut recorder = VideoRecorder::new(config);
recorder.start()?;
// Capture frames during test
for screenshot in screenshots {
recorder.capture_frame(&screenshot)?;
}
let video_data = recorder.stop()?;
std::fs::write("test_recording.mp4", video_data)?;Implementations§
Source§impl VideoRecorder
impl VideoRecorder
Sourcepub fn new(config: VideoConfig) -> Self
pub fn new(config: VideoConfig) -> Self
Create a new video recorder with the given configuration
Sourcepub fn state(&self) -> RecordingState
pub fn state(&self) -> RecordingState
Get the current recording state
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Get the number of captured frames
Sourcepub fn config(&self) -> &VideoConfig
pub fn config(&self) -> &VideoConfig
Get the recording configuration
Sourcepub fn start(&mut self) -> ProbarResult<()>
pub fn start(&mut self) -> ProbarResult<()>
Start recording
Sourcepub fn capture_frame(&mut self, screenshot: &Screenshot) -> ProbarResult<()>
pub fn capture_frame(&mut self, screenshot: &Screenshot) -> ProbarResult<()>
Capture a frame from a screenshot
Sourcepub fn capture_raw_frame(
&mut self,
data: &[u8],
width: u32,
height: u32,
) -> ProbarResult<()>
pub fn capture_raw_frame( &mut self, data: &[u8], width: u32, height: u32, ) -> ProbarResult<()>
Capture a raw frame (RGBA data)
Sourcepub fn stop(&mut self) -> ProbarResult<Vec<u8>>
pub fn stop(&mut self) -> ProbarResult<Vec<u8>>
Stop recording and return the encoded video data
Sourcepub fn save(&self, path: &Path) -> ProbarResult<()>
pub fn save(&self, path: &Path) -> ProbarResult<()>
Save the recorded video to a file
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VideoRecorder
impl RefUnwindSafe for VideoRecorder
impl Send for VideoRecorder
impl Sync for VideoRecorder
impl Unpin for VideoRecorder
impl UnsafeUnpin for VideoRecorder
impl UnwindSafe for VideoRecorder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more