Skip to main content

Crate long_screen

Crate long_screen 

Source
Expand description

Long Screen as a native library: a screen recording in, one big screenshot out.

run drives the same engine the web page runs, pass by pass and in the same order — scan, solve, render, reveal, framing, preview pyramid — over a FrameSource (a video file decoded natively by VideoSource, or RGBA frames you already have). It keeps the rows the page would keep in IndexedDB in an in-memory Store, formats diagnostics with the page’s own zh/en catalogue, reports progress and diagnostics to an Observer, and honours pause and stop through a Control between steps. The RunResult holds the canvases (the print, its framed presentation and any separate fragments) as tiles, and writes any of them as a PNG of any size, streamed band by band.

The command-line tool long-screen (feature cli) is a thin layer over this crate; a desktop app or a Python binding can drive it the same way.

use long_screen::{run, Control, DecodeOptions, Options, VideoSource};

let mut source = VideoSource::open("recording.mov".as_ref(), DecodeOptions::default())?;
let control = Control::new(); // clone it to another thread to pause or stop the run
let mut on_progress = |p: &long_screen::Progress| eprintln!("{} {:.0}%", p.phase, p.fraction * 100.0);
let result = run(&mut source, &Options::default(), &mut on_progress, &control)?;
if let Some(print) = result.print() {
    let file = std::fs::File::create("print.png")?;
    result.write_png(&print.id, std::io::BufWriter::new(file))?;
}
for d in result.diagnostics() {
    eprintln!("{} {}: {}", d.severity, d.code, d.message);
}

§Layers

The crate root is the driver API. Under it sit the layers the driver, the web page’s WebAssembly and the benchmarks are built from. They are public so those builds can reach them, but they are implementation layers: their API follows what those hosts need and may change in minor versions.

  • kernels: the reconstruction algorithms (motion, regions and layers, tracking, the pose graph, compositing, reveal, framing, the preview pyramid, YUV→RGBA), with no I/O. Compiles for wasm32-unknown-unknown.
  • engine: one run as a state machine over the kernels, driven step by step by a host that stores the rows. Compiles for wasm32-unknown-unknown.
  • decode (feature decode): native video decoding with the system decoder or a user-installed ffmpeg.

§Features

  • driver (default): the driver API at the crate root (run, Options, RunResult, the sources, the in-memory Store). Implies catalog.
  • decode (default): the decode module and VideoSource (AVFoundation on macOS, Media Foundation on Windows, ffmpeg everywhere). Re-exports its options as DecodeOptions and DecodeBackend.
  • rayon (default): the kernels run on rayon’s thread pool. Results do not depend on the thread count.
  • catalog (default): the embedded zh/en diagnostic and progress catalogue and its formatter (engine::catalog), which reproduces the web page’s messages exactly.
  • cli (default): the long-screen command line and its argument parser. Implies driver and decode.

With default-features = false only kernels and engine remain, which is what the web page’s WebAssembly builds.

Re-exports§

pub use decode::Backend as DecodeBackend;
pub use decode::Options as DecodeOptions;
pub use crate::engine::catalog::Locale;
pub use crate::source::VideoSource;
pub use crate::source::Frame;
pub use crate::source::FrameSource;
pub use crate::source::MediaInfo;
pub use crate::source::RawSource;
pub use crate::source::SourceError;
pub use crate::store::Store;

Modules§

decode
Native video decoding for the command line, the Python module and desktop builds.
engine
One reconstruction run as a state machine over the kernels.
kernels
The reconstruction algorithms: features and motion evidence, region and layer learning, tracking, the pose graph, compositing with temporal conflicts, reveal, framing and the preview pyramid, plus the YUV→RGBA and PNG row kernels.
source
Where frames come from. A run reads its source once per pass (scan, solve, render, and the reveal’s sweeps), in order, as the web page re-decodes its file for every pass; FrameSource::frames starts one such read.
store
The row store: every row a run persists, by key, in key order — the native stand-in for the page’s IndexedDB namespace run/<id>/ (plus the project/<id> row).
value
Persisted rows as the web page stores them: JavaScript values with ordered object fields, typed arrays and blobs.

Structs§

CanvasInfo
One canvas of the result.
Control
Pause and stop for a running run, from any thread. Clones share the same flags. A stop ends the current pass at its next step and keeps what is done (the result is partial); a pause holds the run between steps.
Diagnostic
One diagnostic, in the run’s display language.
Options
Everything a run takes besides its source.
Progress
One progress event.
RunResult
A finished (or partial) run.
Settings
The run settings the page offers (Settings in src/types.ts), with its defaults.

Enums§

Error
Why a run could not produce anything.
Framing
Whether the print is also shown inside the recording’s own frame (chrome, toolbars).
TemporalPolicy
How conflicting content (an area that changed while it was on screen) is resolved.

Traits§

Observer
Receives a run’s events on the run’s thread. Both methods default to doing nothing.

Functions§

run
Runs the whole reconstruction on source. Progress and diagnostics go to observer as they happen; control pauses or stops the run from another thread. Returns the result even when the run ended partial (a stop, or a failure after some frames were rendered); only a run that rendered nothing is an Error::Failed.