Module ffpipe

Source
Expand description

ffmpeg.exe / ffprobe.exe child-process backend. Universal fallback decoder, image loader, prober, and the process launcher used by export.

Contract (see media/mod.rs):

  • ffmpeg_exe() / ffprobe_exe() locate the binaries: Settings.ffmpeg_dir (set via set_dir), then next to the app exe, then ffmpeg/ beside the exe, then PATH (a few stats per call, not cached).
  • command(exe) returns a std Command with CREATE_NO_WINDOW (0x08000000) so no console flashes.
  • probe(path) -> Asset via ffprobe -v error -print_format json -show_streams -show_format.
  • open_video(path) -> VideoSource: ffmpeg -ss T -i path -map 0:v:0 -f rawvideo -pix_fmt rgba -s WxH -fps_mode cfr -r FPS -an -sn pipe:1, read WH4 bytes per frame (pts = T + n/fps); restart on non-sequential seeks (at the requested size) or when a request outgrows the pipe (then at native size, so later sizes never restart); smaller requests are shrunk in Rust. Images (1 frame) are decoded once per size and cached.
  • open_audio(path, stream) -> AudioSource: ffmpeg -ss T -i path -map 0:a:N -f f32le -ac 2 -ar 48000 pipe:1. Kill children on Drop.

Structsยง

AudioPipe ๐Ÿ”’
ImageSource ๐Ÿ”’
Still image: decoded once per requested size (-frames:v 1), t ignored.
VideoPipe ๐Ÿ”’

Constantsยง

AUDIO_CHUNK_FRAMES ๐Ÿ”’

Staticsยง

DIR ๐Ÿ”’

Functionsยง

box_down ๐Ÿ”’
Area-average downscale of top-down RGBA (w <= sw, h <= sh).
command
A Command for exe that never opens a console window.
f64_of ๐Ÿ”’
ffmpeg_exe
ffprobe_exe
find ๐Ÿ”’
find_all_exe ๐Ÿ”’
Every place name exists, in lookup order. ytdlp needs this because a PATH entry can hold a broken shim (a pip launcher for an uninstalled Python) that must be skipped for the next one.
find_exe ๐Ÿ”’
Locate a helper executable: dir (when set), then next to our exe (and an ffmpeg subfolder), then PATH. Shared with media::ytdlp โ€” not cached, so callers must not run it every frame.
kill ๐Ÿ”’
open_audio
open_video
packet_duration ๐Ÿ”’
Duration of stream sel from its packets: max(pts_time + duration_time) - min(pts_time); when no packet carries a pts (raw .h264) the durations are summed instead. Full demux, so only for files whose container has no duration. 0.0 on failure.
parse_rate ๐Ÿ”’
โ€œ30000/1001โ€ -> 29.97; โ€œ0/0โ€ / garbage -> 0.
probe
set_dir
Set the user-configured ffmpeg directory (โ€œโ€ = auto).
spawn ๐Ÿ”’
str_of ๐Ÿ”’