Skip to main content

Crate weirdnet_media

Crate weirdnet_media 

Source
Expand description

Media processing for Weirdnet clients and nodes, shared by the apps that send audio and video to models and get speech back.

  • probe: WAV headers read in pure Rust; any other container through ffprobe.
  • pcm: decode WAV, mix to mono, resample (16 kHz for transcribers), crossfade, concatenate and write WAV.
  • vad: silence-aware cut points for long clips (30 ms RMS frames).
  • transcribe: the long-audio transcription plan, the prompt carried between pieces, and the re-alignment of each piece’s segments onto the whole clip.
  • speak: speak::TextPlan, the long-text speech plan (paragraph, sentence, clause; script turns kept whole), and the joins between the synthesized pieces.
  • subtitles: SRT and WebVTT.
  • ffmpeg: the hardened ffmpeg / ffprobe ffmpeg::Runner (protocol and demuxer allowlists, no URLs, no shell, time, memory and output limits) behind the ffmpeg::Exec trait, with ffmpeg::FakeRunner for tests without ffmpeg.
  • audio: normalization to 16 kHz mono WAV, soundtrack extraction and encoding through the runner.
  • waveform: an immutable f32 waveform::Waveform (shared samples) with gain, fades, normalise, pan, mix and WAV read and write at 8 to 32 bits, converting to and from pcm::Pcm without loss.
  • video: video probing, frame planning (uniform, scene, hybrid, keyframes, intervals), frame and thumbnail extraction, and clips, behind video::FrameSource with video::FakeSource for tests.

Nothing here fetches anything: inputs are files the caller already chose or bytes it holds. There are no defaults that stand in for a model’s limits; plans take the limits the model reports and refuse, naming the missing setting, when they are absent.

Re-exports§

pub use error::MediaError;
pub use error::Result;

Modules§

audio
Audio through the hardened runner: normalization to 16 kHz mono WAV (WAV in Rust, anything else through ffmpeg), soundtrack extraction from audio or video files, and encoding.
error
The crate’s error type.
ffmpeg
ffmpeg and ffprobe in child processes, hardened.
pcm
PCM in memory: decode WAV, mix to mono, resample, crossfade, concatenate, write WAV. Pure Rust.
probe
What a file holds: WAV headers read in pure Rust, anything else through ffprobe (hardened, in crate::ffmpeg).
speak
Long-text speech: TextPlan splits narration or a script into pieces that each fit the model’s max_input_chars, and says how to join the synthesized pieces.
subtitles
SRT and WebVTT from transcript segments.
transcribe
Long-audio transcription: the chunking plan, the prompt carried from piece to piece, and the re-alignment of each piece’s segments onto the whole clip.
vad
Silence-aware cut points: where to split a long clip so each piece fits a window, cutting at the quietest moment near the end of each window rather than in the middle of a word.
video
Video: probing, frame planning (uniform, scene, hybrid, keyframes, fixed intervals), frame, thumbnail and soundtrack extraction, and clips.
waveform
An immutable f32 Waveform for editing and mixing, next to the 16-bit crate::pcm::Pcm the speech paths use.