Repository navigation
feat: video → WebM conversion with S3 hash cache + per-job build report (0.3.0) - #3
Merged
Merged
Conversation
Video conversion: - The worker image now ships ffmpeg; optimize.py converts non-web video formats (.mov/.m4v/.avi/.mkv/.wmv/.mpg/.mpeg, case-insensitive) to WebM (VP9 CRF 33 + Opus 96k), replacing the original file and rewriting references — the same model already used for images (AVIF) and fonts (WOFF2). .mp4 is left untouched (already web-friendly). - Per-file ffmpeg timeout of 600s; failures keep the original and only warn, so the pipeline never breaks on a bad video. - New convert_videos option (default true) flowing from the API payload through jobs.py to optimize.py's --no-convert-videos flag. S3 hash cache (deploy speed): - sync_to_s3 stores each file's sha256 in the object metadata and skips re-uploading unchanged files (HEAD per file; metadata instead of ETag because multipart uploads make the ETag a composite value). - Converted .webm objects additionally carry source-sha256 and an encoder tag, so repeat deploys of an unchanged video skip the ffmpeg run entirely — the existing .webm in S3 is reused. - The RQ job timeout goes from 600s to 1800s so the first (uncached) deploy of video-heavy pages fits scrape + encoding. Also adds deterministic Content-Types for video extensions in deploy.py, 13 new tests (video conversion, cache hit/miss, upload skip, option wiring), and README/AGENTS.md updates.
optimize.py gains an optional --report <path.json> flag that records every
file the pipeline touches ({path, kind, action, original_bytes, final_bytes,
sources?} — actions: converted|bundled|minified|cached). jobs.py snapshots
the workdir after postprocess (the 'original' side), times each pipeline
step (time.monotonic), and aggregates a 'report' key into the job result:
pages, per-asset-type original/final bytes, video converted/cache_hits
counts, totals with saved_pct, steps_seconds, and the top 10 savings.
deploy.py excludes the .build-report.json artifact from the S3 upload,
following the video cache manifest pattern.
The WordPress plugin renders this report on the jobs screen.
- README: GET /jobs/{id} result example now shows files_skipped and the
full report key (pages, per-type assets with original/final bytes,
video converted/cache_hits, totals with saved_pct, steps_seconds,
top_savings); notes the 30-minute job timeout.
- AGENTS.md: optimize.py CLI gains --report/--cache-bucket/--cache-prefix;
documents the internal artifacts never uploaded to S3
(.video-cache-manifest.json, .build-report.json).
- api/main.py: FastAPI app version aligned with the release (0.3.0).
The two S3 video-cache tests mock subprocess.run but not the
shutil.which('ffmpeg') guard, so they only passed where a real ffmpeg
binary exists (the worker image) and failed on the CI runner, which has
none. Patch optimize.shutil.which so the tests are environment-independent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's in this release
Video optimization (feat(worker), e732545)
optimize.pyconverts non-web videos (.mov/.m4v/.avi/.mkv/.wmv/.mpg/.mpeg) to WebM (VP9 + Opus), replacing originals and rewriting refs — same model as images (AVIF) and fonts (WOFF2)source-sha256+encodermetadata, so repeat deploys of an unchanged video skip ffmpeg entirelysync_to_s3stores per-filesha256in object metadata and skips unchanged uploadsconvert_videosoption (defaulttrue); RQ job timeout 600s → 1800sPer-job build report (feat(worker), abeb08b)
optimize.py --reportwrites per-file entries ({path, kind, action, original_bytes, final_bytes, sources?}; actions: converted|bundled|minified|cached)jobs.pyaggregates areportkey into the job result: pages, per-type original/final bytes, totals with saved_pct, steps_seconds, top_savings (≤10) — consumed by the WordPress plugin jobs screenDocs (206cde8)
reportkey, video cache and 30-min job timeout; AGENTS.md updated; FastAPI version aligned to 0.3.0Validation