Update example based on api changes
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
3c0f2dfed7
commit
b45dc606f1
@ -21,6 +21,8 @@ fn get_display(i: usize) -> Display {
|
|||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn record(i: usize) {
|
fn record(i: usize) {
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
for d in Display::all().unwrap() {
|
for d in Display::all().unwrap() {
|
||||||
println!("{:?} {} {}", d.origin(), d.width(), d.height());
|
println!("{:?} {} {}", d.origin(), d.width(), d.height());
|
||||||
}
|
}
|
||||||
@ -40,7 +42,7 @@ fn record(i: usize) {
|
|||||||
println!("Filter window for cls {} name {}", wnd_cls, wnd_name);
|
println!("Filter window for cls {} name {}", wnd_cls, wnd_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
let frame = capture_mag.frame(0).unwrap();
|
let frame = capture_mag.frame(Duration::from_millis(0)).unwrap();
|
||||||
println!("Capture data len: {}, Saving...", frame.len());
|
println!("Capture data len: {}, Saving...", frame.len());
|
||||||
|
|
||||||
let mut bitflipped = Vec::with_capacity(w * h * 4);
|
let mut bitflipped = Vec::with_capacity(w * h * 4);
|
||||||
@ -76,7 +78,7 @@ fn record(i: usize) {
|
|||||||
println!("Filter window for cls {} title {}", wnd_cls, wnd_title);
|
println!("Filter window for cls {} title {}", wnd_cls, wnd_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
let buffer = capture_mag.frame(0).unwrap();
|
let buffer = capture_mag.frame(Duration::from_millis(0)).unwrap();
|
||||||
println!("Capture data len: {}, Saving...", buffer.len());
|
println!("Capture data len: {}, Saving...", buffer.len());
|
||||||
|
|
||||||
let mut frame = Default::default();
|
let mut frame = Default::default();
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
extern crate scrap;
|
extern crate scrap;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -29,7 +31,7 @@ fn main() {
|
|||||||
let mut out = child.stdin.unwrap();
|
let mut out = child.stdin.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match capturer.frame(0) {
|
match capturer.frame(Duration::from_millis(0)) {
|
||||||
Ok(frame) => {
|
Ok(frame) => {
|
||||||
// Write the frame, removing end-of-row padding.
|
// Write the frame, removing end-of-row padding.
|
||||||
let stride = frame.len() / h;
|
let stride = frame.len() / h;
|
||||||
|
@ -104,9 +104,6 @@ fn main() -> io::Result<()> {
|
|||||||
timebase: [1, 1000],
|
timebase: [1, 1000],
|
||||||
bitrate: args.flag_bv,
|
bitrate: args.flag_bv,
|
||||||
codec: vpx_codec,
|
codec: vpx_codec,
|
||||||
rc_min_quantizer: 0,
|
|
||||||
rc_max_quantizer: 0,
|
|
||||||
speed: 6,
|
|
||||||
num_threads: 0,
|
num_threads: 0,
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -137,7 +134,7 @@ fn main() -> io::Result<()> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(frame) = c.frame(0) {
|
if let Ok(frame) = c.frame(Duration::from_millis(0)) {
|
||||||
let ms = time.as_secs() * 1000 + time.subsec_millis() as u64;
|
let ms = time.as_secs() * 1000 + time.subsec_millis() as u64;
|
||||||
|
|
||||||
for frame in vpx.encode(ms as i64, &frame, STRIDE_ALIGN).unwrap() {
|
for frame in vpx.encode(ms as i64, &frame, STRIDE_ALIGN).unwrap() {
|
||||||
|
@ -34,7 +34,7 @@ fn record(i: usize) {
|
|||||||
loop {
|
loop {
|
||||||
// Wait until there's a frame.
|
// Wait until there's a frame.
|
||||||
|
|
||||||
let buffer = match capturer.frame(0) {
|
let buffer = match capturer.frame(Duration::from_millis(0)) {
|
||||||
Ok(buffer) => buffer,
|
Ok(buffer) => buffer,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
if error.kind() == WouldBlock {
|
if error.kind() == WouldBlock {
|
||||||
@ -83,7 +83,7 @@ fn record(i: usize) {
|
|||||||
loop {
|
loop {
|
||||||
// Wait until there's a frame.
|
// Wait until there's a frame.
|
||||||
|
|
||||||
let buffer = match capturer.frame(0) {
|
let buffer = match capturer.frame(Duration::from_millis(0)) {
|
||||||
Ok(buffer) => buffer,
|
Ok(buffer) => buffer,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
if error.kind() == WouldBlock {
|
if error.kind() == WouldBlock {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user