5722481c4a
Videos now get a thumbnail generated eagerly server-side on upload, through the same WebP/blob-hash pipeline as photos — instead of the old browser path that only ran when the Photos grid first rendered a video tile, re-downloaded the whole video to seek a frame, and PUT 3 JPEGs back (and produced nothing at all for HEVC/.mov, which a browser <video> cannot decode). - New VideoFramePort (application) + FfmpegVideoFrameService / NoopVideoFrameService (infrastructure): shell out to the system ffmpeg (no compile-time libav dep), extract one representative frame as PNG, bounded by its own semaphore + a per-process timeout + kill_on_drop. Noop when ffmpeg is absent/disabled, so videos degrade gracefully to no thumbnail. - ThumbnailRefreshHook.on_file_created routes video/* to generate_video_thumbnails_background: stream the (decrypted, reassembled) blob to a size- and time-bounded temp file on the data volume, extract a frame, and reuse the shared render_and_persist_all_webp helper — so video thumbnails are WebP, blob-hash keyed (dedup'd) and content-negotiated, exactly like photos. - GET thumbnail serves the video's WebP to every client (byte-sniffed Content-Type); a genuine miss returns 204. - Config: OXICLOUD_ENABLE_VIDEO_THUMBNAILS (default true, needs ffmpeg detected at startup) + OXICLOUD_FFMPEG_PATH / _CONCURRENCY / _TIMEOUT_SECS / _MAX_MB. - Dockerfile installs ffmpeg in the runtime image. - Frontend: drop the client-side generateVideoThumb/frameFromVideo re-download path; the server is now the source of truth. Benchmark (examples/bench_video_thumbnails.rs, needs ffmpeg): 4/4 codecs incl. HEVC/.mov produce a thumbnail server-side (was 0% for HEVC); ~50-70 ms/frame in the background; ~3.9 KB preview WebP; up to ~23x less per-first-view transfer on the test corpus (far more on real multi-MB clips). Methodology in benches/VIDEO-THUMB.md. Hardening from an adversarial review: video render holds the decode_semaphore like the image path; the ffmpeg scale filter bounds both dimensions; the blob stream has a timeout; the temp file lives on the data volume; the size cap uses saturating_mul. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
192 lines
7.5 KiB
TOML
192 lines
7.5 KiB
TOML
[package]
|
|
name = "oxicloud"
|
|
version = "0.8.0"
|
|
edition = "2024"
|
|
default-run = "oxicloud"
|
|
|
|
|
|
[dependencies]
|
|
mimalloc = { version = "0.1.52", default-features = false }
|
|
axum = { version = "0.8.9", features = ["multipart", "http1", "http2", "tokio", "macros"] }
|
|
tokio = { version = "1.52.3", features = ["rt-multi-thread", "macros", "io-util", "net", "time", "sync", "fs"] }
|
|
tokio-util = { version = "0.7.18", features = ["io", "codec", "compat"] }
|
|
tokio-stream = { version = "0.1.18", features = ["fs", "sync"] }
|
|
bytes = "1.11.1"
|
|
tempfile = "3.27.0"
|
|
tower = "0.5.3"
|
|
tower-http = { version = "0.6.11", features = ["fs", "compression-gzip", "compression-br", "trace", "cors", "add-extension", "request-id", "set-header", "limit"] }
|
|
flate2 = "1.1.9"
|
|
tracing = "0.1.44"
|
|
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
|
chrono = { version = "0.4.45", features = ["serde"] }
|
|
http-body = "1.0.1"
|
|
serde = { version = "1.0.228", features = ["derive"] }
|
|
serde_json = "1.0.150"
|
|
futures = "0.3.32"
|
|
async-stream = "0.3.6"
|
|
async-trait = "0.1.89"
|
|
mime_guess = "2.0.5"
|
|
uuid = { version = "1.23.3", features = ["v4", "v7", "serde"] }
|
|
thiserror = "2.0.18"
|
|
|
|
mockall = { version = "0.14.0", optional = true }
|
|
sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio", "tls-rustls", "chrono", "uuid", "json", "migrate"] }
|
|
jsonwebtoken = { version = "10.4.0", features = ["rust_crypto"] }
|
|
argon2 = "0.5.3"
|
|
rand_core = { version = "0.6", features = ["std", "getrandom"] }
|
|
quick-xml = "0.39.4"
|
|
dotenvy = "0.15.7"
|
|
moka = { version = "0.12.15", features = ["future", "sync"] }
|
|
http-range-header = "0.4"
|
|
image = { version = "0.25.10", default-features = false, features = ["jpeg", "png", "gif", "webp"] }
|
|
# Shrink-on-load JPEG decode (DCT 1/2·1/4·1/8 scaling) for thumbnails — pure
|
|
# Rust, no C toolchain. The `image` crate's zune-jpeg backend can't scale during
|
|
# decode; this can, cutting decode time/RAM ~order-of-magnitude on large photos.
|
|
jpeg-decoder = "0.3"
|
|
# SIMD (AVX2/SSE4.1/NEON) image resizing for thumbnails — far faster than the
|
|
# `image` crate's scalar resampler, and it speeds every format (incl. PNG/WebP).
|
|
fast_image_resize = "5"
|
|
# Lossy WebP encoding for thumbnails. The `image` crate's webp feature is
|
|
# lossless-only; this binds libwebp (vendored + built via `cc`, no system dep)
|
|
# for quality-controlled lossy output (~25-30% smaller than JPEG at equal SSIM).
|
|
webp = "0.3"
|
|
id3 = "1.17"
|
|
mp3-duration = "0.1"
|
|
kamadak-exif = "0.6.1"
|
|
md-5 = "0.11.0"
|
|
sha2 = "0.11.0"
|
|
unicode-normalization = "0.1.25"
|
|
blake3 = { version = "1.8.5", features = ["rayon", "mmap"] }
|
|
hex = "0.4.3"
|
|
http-body-util = "0.1.3"
|
|
percent-encoding = "2.3.2"
|
|
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls-webpki-roots","rustls-tls-native-roots"] }
|
|
base64 = "0.22.1"
|
|
fs2 = "0.4"
|
|
rayon = "1.12.0"
|
|
infer = "0.19"
|
|
async-compression = { version = "0.4.42", features = ["tokio", "gzip"] }
|
|
async_zip = { version = "0.0.18", features = ["tokio", "deflate"] }
|
|
dashmap = "6.2.1"
|
|
socket2 = { version = "0.6.4", features = ["all"] }
|
|
urlencoding = "2.1.3"
|
|
utoipa = { version = "5.5.0", features = ["axum_extras", "uuid", "chrono"] }
|
|
aws-sdk-s3 = "1.136.0"
|
|
aws-config = { version = "1.8.18", features = ["behavior-version-latest"] }
|
|
aws-smithy-types = "1.5.0"
|
|
azure_core = { version = "0.21", default-features = false, features = ["enable_reqwest_rustls", "hmac_rust"] }
|
|
azure_storage = { version = "0.21", default-features = false, features = ["enable_reqwest_rustls", "hmac_rust"] }
|
|
azure_storage_blobs = { version = "0.21", default-features = false, features = ["enable_reqwest_rustls", "hmac_rust"] }
|
|
aes-gcm = "0.10.3"
|
|
lru = "0.16.4"
|
|
fastcdc = { version = "4.0.0", features = ["tokio"] }
|
|
lettre = { version = "0.11.18", default-features = false, features = ["smtp-transport", "tokio1-rustls-tls", "rustls-native-certs", "builder"] }
|
|
idna = "1.1"
|
|
smol_str = { version = "0.3.6", features = ["serde"] }
|
|
accept-language = "3.1.0"
|
|
askama = "0.16.0"
|
|
tantivy = "0.26.1"
|
|
zip = { version = "8.6.0", default-features = false, features = ["deflate"] }
|
|
pdf-extract = "0.10.0"
|
|
nom-exif = "3.6.1"
|
|
extism = { version = "1.30.0", optional = true }
|
|
toml = { version = "1.1.2", optional = true }
|
|
file-rotate = { version = "0.7.6", optional = true }
|
|
ort = { version = "2.0.0-rc.12", default-features = false, features = ["load-dynamic", "ndarray", "tracing", "api-24"], optional = true }
|
|
ndarray = { version = "0.17.2", optional = true }
|
|
|
|
[features]
|
|
default = []
|
|
test_utils = ["mockall"]
|
|
integration_tests = []
|
|
# WASM plugin runtime (Extism). Opt-in: bundles wasmtime, a large engine most
|
|
# deployments won't use. Activation also requires OXICLOUD_ENABLE_PLUGINS=true.
|
|
plugins = ["dep:extism", "dep:toml", "dep:file-rotate"]
|
|
# Empty marker feature that gates the `load-seed` binary so it isn't built
|
|
# by default (and skipped in prod Docker builds). Kept separate from
|
|
# test_utils so enabling it doesn't change the oxicloud dependency graph —
|
|
# this lets one `cargo build` produce both `oxicloud` and `load-seed`
|
|
# without recompiling oxicloud with mockall in scope.
|
|
load_seed_bin = []
|
|
# Real ONNX-backed face analyzer (detector + embedder) for the People feature.
|
|
# Opt-in: pulls `ort` (ONNX Runtime, load-dynamic — dlopen's libonnxruntime at
|
|
# runtime) + `ndarray`, a heavy stack most deployments won't use. Activation also
|
|
# requires OXICLOUD_ENABLE_FACES=true *and* operator-provided ONNX models; without
|
|
# this feature the People pipeline falls back to the inert NoopFaceAnalyzer.
|
|
faces-onnx = ["dep:ort", "dep:ndarray"]
|
|
# Performance benchmark harness (Phase 0). Exposes `bench_support` + thin public
|
|
# wrappers over the private thumbnail render functions so `benches/` and
|
|
# `examples/` can measure them. Off by default — adds nothing to prod builds.
|
|
# Run with: `cargo bench --features bench` / `cargo run --release --features bench --example bench_thumbnails_mem`.
|
|
bench = []
|
|
|
|
[dev-dependencies]
|
|
criterion = "0.5"
|
|
|
|
[lints.rust]
|
|
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(integration_tests)'] }
|
|
|
|
[[bin]]
|
|
name = "generate-openapi"
|
|
path = "src/bin/generate-openapi.rs"
|
|
|
|
[[bin]]
|
|
name = "migrate-nfc-filenames"
|
|
path = "src/bin/migrate-nfc-filenames.rs"
|
|
|
|
[[bin]]
|
|
name = "load-seed"
|
|
path = "src/bin/load-seed.rs"
|
|
# Test fixture seeder. Gated behind the empty `load_seed_bin` feature so
|
|
# `cargo build --release` (and the prod Dockerfile) skip it. tests/load/run.sh
|
|
# and load-nightly.yml build it explicitly with --features load_seed_bin.
|
|
required-features = ["load_seed_bin"]
|
|
|
|
# Phase 0 perf harness — Task 0.2 (criterion latency + output-size bench).
|
|
[[bench]]
|
|
name = "thumbnails"
|
|
path = "benches/thumbnails.rs"
|
|
harness = false
|
|
required-features = ["bench"]
|
|
|
|
# Phase 0 perf harness — Task 0.3 (peak-RAM + saturated-throughput baseline).
|
|
[[example]]
|
|
name = "bench_thumbnails_mem"
|
|
path = "examples/bench_thumbnails_mem.rs"
|
|
required-features = ["bench"]
|
|
|
|
# Video thumbnail benchmark — Option B (server-side ffmpeg frame → WebP). Needs
|
|
# `ffmpeg` on PATH (libx264/libx265/libvpx-vp9 to synthesize the test corpus).
|
|
[[example]]
|
|
name = "bench_video_thumbnails"
|
|
path = "examples/bench_video_thumbnails.rs"
|
|
required-features = ["bench"]
|
|
|
|
# DB connection-pool tail-latency benchmark (needs the dev Postgres up).
|
|
[[example]]
|
|
name = "bench_db_pool"
|
|
path = "examples/bench_db_pool.rs"
|
|
required-features = ["bench"]
|
|
|
|
# ACL owner-cache benchmark — owner query vs moka hit (needs the dev Postgres up).
|
|
[[example]]
|
|
name = "bench_owner_cache"
|
|
path = "examples/bench_owner_cache.rs"
|
|
required-features = ["bench"]
|
|
|
|
[profile.release]
|
|
lto = "thin"
|
|
codegen-units = 1
|
|
opt-level = 3
|
|
panic = "abort"
|
|
strip = true
|
|
|
|
[profile.dev]
|
|
opt-level = 1
|
|
debug = true
|
|
|
|
[profile.bench]
|
|
lto = "fat"
|
|
codegen-units = 1
|
|
opt-level = 3
|