MCPcopy Create free account
hub / github.com/Recordscript/recordscript / main

Function main

libs/scrap/examples/record-screen.rs:63–172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61}
62
63fn main() -> io::Result<()> {
64 let args: Args = Docopt::new(USAGE)
65 .and_then(|d| d.deserialize())
66 .unwrap_or_else(|e| e.exit());
67
68 let duration = args.flag_time.map(Duration::from_secs);
69
70 let d = Display::primary().unwrap();
71 let (width, height) = (d.width() as u32, d.height() as u32);
72
73 // Setup the multiplexer.
74
75 let out = match {
76 OpenOptions::new()
77 .write(true)
78 .create_new(true)
79 .open(&args.arg_path)
80 } {
81 Ok(file) => file,
82 Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => {
83 if loop {
84 quest::ask("Overwrite the existing file? [y/N] ");
85 if let Some(b) = quest::yesno(false)? {
86 break b;
87 }
88 } {
89 File::create(&args.arg_path)?
90 } else {
91 return Ok(());
92 }
93 }
94 Err(e) => return Err(e.into()),
95 };
96
97 let mut webm =
98 mux::Segment::new(mux::Writer::new(out)).expect("Could not initialize the multiplexer.");
99
100 let (vpx_codec, mux_codec) = match args.flag_codec {
101 Codec::Vp8 => (vpx_encode::VpxVideoCodecId::VP8, mux::VideoCodecId::VP8),
102 Codec::Vp9 => (vpx_encode::VpxVideoCodecId::VP9, mux::VideoCodecId::VP9),
103 };
104
105 let mut vt = webm.add_video_track(width, height, None, mux_codec);
106
107 // Setup the encoder.
108 let quality = match args.flag_quality {
109 Quality::Best => Q::Best,
110 Quality::Balanced => Q::Balanced,
111 Quality::Low => Q::Low,
112 };
113 let mut vpx = vpx_encode::VpxEncoder::new(
114 EncoderCfg::VPX(vpx_encode::VpxEncoderConfig {
115 width,
116 height,
117 quality,
118 codec: vpx_codec,
119 keyframe_interval: None,
120 }),

Callers

nothing calls this directly

Calls 11

sleepFunction · 0.85
writeMethod · 0.80
storeMethod · 0.80
loadMethod · 0.80
widthMethod · 0.45
heightMethod · 0.45
cloneMethod · 0.45
frameMethod · 0.45
toMethod · 0.45
yuvfmtMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected