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 viaset_dir), then next to the app exe, thenffmpeg/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 viaffprobe -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ยง
- Audio
Pipe ๐ - Image
Source ๐ - Still image: decoded once per requested size (
-frames:v 1),tignored. - Video
Pipe ๐
Constantsยง
- AUDIO_
CHUNK_ ๐FRAMES
Staticsยง
- DIR ๐
Functionsยง
- box_
down ๐ - Area-average downscale of top-down RGBA (
w <= sw,h <= sh). - command
- A Command for
exethat never opens a console window. - f64_of ๐
- ffmpeg_
exe - ffprobe_
exe - find ๐
- find_
all_ ๐exe - Every place
nameexists, in lookup order.ytdlpneeds 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 anffmpegsubfolder), then PATH. Shared withmedia::ytdlpโ not cached, so callers must not run it every frame. - kill ๐
- open_
audio - open_
video - packet_
duration ๐ - Duration of stream
selfrom 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 ๐