Skip to content

Commit 3824fa7

Browse files
authored
Merge pull request #126 from USACE-RMC/enhancement/video-component-and-ffmpeg
Add Video scroll-into-view autoplay and video compression tooling
2 parents 2673907 + 153129d commit 3824fa7

8 files changed

Lines changed: 477 additions & 11 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ src/reportIdMap.js
3535
src/imageDimensions.js
3636
src/data/
3737

38+
# Preserved raw originals from compress-video (kept locally, never deployed)
39+
*-raw.mp4
40+
*-raw.webm
41+
*-raw.mov
42+
*-raw.m4v
43+
3844
/docx_converter/venv/
3945
/docx_converter/utils/__pycache__/
4046
*.py[cod]

docs/dev/documentation-guide/06-creating-editing-pages.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ import Video from '@site/src/components/Video';
582582
<Video
583583
videoKey="vid-demo"
584584
src="/videos/desktop-applications/lifesim/users-guide/v1.0/demo.mp4"
585-
alt="Screen recording of the LifeSim setup process"
586585
caption="LifeSim setup demonstration"
587586
/>
588587
```
@@ -595,6 +594,16 @@ import VideoReference from '@site/src/components/VideoReference';
595594
See <VideoReference videoKey="vid-demo" /> for a walkthrough.
596595
```
597596

597+
:::tip Compress videos before committing
598+
Screen-capture files are often much larger than they need to be. Before adding a video, compress it with the built-in tool:
599+
600+
```bash
601+
npm run compress-video -- static/figures/<path>/your-video.mp4
602+
```
603+
604+
This re-encodes the file in place (so your `<Video src>` path stays the same) and preserves the untouched original beside it as `your-video-raw.mp4`. The `*-raw.*` originals are gitignored — kept locally as a backup, never committed or deployed. Add `--audio` to keep an audio track (dropped by default) or `--crf <n>` to adjust quality.
605+
:::
606+
598607
See [React Components](./07-react-components.mdx) for full props documentation.
599608

600609
---

docs/dev/documentation-guide/07-react-components.mdx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3105,7 +3105,7 @@ import Video from '@site/src/components/Video';
31053105
'Multiple sources <code>[{src, type}]</code>',
31063106
'Display width',
31073107
'Show video controls',
3108-
'Auto-play on load',
3108+
'Auto-play when scrolled into view (muted); pauses off-screen; off for reduced-motion users',
31093109
'Loop playback',
31103110
'Mute audio (auto=true if autoPlay)',
31113111
'iOS inline playback',
@@ -3118,6 +3118,27 @@ import Video from '@site/src/components/Video';
31183118
]}
31193119
/>
31203120

3121+
**Autoplay behavior:**
3122+
3123+
When `autoPlay` is set, the video does **not** start on page load. It starts when the user scrolls it into view and pauses when it scrolls out of view (via an `IntersectionObserver`). Autoplay always plays **muted** (browsers block un-muted autoplay), and it is **disabled entirely for visitors who have enabled "reduce motion"** in their operating system.
3124+
3125+
Use `autoPlay loop` with `controls={false}` as a lightweight, modern replacement for an animated GIF — the same continuous, silent loop, but a far smaller file with built-in pause-when-offscreen behavior:
3126+
3127+
```jsx
3128+
<Video
3129+
videoKey="video-gif-style"
3130+
caption="Looping UI animation"
3131+
src="/videos/ui-loop.mp4"
3132+
autoPlay
3133+
loop
3134+
controls={false}
3135+
/>
3136+
```
3137+
3138+
:::warning Keep controls on for longer autoplay clips
3139+
For an `autoPlay loop` clip longer than ~5 seconds, leave `controls` at its default (`true`) so viewers can pause it. Continuous motion with no pause control fails WCAG 2.2.2 (Pause, Stop, Hide), a Section 508 requirement. The `controls={false}` GIF style is only appropriate for very short loops.
3140+
:::
3141+
31213142
---
31223143

31233144
### VideoReference

docs/dev/documentation-guide/17-appendix-b-build-process-overview.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ These files configure the build process but are rarely modified:
601601
**Contains:**
602602

603603
- List of all npm packages used
604-
- Script definitions (`start`, `build`, `deploy`)
604+
- Script definitions (`start`, `build`, `deploy`, and the manual `compress-video` utility)
605605
- Node.js version requirements
606606
- Project metadata
607607

@@ -625,6 +625,14 @@ These files configure the build process but are rarely modified:
625625

626626
---
627627

628+
### `scripts/compress-video.js` (manual utility)
629+
630+
**Purpose:** Compress oversized video files before committing them.
631+
632+
Unlike the scripts above, this is **not** part of the automated build — it is an on-demand helper. Run `npm run compress-video -- <path-to-video>` to re-encode a video in place (H.264/CRF via the bundled `ffmpeg-static`, so no system install is required). The original is preserved as a gitignored `*-raw.*` file. See [Videos and GIFs](./06-creating-editing-pages.mdx) for the contributor workflow.
633+
634+
---
635+
628636
## Deployment to Production (Administrator-Level Only)
629637

630638
:::danger Important - Administrators Only

package-lock.json

Lines changed: 134 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"versions": "node scripts/versions.js",
99
"sidebars": "node scripts/generateSidebars.js",
1010
"report-map": "node scripts/generateReportIdMap.js",
11+
"compress-video": "node scripts/compress-video.js",
1112
"generate-toc": "node scripts/generateEventTreeTOC.js",
1213
"image-dims": "node scripts/generateImageDimensions.js",
1314
"start": "cross-env DOCS_MODE=dev npm run image-dims && cross-env DOCS_MODE=dev npm run report-map && cross-env DOCS_MODE=dev npm run sidebars && cross-env DOCS_MODE=dev npm run counters && cross-env DOCS_MODE=dev npm run versions && cross-env DOCS_MODE=dev npm run generate-toc && cross-env DOCS_MODE=dev docusaurus start",
@@ -52,6 +53,7 @@
5253
"autoprefixer": "^10.4.21",
5354
"baseline-browser-mapping": "^2.9.19",
5455
"cross-env": "^7.0.3",
56+
"ffmpeg-static": "^5.3.0",
5557
"postcss": "^8.5.6",
5658
"prettier": "^3.6.2",
5759
"prettier-plugin-tailwindcss": "^0.6.14"

0 commit comments

Comments
 (0)