mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
Compare commits
202
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f68805b981 | ||
|
|
db53845b01 | ||
|
|
3ffe34bb7d | ||
|
|
0706baee4e | ||
|
|
1b7450fb4b | ||
|
|
84acab1f50 | ||
|
|
25280d1eba | ||
|
|
6350c5deb0 | ||
|
|
b6dad1b8aa | ||
|
|
4c3a3ba799 | ||
|
|
6d076868f0 | ||
|
|
119f458018 | ||
|
|
1899d29dff | ||
|
|
a9ecc06820 | ||
|
|
191314a69a | ||
|
|
865e608857 | ||
|
|
56cf86c5c8 | ||
|
|
ee1f3bc32e | ||
|
|
040153449c | ||
|
|
b60d901473 | ||
|
|
457121f804 | ||
|
|
3f9d5eda2d | ||
|
|
3a08d33f37 | ||
|
|
917bc94f59 | ||
|
|
69fb3d8f87 | ||
|
|
a669144986 | ||
|
|
b39dd4e7de | ||
|
|
f46529b461 | ||
|
|
c3e7206581 | ||
|
|
96c450fb75 | ||
|
|
85f4b98616 | ||
|
|
fcdcf1c883 | ||
|
|
3f99e479cd | ||
|
|
bb8b497b58 | ||
|
|
c37509d17f | ||
|
|
913931ad9a | ||
|
|
02051ee992 | ||
|
|
adec0aef74 | ||
|
|
84b7659b09 | ||
|
|
e8e3500466 | ||
|
|
abc6828def | ||
|
|
d184deb4d1 | ||
|
|
80ffc0f8e3 | ||
|
|
80cc01f11d | ||
|
|
7d71973476 | ||
|
|
8581fac811 | ||
|
|
0cd894553d | ||
|
|
c218ecfcdb | ||
|
|
813ea34251 | ||
|
|
0112793530 | ||
|
|
7da3ef25ce | ||
|
|
2238d3d66b | ||
|
|
9f3ece646e | ||
|
|
fcc8fded73 | ||
|
|
cc9f9b1135 | ||
|
|
4dfe231d32 | ||
|
|
8a94b68093 | ||
|
|
0013c2eac2 | ||
|
|
10390997d3 | ||
|
|
d3ebd0baf8 | ||
|
|
56de5f1fd7 | ||
|
|
4d44519fc1 | ||
|
|
bb109cd6d1 | ||
|
|
d8945089ed | ||
|
|
dc9dacf41e | ||
|
|
ac7c37f256 | ||
|
|
08d0c7782a | ||
|
|
12870b2426 | ||
|
|
cba2c338d3 | ||
|
|
87589c84c3 | ||
|
|
1c8f405463 | ||
|
|
b36c98b418 | ||
|
|
4f74e7e754 | ||
|
|
067c030b67 | ||
|
|
1cc07ce266 | ||
|
|
dd0197900f | ||
|
|
f858b78c3b | ||
|
|
4bb94788af | ||
|
|
61b832fcba | ||
|
|
6e19fb5dbe | ||
|
|
6ee9a06f67 | ||
|
|
fb0fca507f | ||
|
|
b3d3308a37 | ||
|
|
f40e458776 | ||
|
|
5194d34efa | ||
|
|
0c132413b6 | ||
|
|
7ef7acc028 | ||
|
|
eaac2989d1 | ||
|
|
6e4f947fc9 | ||
|
|
76f33c467b | ||
|
|
bf95366d54 | ||
|
|
dfe8cff1a7 | ||
|
|
7669977ddd | ||
|
|
5bb9bd83c3 | ||
|
|
04adefa570 | ||
|
|
e41890c456 | ||
|
|
371a406507 | ||
|
|
b6a968dae5 | ||
|
|
07f8dd3b99 | ||
|
|
8c52f63c4e | ||
|
|
3a62efa343 | ||
|
|
90b2621d5b | ||
|
|
bd9f7b73b8 | ||
|
|
30c26b919c | ||
|
|
c848379314 | ||
|
|
e50c22064f | ||
|
|
58fe65aad1 | ||
|
|
7b1e9d0f6b | ||
|
|
dd9773ce99 | ||
|
|
b6f8180b07 | ||
|
|
d81049d925 | ||
|
|
4c71a31628 | ||
|
|
2f377010ad | ||
|
|
d44cd9c41b | ||
|
|
7f7acd70f8 | ||
|
|
5285e38348 | ||
|
|
4af90803d5 | ||
|
|
8fe4b08911 | ||
|
|
82a461297d | ||
|
|
7c83b42fbb | ||
|
|
c75455936f | ||
|
|
2ddcf9fbe1 | ||
|
|
179f244e5d | ||
|
|
4b707f246f | ||
|
|
cfb58e87ac | ||
|
|
c3ba126ccf | ||
|
|
3826a68bfc | ||
|
|
36564204e6 | ||
|
|
196fb8ddf5 | ||
|
|
e251524164 | ||
|
|
673479e573 | ||
|
|
744301d1a1 | ||
|
|
db6e7fb5e0 | ||
|
|
cdcdee527d | ||
|
|
2fb97c51d2 | ||
|
|
ebc9e8a389 | ||
|
|
0c8042d140 | ||
|
|
20379f2da8 | ||
|
|
93b8e55537 | ||
|
|
4a9646d2ff | ||
|
|
e82cd4efe6 | ||
|
|
1fb9e01468 | ||
|
|
1d4779f0c2 | ||
|
|
39639485d2 | ||
|
|
4ad870b947 | ||
|
|
67d5b3ff86 | ||
|
|
8a1e9248df | ||
|
|
2c84003a83 | ||
|
|
408529cf83 | ||
|
|
094d928013 | ||
|
|
3067b55fe1 | ||
|
|
775469dbac | ||
|
|
aefd7f7787 | ||
|
|
c202f3e590 | ||
|
|
9f4cce5b00 | ||
|
|
dd246e6ab3 | ||
|
|
2ccfa6df4f | ||
|
|
c53a2cfd47 | ||
|
|
c808083f86 | ||
|
|
63e1547df4 | ||
|
|
bb5cb7ffdd | ||
|
|
6d9ec6b7ea | ||
|
|
ce16bf2003 | ||
|
|
c37616685c | ||
|
|
86b5e813f8 | ||
|
|
ea77b0dbb1 | ||
|
|
624c60be25 | ||
|
|
f7b42e8bcc | ||
|
|
5d18a5f03e | ||
|
|
d399e38325 | ||
|
|
c77c4858c0 | ||
|
|
5dd7623ac3 | ||
|
|
df8c577fc3 | ||
|
|
a3fec64205 | ||
|
|
33b3d3d4a6 | ||
|
|
c5df492df8 | ||
|
|
f21929e9e3 | ||
|
|
9f75dddd30 | ||
|
|
c4cb327b85 | ||
|
|
77e88cb85c | ||
|
|
70dd4ed129 | ||
|
|
34ab7a4887 | ||
|
|
2b8ca92365 | ||
|
|
c4578438d1 | ||
|
|
df67edc978 | ||
|
|
d48a969211 | ||
|
|
fc8e7d7387 | ||
|
|
4782bb27b9 | ||
|
|
f7484f2eb5 | ||
|
|
2161a524ab | ||
|
|
ac78166b2a | ||
|
|
3bdd163c78 | ||
|
|
10a18eb332 | ||
|
|
ee3451714d | ||
|
|
3acbaab880 | ||
|
|
1caad9f024 | ||
|
|
230a265b34 | ||
|
|
338c140f4c | ||
|
|
26a3415c47 | ||
|
|
6b410a9827 | ||
|
|
9df6d769e3 | ||
|
|
52a07b6239 |
No files matched your search
@@ -118,4 +118,16 @@ jobs:
|
||||
# debug info off: with it the test binaries of the app crates filled 27 GB of a runner's disk (#90)
|
||||
env:
|
||||
CARGO_PROFILE_TEST_DEBUG: "0"
|
||||
run: cargo test --locked -p raea-io-media -p raea-core-fonts -p raea-native -p raea-core-brief -p raea-core-k -p raea-bundle -p raea-app-check -p raea-app-check-flash -p raea-io-ffmpeg -p raea-app-workspace -p raea-app-tools -p raea-app-targets
|
||||
run: cargo test --locked -p raea-runtime-plugins -p raea-io-media -p raea-core-fonts -p raea-native -p raea-core-brief -p raea-core-k -p raea-bundle -p raea-app-check -p raea-app-check-flash -p raea-io-ffmpeg -p raea-app-workspace -p raea-app-tools -p raea-app-targets
|
||||
- name: Windows' and Linux's own (#169)
|
||||
# what a Windows or Linux user meets that no other step ran: QuickJS's Intl (raea-runtime-jsengine's
|
||||
# quickjs_formats_as_javascriptcore_does, on Linux), openh264 at --quality master (raea-io-soft), git found or
|
||||
# fetched (raea-io-assets), and raea's Node core under the agent shell (raea-native's tests/node.rs: Node's names
|
||||
# for the system, Windows' paths); tests/node.rs needs raea-native's modules feature and tests/quality.rs
|
||||
# raea-io-soft's h264
|
||||
env:
|
||||
CARGO_PROFILE_TEST_DEBUG: "0"
|
||||
run: |
|
||||
cargo test --locked -p raea-native --features modules --test node
|
||||
cargo test --locked -p raea-io-soft --features h264
|
||||
cargo test --locked -p raea-runtime-jsengine -p raea-io-assets
|
||||
@@ -217,9 +217,10 @@ jobs:
|
||||
retention-days: 3
|
||||
compression-level: 0
|
||||
|
||||
# Windows in Git's bash on GitHub's runner, with the Visual Studio Build Tools in its image (their image terms; we
|
||||
# accept no licence and download no Microsoft files). The C runtime is the DLL one (the VC++ redistributable): ort's
|
||||
# prebuilt ONNX Runtime is built against it, so crt-static doesn't link (LNK2019 on __imp_ symbols, 10-29).
|
||||
# Windows in Git's bash on GitHub's runner, with Visual Studio in its image. The C runtime is the DLL one: ONNX
|
||||
# Runtime is built against it (crt-static didn't link: LNK2019 on __imp_ symbols, 10-29), and Microsoft's
|
||||
# onnxruntime.dll imports it too, so the VC++ runtime's DLLs ship beside raea.exe from this image's Visual Studio
|
||||
# (tools/release/win-bundle.sh), as Microsoft documents for app-local deployment.
|
||||
windows:
|
||||
runs-on: ${{ (vars.RELEASE_WINDOWS_RUNNER && fromJSON(vars.RELEASE_WINDOWS_RUNNER)) || 'windows-latest' }}
|
||||
timeout-minutes: 350
|
||||
@@ -329,12 +330,20 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: bash tools/release/promoted-bins.sh "$RAEA_PROMOTED_FROM" target/dist
|
||||
# which DLLs raea needs from the machine (the CRT's come from the VC++ redistributable)
|
||||
# ONNX Runtime as Microsoft builds it (MIT), beside raea.exe, which loads it when a model first runs (#110): the
|
||||
# static runtime ort links by default is built for AVX2 and stopped raea.exe at start on CPUs without it
|
||||
- name: ONNX Runtime (tools/release/onnxruntime.sh)
|
||||
run: bash tools/release/onnxruntime.sh target/dist
|
||||
# and what a PC with nothing installed and no downloads needs beside raea.exe: the VC++ runtime (from this
|
||||
# runner's Visual Studio), FFmpeg (raea's LGPL build) and uv, each with its licence
|
||||
- name: The Windows bundle (tools/release/win-bundle.sh)
|
||||
run: bash tools/release/win-bundle.sh target/dist
|
||||
# which DLLs raea needs from the machine (the CRT's now ship beside it: win-bundle.sh)
|
||||
- name: What raea.exe imports
|
||||
run: |
|
||||
{ echo '### what raea.exe, raea_bundle.dll and raea-perceive.exe import'; echo '```'
|
||||
{ echo '### what raea.exe, raea_bundle.dll, raea-perceive.exe and onnxruntime.dll import'; echo '```'
|
||||
dumpbin=$(ls "/c/Program Files/Microsoft Visual Studio"/*/*/VC/Tools/MSVC/*/bin/HostX64/x64/dumpbin.exe | head -1)
|
||||
"$dumpbin" -nologo -dependents target/dist/raea.exe target/dist/raea_bundle.dll target/dist/raea-perceive.exe | grep -iE '\.dll$|Dump of' | sed 's/^ *//'
|
||||
"$dumpbin" -nologo -dependents target/dist/raea.exe target/dist/raea_bundle.dll target/dist/raea-perceive.exe target/dist/onnxruntime.dll target/dist/ffmpeg.exe | grep -iE '\.dll$|Dump of' | sed 's/^ *//'
|
||||
echo '```'; } | tee -a "$GITHUB_STEP_SUMMARY" || true
|
||||
# release.sh's checks render on Mesa's lavapipe (software Vulkan, MIT; on the runner only, never in the zip): the
|
||||
# runner has no GPU, and WARP, Windows' own software DX12, crashes compiling one of Bevy's compute shaders there
|
||||
@@ -415,6 +424,7 @@ jobs:
|
||||
lfs: false
|
||||
sparse-checkout: |
|
||||
tools/release-check.sh
|
||||
tools/release/win-bundle.files
|
||||
tools/release/lavapipe.sh
|
||||
sparse-checkout-cone-mode: false
|
||||
path: check
|
||||
@@ -428,7 +438,8 @@ jobs:
|
||||
run: |
|
||||
set -e
|
||||
v=${TAG#v}
|
||||
cp check/tools/release-check.sh "$RUNNER_TEMP/"
|
||||
# and the list of what bin\ must carry, where release-check.sh looks for it (release/ beside it)
|
||||
cp check/tools/release-check.sh "$RUNNER_TEMP/" && mkdir -p "$RUNNER_TEMP/release" && cp check/tools/release/win-bundle.files "$RUNNER_TEMP/release/"
|
||||
rm -rf check
|
||||
cd "$RUNNER_TEMP/zip"
|
||||
sha256sum -c "raea-$v-windows-x86_64.zip.sha256"
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
# FFmpeg for Windows as raea ships it (tools/release/ffmpeg-win.sh): built on Linux with mingw-w64 and published once
|
||||
# as the prerelease tools-ffmpeg-<version>-lgpl, with FFmpeg's source tarball, its signature and the script, which are
|
||||
# its complete source (LGPL 2.1 or later). io/assets/src/setup.rs pins the zip by its
|
||||
# sha256, so a published zip is never replaced: a run whose release already holds one only builds it and says
|
||||
# whether its own sha256 differs.
|
||||
name: tools-ffmpeg
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths: [tools/release/ffmpeg-win.sh, .github/workflows/tools-ffmpeg.yml]
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: false
|
||||
# the x86_64 cross compiler only, and non-interactive: an install that asks (needrestart, debconf) waits forever.
|
||||
# The runner's own EC2 mirror has trickled (35 MB in 11 minutes, 11-19), so apt reads Ubuntu's archive first
|
||||
# and Azure's mirror after it, gives up on a stalled request and retries.
|
||||
- name: mingw-w64
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
NEEDRESTART_MODE: a
|
||||
run: |
|
||||
printf 'http://archive.ubuntu.com/ubuntu/\tpriority:1\nhttp://azure.archive.ubuntu.com/ubuntu/\tpriority:2\n' | sudo tee /etc/apt/apt-mirrors.txt
|
||||
o="-o Acquire::Retries=5 -o Acquire::http::Timeout=30"
|
||||
sudo -E apt-get $o update -q
|
||||
sudo -E apt-get $o install -y -q --no-install-recommends gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 libz-mingw-w64-dev nasm make pkg-config xz-utils zip
|
||||
timeout-minutes: 25
|
||||
- name: build
|
||||
run: bash tools/release/ffmpeg-win.sh out
|
||||
- name: publish (once)
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
v=$(sed -n 's/^v=//p' tools/release/ffmpeg-win.sh)
|
||||
tag=tools-ffmpeg-$v-lgpl; zip=ffmpeg-$v-lgpl-win64.zip
|
||||
if gh release view "$tag" --json assets -q '.assets[].name' 2>/dev/null | grep -qx "$zip"; then
|
||||
echo "$tag already has $zip (never replaced); this run's: $(cat out/$zip.sha256)"; exit 0
|
||||
fi
|
||||
curl -fsSL -o "out/ffmpeg-$v.tar.xz.asc" "https://ffmpeg.org/releases/ffmpeg-$v.tar.xz.asc"
|
||||
cp tools/release/ffmpeg-win.sh out/
|
||||
gh release view "$tag" >/dev/null 2>&1 || gh release create "$tag" --prerelease --title "FFmpeg $v for Windows (LGPL), as raea ships it" \
|
||||
--notes "FFmpeg $v cross-built for Windows x64 by tools/release/ffmpeg-win.sh: static, FFmpeg's own code, zlib and libvpx's decoders (BSD), LGPL 2.1 or later; its H.264 encoder is Windows' own (Media Foundation). Its complete source is ffmpeg-$v.tar.xz (with FFmpeg's signature), the libvpx tarball and ffmpeg-win.sh, attached here. raea ships it beside raea.exe on Windows and fetches it where it isn't."
|
||||
gh release upload "$tag" "out/$zip" "out/$zip.sha256" "out/ffmpeg-$v.tar.xz" "out/ffmpeg-$v.tar.xz.asc" out/libvpx-*.tar.gz out/ffmpeg-win.sh
|
||||
@@ -0,0 +1,34 @@
|
||||
# The complete corresponding source of the Git for Windows the Windows app ships (tools/release/git-sources.sh),
|
||||
# published once as the prerelease tools-git-<tag>-sources, which the app's git\SOURCE.txt names: GPLv2 section 3
|
||||
# asks whoever distributes Git to make it available, and dugite-native's own repository isn't all of it (Git for
|
||||
# Windows' MSYS2 runtime, bash, curl and the rest are built from their own source packages). A run whose release
|
||||
# already holds the archive changes nothing.
|
||||
name: tools-git-sources
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths: [tools/release/git-sources.sh, .github/workflows/tools-git-sources.yml]
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
sources:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 60
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: false
|
||||
- name: publish (once)
|
||||
run: |
|
||||
t=$(sed -n 's/^tag=//p' tools/release/git-sources.sh)
|
||||
tag=tools-git-$t-sources; tar=git-for-windows-$t-sources.tar
|
||||
if gh release view "$tag" --json assets -q '.assets[].name' 2>/dev/null | grep -qx "$tar"; then
|
||||
echo "$tag already has $tar"; exit 0
|
||||
fi
|
||||
bash tools/release/git-sources.sh out
|
||||
cp tools/release/git-sources.sh out/
|
||||
gh release view "$tag" >/dev/null 2>&1 || gh release create "$tag" --prerelease --title "Git for Windows ($t) sources, as raea's Windows app ships it" \
|
||||
--notes "The complete corresponding source of the Git for Windows (dugite-native $t) that raea's Windows app ships in its git folder: each package of its etc/package-versions.txt as the source package it was built from, from Git for Windows' pacman repository or MSYS2's source mirror (SOURCES.tsv inside says which), collected by git-sources.sh, attached here. raea runs Git as a separate program."
|
||||
gh release upload "$tag" "out/$tar" "out/$tar.sha256" out/git-sources.sh
|
||||
+7
-1
@@ -5,7 +5,10 @@ target/
|
||||
meaning/bench/temporal/out/*.npz
|
||||
__pycache__/
|
||||
# every package's installed dependencies, wherever bun or npm puts them
|
||||
node_modules/
|
||||
# a package folder, or a link to one (sdk/blender and sdk/godot link sdk/raea's)
|
||||
node_modules
|
||||
# TypeScript's incremental build record
|
||||
*.tsbuildinfo
|
||||
engine/media/golden/
|
||||
|
||||
# tools/release.sh writes releases here
|
||||
@@ -101,5 +104,8 @@ sdk/raea/.scratch-*/
|
||||
|
||||
# the Tripo CLI writes its last task id into the directory it runs in
|
||||
.tripo/
|
||||
# examples/materials/wear: its house is made by make-house.ts (media/) and baked at render time (assets/wear/)
|
||||
/examples/materials/wear/media/
|
||||
/examples/materials/wear/assets/
|
||||
# tools/bevy-parity links each example folder's assets/ to Bevy's checkout at run time (an absolute, per-machine path)
|
||||
/sdk/raea/bench/bevy-parity/**/assets
|
||||
Generated
+223
-161
@@ -761,7 +761,7 @@ version = "0.38.0+1.3.281"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
"libloading 0.8.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2668,7 +2668,6 @@ dependencies = [
|
||||
"bevy_utils",
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"ctt",
|
||||
"ddsfile",
|
||||
"futures-lite",
|
||||
"guillotiere",
|
||||
@@ -4806,7 +4805,7 @@ checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
"libloading",
|
||||
"libloading 0.8.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5567,100 +5566,6 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctt"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c119cc328a986d0bae3a1753941595f1dc6a0f2d938b5f49edf8937bd606fa9"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"ctt-astcenc",
|
||||
"ctt-bc7enc-rdo",
|
||||
"ctt-compressonator",
|
||||
"ctt-etcpak",
|
||||
"ctt-intel-texture-compressor",
|
||||
"ddsfile",
|
||||
"fast_image_resize",
|
||||
"flate2",
|
||||
"half",
|
||||
"ktx2",
|
||||
"log",
|
||||
"miniz_oxide 0.8.9",
|
||||
"profiling",
|
||||
"thiserror 2.0.21",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctt-astcenc"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24a806826f523401c1c8a9afded1c5625f005fd8e6567ceba2fe6254d8c59e3e"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cc",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctt-bc7enc-rdo"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a4ad8fcbfcafc39a9e02bfb344fd517dd0bcd7adabcc25de19e9703eb3b99a3"
|
||||
dependencies = [
|
||||
"ctt-bc7enc-rdo-prebuilt",
|
||||
"ispc-build-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctt-bc7enc-rdo-prebuilt"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f27a2776bbafcc2d335c0621aa9dbd40ecfecdb02a636d3fcd2a2379f96f7472"
|
||||
dependencies = [
|
||||
"ispc-build-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctt-compressonator"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21eefd5a6f96023adc6bc8c95de1afccded8f958afdbf7e02fa98bf325c41058"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctt-etcpak"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c6025bf0456c4a8c0a693c803eb7368f045f74709adc6b271223ca7f76898ab"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctt-intel-texture-compressor"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "452985b4223f1a68da0722161ff9a7dbb33bcb32cd30f341b541fd980c58fb26"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"ctt-intel-texture-compressor-prebuilt",
|
||||
"ispc-build-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctt-intel-texture-compressor-prebuilt"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa4031e53991b02e2b9fb903f3bb458ab9a2afcec99320800d4d4092dc43d33c"
|
||||
dependencies = [
|
||||
"ispc-build-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cursor-icon"
|
||||
version = "1.2.0"
|
||||
@@ -6320,7 +6225,7 @@ version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
"libloading 0.8.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6839,18 +6744,6 @@ dependencies = [
|
||||
"arrayvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fast_image_resize"
|
||||
version = "6.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9c50201dc184ba6553da1695aac20a042efffbe2d84542cee31917c86c3ab1e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"document-features",
|
||||
"num-traits",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastbloom"
|
||||
version = "0.17.0"
|
||||
@@ -8684,15 +8577,6 @@ version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "ispc-build-utils"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4cda913ddb107b9bb5c46769855e3849e62daa52fc7e70de0080ca4e6cfd030"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
@@ -8895,7 +8779,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"libloading",
|
||||
"libloading 0.8.9",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
@@ -9171,6 +9055,16 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1832accd5a4ca2795ace4d05d15c4039be15b62d3b950eff99746a990e3cc10"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.16"
|
||||
@@ -11989,6 +11883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4336a1e2b38848325241c72889086886004e589b7c74f335e60a8e8db5138a0b"
|
||||
dependencies = [
|
||||
"half",
|
||||
"libloading 0.9.1",
|
||||
"ndarray 0.17.2",
|
||||
"ort-sys",
|
||||
"smallvec",
|
||||
@@ -13747,22 +13642,23 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-scene",
|
||||
"raea-app-layers",
|
||||
"raea-io-alpha",
|
||||
"raea-io-capcut",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-runtime-bundle",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-check"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-app-check-cause",
|
||||
"raea-app-check-flash",
|
||||
"raea-app-check-inbox",
|
||||
"raea-app-check-read",
|
||||
"raea-app-check-text",
|
||||
"raea-core-brief",
|
||||
"raea-core-facts",
|
||||
"raea-io-ffmpeg",
|
||||
@@ -13772,6 +13668,15 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-check-cause"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-check-flash"
|
||||
version = "0.1.0"
|
||||
@@ -13784,6 +13689,28 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-check-read"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"raea-app-media",
|
||||
"raea-io-ffmpeg",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-sys-measure",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-check-text"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-core-facts",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-ci"
|
||||
version = "0.1.0"
|
||||
@@ -13799,6 +13726,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-app-check",
|
||||
"raea-app-check-text",
|
||||
"raea-app-notes",
|
||||
"raea-app-registry",
|
||||
"raea-core-brief",
|
||||
@@ -13890,6 +13818,19 @@ dependencies = [
|
||||
"ureq 2.12.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-layers"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-core-scene",
|
||||
"raea-io-alpha",
|
||||
"raea-io-media",
|
||||
"raea-runtime-bundle",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-media"
|
||||
version = "0.1.0"
|
||||
@@ -13904,11 +13845,22 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-motion"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-io-home",
|
||||
"raea-runtime-bundle",
|
||||
"raea-sys-kimodo",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-notes"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-core-facts",
|
||||
"raea-io-ffmpeg",
|
||||
"raea-io-home",
|
||||
"raea-io-trace",
|
||||
"serde",
|
||||
@@ -13986,13 +13938,13 @@ name = "raea-app-tools"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-app-motion",
|
||||
"raea-io-assets",
|
||||
"raea-io-gen",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-runtime-bundle",
|
||||
"raea-runtime-export",
|
||||
"raea-sys-kimodo",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -14005,6 +13957,7 @@ dependencies = [
|
||||
"raea-app-registry",
|
||||
"raea-core-brief",
|
||||
"raea-core-facts",
|
||||
"raea-io-assets",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -14231,6 +14184,7 @@ dependencies = [
|
||||
"raea-app-fingerprint",
|
||||
"raea-app-game",
|
||||
"raea-app-judge",
|
||||
"raea-app-layers",
|
||||
"raea-app-media",
|
||||
"raea-app-notes",
|
||||
"raea-app-play",
|
||||
@@ -14248,6 +14202,7 @@ dependencies = [
|
||||
"raea-io-media",
|
||||
"raea-io-npm",
|
||||
"raea-io-trace",
|
||||
"raea-light",
|
||||
"raea-native",
|
||||
"raea-neural",
|
||||
"raea-render",
|
||||
@@ -14257,6 +14212,7 @@ dependencies = [
|
||||
"raea-runtime-plugins",
|
||||
"raea-runtime-react",
|
||||
"raea-runtime-sound",
|
||||
"raea-runtime-wear",
|
||||
"raea-sys-index",
|
||||
"regex",
|
||||
"serde",
|
||||
@@ -14525,6 +14481,7 @@ dependencies = [
|
||||
name = "raea-io-ffmpeg"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-io-assets",
|
||||
"raea-io-codec",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -14687,6 +14644,16 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-light"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-io-home",
|
||||
"raea-runtime-bundle",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-modules"
|
||||
version = "0.1.0"
|
||||
@@ -14873,6 +14840,7 @@ dependencies = [
|
||||
"raea-sys-grass",
|
||||
"raea-sys-grid",
|
||||
"raea-sys-hold",
|
||||
"raea-sys-lod",
|
||||
"raea-sys-look",
|
||||
"raea-sys-matchmove",
|
||||
"raea-sys-material",
|
||||
@@ -14893,7 +14861,6 @@ dependencies = [
|
||||
"raea-sys-three-shader",
|
||||
"raea-sys-viewbox",
|
||||
"raea-sys-volume",
|
||||
"raea-sys-wear",
|
||||
"serde_json",
|
||||
"wgpu",
|
||||
]
|
||||
@@ -14906,6 +14873,7 @@ dependencies = [
|
||||
"objc2 0.6.5",
|
||||
"objc2-metal 0.3.2",
|
||||
"objc2-metal-fx",
|
||||
"raea-io-home",
|
||||
"wgpu",
|
||||
]
|
||||
|
||||
@@ -15079,7 +15047,7 @@ name = "raea-runtime-bundle-lib"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"libloading",
|
||||
"libloading 0.8.9",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -15100,6 +15068,7 @@ dependencies = [
|
||||
"raea-io-net",
|
||||
"raea-native",
|
||||
"raea-runtime-plugins",
|
||||
"raea-runtime-wear",
|
||||
"raea-sys-fonts",
|
||||
"raea-sys-grab",
|
||||
"raea-sys-mix",
|
||||
@@ -15185,6 +15154,7 @@ dependencies = [
|
||||
"raea-io-net",
|
||||
"raea-page",
|
||||
"raea-render",
|
||||
"raea-runtime-segments",
|
||||
"raea-runtime-view",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-k",
|
||||
@@ -15286,6 +15256,8 @@ dependencies = [
|
||||
name = "raea-runtime-jsengine"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"miniz_oxide 0.8.9",
|
||||
"objc2 0.6.5",
|
||||
"raea-io-home",
|
||||
"rquickjs",
|
||||
@@ -15308,6 +15280,7 @@ dependencies = [
|
||||
"raea-runtime-export",
|
||||
"raea-runtime-page",
|
||||
"raea-runtime-react",
|
||||
"raea-runtime-scene",
|
||||
"raea-runtime-sound",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-hold",
|
||||
@@ -15429,8 +15402,8 @@ dependencies = [
|
||||
"raea-runtime-look",
|
||||
"raea-runtime-scene2d",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-layers",
|
||||
"raea-sys-procmat",
|
||||
"raea-sys-wear",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -15452,6 +15425,7 @@ dependencies = [
|
||||
"raea-core-program",
|
||||
"raea-runtime-plugins",
|
||||
"raea-sys-compute",
|
||||
"raea-sys-copies",
|
||||
"raea-sys-fog",
|
||||
"raea-sys-fog-half",
|
||||
"raea-sys-frame",
|
||||
@@ -15464,6 +15438,16 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-segments"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"muxide",
|
||||
"raea-io-codec",
|
||||
"raea-io-media",
|
||||
"re_mp4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-shared"
|
||||
version = "0.1.0"
|
||||
@@ -15552,6 +15536,18 @@ dependencies = [
|
||||
"wgpu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-wear"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-io-assets",
|
||||
"raea-native",
|
||||
"raea-sys-bake",
|
||||
"raea-sys-glb",
|
||||
"raea-sys-weathering",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-world"
|
||||
version = "0.1.0"
|
||||
@@ -15622,6 +15618,7 @@ name = "raea-sys-bake"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-io-assets",
|
||||
"raea-io-home",
|
||||
"rapier3d",
|
||||
"serde_json",
|
||||
@@ -15707,6 +15704,25 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-copies"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-sys-material",
|
||||
"raea-sys-shader",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-damage"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parry3d",
|
||||
"raea-core-ease",
|
||||
"raea-sys-touch",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-environment"
|
||||
version = "0.1.0"
|
||||
@@ -15718,6 +15734,13 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-exposure"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parry3d",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-filters"
|
||||
version = "0.1.0"
|
||||
@@ -15762,6 +15785,7 @@ dependencies = [
|
||||
"dunce",
|
||||
"fastrand",
|
||||
"image",
|
||||
"raea-io-ffmpeg",
|
||||
"raea-sys-columns",
|
||||
"raea-sys-fingerprint",
|
||||
"serde",
|
||||
@@ -15791,6 +15815,17 @@ dependencies = [
|
||||
"wgpu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-foliage"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"parry3d",
|
||||
"raea-core-ease",
|
||||
"raea-sys-glb",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-fonts"
|
||||
version = "0.1.0"
|
||||
@@ -15833,6 +15868,7 @@ dependencies = [
|
||||
"raea-core-scene",
|
||||
"raea-io-media",
|
||||
"raea-sys-layers",
|
||||
"raea-sys-shots",
|
||||
"serde_json",
|
||||
"wgpu",
|
||||
]
|
||||
@@ -15849,6 +15885,13 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-glb"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-grab"
|
||||
version = "0.1.0"
|
||||
@@ -15941,6 +15984,7 @@ name = "raea-sys-kimodo"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"mlx-rs",
|
||||
"raea-io-home",
|
||||
"raea-sys-ml",
|
||||
@@ -15981,6 +16025,13 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-lod"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-look"
|
||||
version = "0.1.0"
|
||||
@@ -16052,10 +16103,18 @@ dependencies = [
|
||||
"cpal 0.15.3",
|
||||
"firewheel",
|
||||
"raea-io-media",
|
||||
"raea-sys-mix-level",
|
||||
"raea-sys-tone",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-mix-level"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-io-media",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-ml"
|
||||
version = "0.1.0"
|
||||
@@ -16196,6 +16255,14 @@ dependencies = [
|
||||
"wgpu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-runoff"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parry3d",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-sampler"
|
||||
version = "0.1.0"
|
||||
@@ -16240,6 +16307,14 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-shots"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-program",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-song"
|
||||
version = "0.1.0"
|
||||
@@ -16324,6 +16399,13 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-touch"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parry3d",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-tweak"
|
||||
version = "0.1.0"
|
||||
@@ -16370,12 +16452,20 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-wear"
|
||||
name = "raea-sys-weathering"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-program",
|
||||
"image",
|
||||
"parry3d",
|
||||
"raea-core-meshcheck",
|
||||
"raea-sys-damage",
|
||||
"raea-sys-exposure",
|
||||
"raea-sys-glb",
|
||||
"raea-sys-runoff",
|
||||
"raea-sys-touch",
|
||||
"rayon",
|
||||
"serde_json",
|
||||
"sha2 0.10.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -17799,7 +17889,7 @@ dependencies = [
|
||||
"image",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"libloading",
|
||||
"libloading 0.8.9",
|
||||
"objc2 0.5.3",
|
||||
"objc2 0.6.5",
|
||||
"objc2-app-kit 0.2.2",
|
||||
@@ -22241,7 +22331,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"khronos-egl",
|
||||
"libc",
|
||||
"libloading",
|
||||
"libloading 0.8.9",
|
||||
"log",
|
||||
"naga",
|
||||
"naga-types",
|
||||
@@ -23094,7 +23184,7 @@ dependencies = [
|
||||
"as-raw-xcb-connection",
|
||||
"gethostname",
|
||||
"libc",
|
||||
"libloading",
|
||||
"libloading 0.8.9",
|
||||
"once_cell",
|
||||
"rustix 1.1.5",
|
||||
"x11rb-protocol",
|
||||
@@ -23641,34 +23731,6 @@ dependencies = [
|
||||
"futures-io",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb02c3132d251ab1606e9fc913a7da6c6ed08cc263df15edf082e1dc497d157"
|
||||
dependencies = [
|
||||
"zstd-safe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd-safe"
|
||||
version = "7.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c8ea04668f5de8d8d51051714ba560c9536519cadcdb8829bba4fe2ad159b03"
|
||||
dependencies = [
|
||||
"zstd-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd-sys"
|
||||
version = "2.1.2+zstd.1.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zune-core"
|
||||
version = "0.5.3"
|
||||
|
||||
+19
-1
@@ -39,6 +39,7 @@ members = [
|
||||
"engine/bundle",
|
||||
"engine/cli",
|
||||
"engine/neural",
|
||||
"engine/light",
|
||||
"engine/modules",
|
||||
"engine/native",
|
||||
"io/npm",
|
||||
@@ -79,6 +80,7 @@ members = [
|
||||
"systems/k",
|
||||
"systems/tone",
|
||||
"systems/mix",
|
||||
"systems/mix/level",
|
||||
"systems/ml",
|
||||
"systems/mlx",
|
||||
"systems/kimodo",
|
||||
@@ -101,12 +103,18 @@ members = [
|
||||
"systems/canvas",
|
||||
"systems/tweak",
|
||||
"systems/filters",
|
||||
"systems/wear",
|
||||
"systems/weathering",
|
||||
"systems/runoff",
|
||||
"systems/touch",
|
||||
"systems/exposure",
|
||||
"systems/damage",
|
||||
"systems/glb",
|
||||
"systems/procmat",
|
||||
"systems/page",
|
||||
"systems/page-net",
|
||||
"systems/page-ops",
|
||||
"systems/frame",
|
||||
"systems/shots",
|
||||
"systems/hold",
|
||||
"systems/body",
|
||||
"systems/grab",
|
||||
@@ -117,9 +125,12 @@ members = [
|
||||
"systems/text3d",
|
||||
"runtime/gpuframe",
|
||||
"runtime/scene3d",
|
||||
"systems/copies",
|
||||
"systems/screen",
|
||||
"systems/matchmove",
|
||||
"systems/grid",
|
||||
"systems/lod",
|
||||
"systems/foliage",
|
||||
"systems/viewbox",
|
||||
"systems/rendermap",
|
||||
"systems/meshseq",
|
||||
@@ -142,6 +153,7 @@ members = [
|
||||
"runtime/view",
|
||||
"runtime/world",
|
||||
"runtime/encode",
|
||||
"runtime/segments",
|
||||
"runtime/plugins",
|
||||
"runtime/input",
|
||||
"tools/perceive",
|
||||
@@ -164,6 +176,7 @@ members = [
|
||||
"engine/shape-web",
|
||||
"runtime/calls",
|
||||
"runtime/shots",
|
||||
"runtime/wear",
|
||||
"runtime/canvas",
|
||||
"runtime/export",
|
||||
"runtime/live",
|
||||
@@ -175,8 +188,11 @@ members = [
|
||||
"runtime/scene2d",
|
||||
"runtime/shared",
|
||||
"apps/check",
|
||||
"apps/check/cause",
|
||||
"apps/check/flash",
|
||||
"apps/check/inbox",
|
||||
"apps/check/read",
|
||||
"apps/check/text",
|
||||
"apps/direction",
|
||||
"apps/notes",
|
||||
"apps/fingerprint",
|
||||
@@ -185,6 +201,7 @@ members = [
|
||||
"apps/workspace/registry",
|
||||
"apps/ci",
|
||||
"apps/tools",
|
||||
"apps/motion",
|
||||
"apps/engines",
|
||||
"apps/interchange",
|
||||
"apps/judge",
|
||||
@@ -193,6 +210,7 @@ members = [
|
||||
"apps/targets",
|
||||
"apps/game",
|
||||
"apps/capcut",
|
||||
"apps/layers",
|
||||
"apps/play",
|
||||
"tools/sdk-props",
|
||||
"tools/hands-audit",
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
ctt 0.5.0 ships no licence file of its own. Its Cargo.toml declares MIT OR Apache-2.0 OR Zlib, by The ctt developers.
|
||||
|
||||
---- Apache-2.0: the text is LICENSES/texts/Apache-2.0.txt ----
|
||||
|
||||
---- MIT ----
|
||||
|
||||
Copyright (c) The ctt developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---- Zlib ----
|
||||
|
||||
Copyright (c) The ctt developers
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held
|
||||
liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter
|
||||
it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If
|
||||
you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not
|
||||
required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original
|
||||
software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
@@ -1,175 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
@@ -1,178 +0,0 @@
|
||||
Copyright (C) 2018-2021 Binomial LLC
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -1,20 +0,0 @@
|
||||
ctt-bc7enc-rdo-prebuilt 0.5.0 ships no licence file of its own. Its Cargo.toml declares (MIT OR Apache-2.0) AND Apache-2.0, by The ctt developers, Rich Geldreich <[email protected]>.
|
||||
|
||||
---- Apache-2.0: the text is LICENSES/texts/Apache-2.0.txt ----
|
||||
|
||||
---- MIT ----
|
||||
|
||||
Copyright (c) The ctt developers, Rich Geldreich <[email protected]>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,26 +0,0 @@
|
||||
etcpak, an extremely fast ETC compression utility (https://github.com/wolfpld/etcpak)
|
||||
|
||||
Copyright (c) 2013-2026, Bartosz Taudul <wolf@nereid.pl>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,176 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Graham Wihlidal
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,19 +0,0 @@
|
||||
Copyright 2017 Intel Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,20 +0,0 @@
|
||||
ctt-intel-texture-compressor-prebuilt 0.5.0 ships no licence file of its own. Its Cargo.toml declares (MIT OR Apache-2.0) AND MIT, by The ctt developers, Traverse Research <[email protected]>, Graham Wihlidal <[email protected]>, Intel Corporation.
|
||||
|
||||
---- Apache-2.0: the text is LICENSES/texts/Apache-2.0.txt ----
|
||||
|
||||
---- MIT ----
|
||||
|
||||
Copyright (c) The ctt developers, Traverse Research <[email protected]>, Graham Wihlidal <[email protected]>, Intel Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright (c) 2021 Kirill Kuzminykh
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Kirill Kuzminykh
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2020 Andrew Straw
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,25 +0,0 @@
|
||||
Copyright (c) 2020 Andrew D. Straw
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2020 Andrew Straw
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,25 +0,0 @@
|
||||
Copyright (c) 2020 Andrew D. Straw
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,37 +0,0 @@
|
||||
ispc-build-utils 0.5.0 ships no licence file of its own. Its Cargo.toml declares MIT OR Apache-2.0 OR Zlib, by The ctt developers.
|
||||
|
||||
---- Apache-2.0: the text is LICENSES/texts/Apache-2.0.txt ----
|
||||
|
||||
---- MIT ----
|
||||
|
||||
Copyright (c) The ctt developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---- Zlib ----
|
||||
|
||||
Copyright (c) The ctt developers
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held
|
||||
liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter
|
||||
it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If
|
||||
you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not
|
||||
required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original
|
||||
software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
@@ -1,28 +0,0 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2026, Alexandre Bury
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,28 +0,0 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2026, Alexandre Bury
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,28 +0,0 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2026, Alexandre Bury
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,32 +0,0 @@
|
||||
The auto-generated bindings are under the 3-clause BSD license:
|
||||
|
||||
BSD License
|
||||
|
||||
For Zstandard software
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook, nor Meta, nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -20,8 +20,20 @@ animato (MIT OR Apache-2.0), usvg and resvg (Apache-2.0 OR MIT), mediabunny (MPL
|
||||
|
||||
The Windows build (docs/ports.feature PT20) adds: junction 1.4.2 (MIT, node_modules' links in io/npm) and windows-sys
|
||||
0.61.2 (Microsoft, MIT OR Apache-2.0, in io/trace); every build has dunce 1.0.5 (CC0-1.0 OR MIT-0 OR Apache-2.0, plain
|
||||
paths for Windows in runtime/bundle). It ships none of Microsoft's C runtime or SDK files: the runtime comes from the
|
||||
Microsoft Visual C++ Redistributable, installed on the machine.
|
||||
paths for Windows in runtime/bundle). Its bin\ also carries, each with its licence beside it (tools/release/win-bundle.sh):
|
||||
Microsoft's Visual C++ runtime (vcruntime140.dll, vcruntime140_1.dll, msvcp140.dll, msvcp140_1.dll), redistributed
|
||||
under Microsoft's Visual Studio licence terms; ONNX Runtime's onnxruntime.dll (Microsoft, MIT);
|
||||
FFmpeg 9.0.2 (ffmpeg.exe, ffprobe.exe; LGPL-2.1-or-later), built from FFmpeg's release with FFmpeg's own code, zlib
|
||||
and libvpx 1.17.0's decoders (BSD-3-Clause with the WebM project's patent grant: libvpx-LICENSE.txt,
|
||||
libvpx-PATENTS.txt) by tools/release/ffmpeg-win.sh, its H.264 encoder Windows' own (Media Foundation), its source
|
||||
published as the release tools-ffmpeg-9.0.2-lgpl;
|
||||
uv (uv.exe; Astral, MIT OR Apache-2.0).
|
||||
The Windows app adds Git for Windows with Git LFS (dugite-native; GPLv2 and its parts' licences, in git\), which raea
|
||||
runs as a separate program; its complete corresponding source is published as the release tools-git-<tag>-sources.
|
||||
raea.exe, on a PC with no Git, fetches the same build once into its tools cache (io/assets git()).
|
||||
The Windows and Linux builds' JavaScript engine, QuickJS (rquickjs, MIT), carries FormatJS's Intl polyfills (MIT,
|
||||
Copyright FormatJS) and the Unicode CLDR locale data they're made with (Unicode-3.0), packed in
|
||||
runtime/jsengine/js/intl.pack; both licences are in runtime/jsengine/js/intl/LICENSE-FormatJS.md and in the pack.
|
||||
The native target (engine/rune, docs/targets.feature) builds on Rune (https://github.com/anomalyco/rune, Copyright
|
||||
2026 Anomaly, MIT; LICENSES/rune-0.0.1/repository-LICENSE): rune, rune-kit and their crates, by a pinned rev.
|
||||
|
||||
@@ -155,14 +167,6 @@ LICENSES/<crate>-<version>/.
|
||||
cssparser 0.37.0: MPL-2.0
|
||||
csv-core 0.1.13: Unlicense/MIT
|
||||
csv 1.4.0: Unlicense/MIT
|
||||
ctt-astcenc 0.5.0: (MIT OR Apache-2.0 OR Zlib) AND Apache-2.0
|
||||
ctt-bc7enc-rdo-prebuilt 0.5.0: (MIT OR Apache-2.0) AND Apache-2.0
|
||||
ctt-bc7enc-rdo 0.5.0: (MIT OR Apache-2.0 OR Zlib) AND Apache-2.0
|
||||
ctt-compressonator 0.5.0: (MIT OR Apache-2.0 OR Zlib) AND MIT
|
||||
ctt-etcpak 0.5.0: (MIT OR Apache-2.0 OR Zlib) AND BSD-3-Clause
|
||||
ctt-intel-texture-compressor-prebuilt 0.5.0: (MIT OR Apache-2.0) AND MIT
|
||||
ctt-intel-texture-compressor 0.5.0: (MIT OR Apache-2.0) AND MIT
|
||||
ctt 0.5.0: MIT OR Apache-2.0 OR Zlib
|
||||
dashmap 6.2.1: MIT
|
||||
default-struct-builder 0.5.1: MIT OR Apache-2.0
|
||||
deluxe-core 0.5.0: MIT
|
||||
@@ -188,7 +192,6 @@ LICENSES/<crate>-<version>/.
|
||||
enumflags2 0.7.12: MIT OR Apache-2.0
|
||||
epaint_default_fonts 0.36.2: (MIT OR Apache-2.0) AND OFL-1.1 AND Ubuntu-font-1.0
|
||||
epaint 0.36.2: MIT OR Apache-2.0
|
||||
fast_image_resize 6.1.0: MIT OR Apache-2.0
|
||||
fastbloom 0.17.0: MIT OR Apache-2.0
|
||||
fastnoise-lite 1.1.1: MIT
|
||||
fid-rs 0.2.0: MIT OR Apache-2.0
|
||||
@@ -219,14 +222,11 @@ LICENSES/<crate>-<version>/.
|
||||
i_overlay 4.5.2: MIT OR Apache-2.0
|
||||
i_shape 1.18.0: MIT
|
||||
i_tree 0.18.0: MIT
|
||||
iana-time-zone-haiku 0.1.2: MIT OR Apache-2.0
|
||||
iana-time-zone 0.1.65: MIT OR Apache-2.0
|
||||
ilattice 0.1.0: MIT OR Apache-2.0
|
||||
imagesize 0.13.0: MIT
|
||||
inout 0.1.4: MIT OR Apache-2.0
|
||||
interpolation 0.3.0: MIT
|
||||
is-terminal 0.4.17: MIT
|
||||
ispc-build-utils 0.5.0: MIT OR Apache-2.0 OR Zlib
|
||||
itertools 0.10.5: MIT/Apache-2.0
|
||||
iyes_progress 0.18.0: MIT OR Apache-2.0
|
||||
jzon 0.12.5: MIT/Apache-2.0
|
||||
@@ -428,9 +428,6 @@ LICENSES/<crate>-<version>/.
|
||||
zbus 6.2.1: MIT
|
||||
zcheapstr 1.1.0: MIT
|
||||
zruntime 0.2.2: MIT
|
||||
zstd-safe 7.4.0: BSD-3-Clause
|
||||
zstd-sys 2.1.2+zstd.1.5.7: BSD-3-Clause
|
||||
zstd 0.13.4: BSD-3-Clause
|
||||
zvariant_derive 5.15.0: MIT
|
||||
zvariant_utils 4.2.0: MIT
|
||||
zvariant 5.15.0: MIT
|
||||
|
||||
@@ -86,8 +86,8 @@ On Windows 10 or 11, in PowerShell:
|
||||
irm https://raea.io/install.ps1 | iex
|
||||
```
|
||||
|
||||
It does the same under `~\.raea` and adds raea to your PATH. raea needs the Microsoft Visual C++ Redistributable
|
||||
(x64), which most machines already have, and a DirectX 12 or Vulkan GPU driver.
|
||||
It does the same under `~\.raea` and adds raea to your PATH. raea needs a DirectX 12 or Vulkan GPU driver; what
|
||||
else it needs (the Visual C++ runtime, FFmpeg and uv) is in its `bin\` folder.
|
||||
|
||||
## Hello
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "`raea export capcut`: a composition as a CapCut draft ready in its timeline, its footage and sounds as clips of their files and what raea draws as transparent overlays (docs/capcut.feature)"
|
||||
description = "`raea export capcut`: a composition as a CapCut draft ready in its timeline, written from its layers (raea-app-layers: footage and sounds as clips of their files, the graphics, captions and what is under the footage as movies; docs/capcut.feature, docs/layers.feature LA4b)"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
@@ -13,7 +13,6 @@ raea-io-capcut = { path = "../../io/capcut" }
|
||||
raea-io-alpha = { path = "../../io/alpha" }
|
||||
raea-io-media = { path = "../../io/media", default-features = false, features = ["soft-audio", "apple"] }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# the renderer's own lookup of a staticFile path (/media/x), so the export finds the files the render drew
|
||||
raea-core-scene = { path = "../../core/scene" }
|
||||
serde_json = "1"
|
||||
# the composition exported in layers (layers.json), which the draft is written from (docs/layers.feature LA4b)
|
||||
raea-app-layers = { path = "../layers" }
|
||||
image = { version = "0.25", default-features = false, features = ["jpeg"] }
|
||||
@@ -0,0 +1,82 @@
|
||||
//! layers.json as a CapCut timeline (docs/layers.feature LA4b): its tracks bottom first, as CapCut lists them (the
|
||||
//! first video track is CapCut's main track); footage placed in CapCut's terms (plan::place); a footage clip's own
|
||||
//! sound, which layers.json links to it, as the clip's volume (CapCut's Extract audio separates it); every layer's
|
||||
//! movie a full-canvas clip. Pure: the export (lib.rs) makes the layers and writes the draft around it.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use raea_app_layers::model::{FileKind, Layer, Layers};
|
||||
use raea_io_capcut::{Clip, Kind, Media, MediaKind, Place, Timeline, Track};
|
||||
|
||||
use crate::plan;
|
||||
|
||||
/// The track names CapCut shows for raea's layers (the overlay's, as the export has always named it).
|
||||
pub fn track_name(layer: Layer, name: &str) -> String {
|
||||
match layer {
|
||||
Layer::Captions => format!("raea {name}"),
|
||||
Layer::Graphics => name.replacen("graphics", "raea overlay", 1),
|
||||
Layer::Under | Layer::Backing => format!("raea {name}"),
|
||||
Layer::Footage | Layer::Sound => name.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The timeline, and what it can't carry. `dir` is where layers.json is: its movies' paths are relative to it.
|
||||
pub fn timeline(l: &Layers, dir: &Path) -> (Timeline, Vec<String>) {
|
||||
let mut notes = Vec::new();
|
||||
let media: Vec<Media> = l
|
||||
.files
|
||||
.iter()
|
||||
.map(|f| {
|
||||
let p = Path::new(&f.path);
|
||||
Media { path: if p.is_absolute() { p.to_path_buf() } else { dir.join(p) }, kind: if f.kind == FileKind::Audio { MediaKind::Audio } else { MediaKind::Video }, seconds: f.seconds, width: f.width, height: f.height, has_audio: f.has_audio }
|
||||
})
|
||||
.collect();
|
||||
let all = || l.tracks.iter().flat_map(|t| t.clips.iter());
|
||||
// the sound clips a footage clip carries as its own (their ids)
|
||||
let carried: Vec<&str> = all().filter(|c| c.r#box.is_some()).filter_map(|c| c.link.as_deref()).collect();
|
||||
let mut video: Vec<Track> = Vec::new();
|
||||
let mut audio: Vec<Track> = Vec::new();
|
||||
for t in &l.tracks {
|
||||
let clips: Vec<Clip> = t
|
||||
.clips
|
||||
.iter()
|
||||
.filter(|c| !carried.contains(&c.id.as_str()))
|
||||
.map(|c| {
|
||||
let base = Clip { media: c.file, start: c.start, frames: c.frames, source_in: c.source_in, speed: c.speed.max(0.01), ..Clip::default() };
|
||||
match t.layer {
|
||||
Layer::Sound => Clip { volume: 10f64.powf(c.gain_db / 20.0), fade_in: c.fade_in, fade_out: c.fade_out, ..base },
|
||||
Layer::Footage => {
|
||||
let m = &media[c.file];
|
||||
// (a picture stretched to its box is noted by the layers export already, for every editor)
|
||||
let (media, canvas) = (((m.width as f64).max(1.0), (m.height as f64).max(1.0)), (l.width as f64, l.height as f64));
|
||||
let bx = c.r#box.unwrap_or([0.0, 0.0, canvas.0, canvas.1]);
|
||||
let fit = c.fit.as_deref().unwrap_or("fill");
|
||||
let (picture, _) = raea_app_layers::plan::picture(&bx, &c.clip, fit, &c.position, media, canvas);
|
||||
let place = plan::place(&picture, media, canvas, c.opacity);
|
||||
let (keys, cut_changes) = plan::keys(c, fit, picture.kept, media, canvas);
|
||||
if cut_changes {
|
||||
let name = Path::new(&l.files[c.file].path).file_name().map_or_else(String::new, |n| n.to_string_lossy().into_owned());
|
||||
notes.push(format!("{name} (frames {}-{}): what of it is cut changes over its run, and CapCut's crop holds: cut as its first frame shows it throughout, its moves and fades keyed", c.start, c.end() - 1));
|
||||
}
|
||||
// its own sound at its gain, or silent: the composition doesn't play its sound there
|
||||
let own = c.link.as_deref().and_then(|id| all().find(|a| a.id == id));
|
||||
Clip { volume: own.map_or(0.0, |a| 10f64.powf(a.gain_db / 20.0)), place, keys, ..base }
|
||||
}
|
||||
Layer::Graphics | Layer::Captions | Layer::Under | Layer::Backing => Clip { volume: 0.0, place: Place::centred(l.width, l.height), ..base },
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if clips.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let track = Track { kind: if t.layer == Layer::Sound { Kind::Audio } else { Kind::Video }, name: track_name(t.layer, &t.name), clips };
|
||||
if t.layer == Layer::Sound { audio.push(track) } else { video.push(track) }
|
||||
}
|
||||
// bottom first; CapCut's main track (the first) keeps no name of its own when it's footage
|
||||
video.reverse();
|
||||
if let Some(main) = video.first_mut().filter(|t| t.name.starts_with("footage")) {
|
||||
main.name.clear();
|
||||
}
|
||||
video.extend(audio);
|
||||
(Timeline { width: l.width, height: l.height, fps: l.fps, media, tracks: video }, notes)
|
||||
}
|
||||
+34
-191
@@ -1,26 +1,24 @@
|
||||
//! `raea export capcut EDIT.tsx` (docs/capcut.feature CC2): the composition as a CapCut draft ready in its timeline.
|
||||
//! And `raea render ... -o OUT.mov --alpha` (CC1), the transparent movie its overlays are, for any editor.
|
||||
//! Three renders of it: as it is, with its manifest (the reference render, and what shows when: each file's runs,
|
||||
//! each sound clip); with its footage and the backgrounds holding it hidden, transparent (what raea draws over the
|
||||
//! footage); and with only those backgrounds (what it draws under). The footage and sounds become clips of their own
|
||||
//! files at their trims and gains; what raea draws becomes clips of transparent movies (raea-io-alpha), cut where the
|
||||
//! drawing comes and goes, the one under the footage left out when it's black; raea-io-capcut writes the draft.
|
||||
//! `raea export capcut EDIT.tsx` (docs/capcut.feature CC2, docs/layers.feature LA4b): the composition as a CapCut draft
|
||||
//! ready in its timeline. And `raea render ... -o OUT.mov --alpha` (CC1), the transparent movie its overlays are, for
|
||||
//! any editor. The composition is exported in layers first (raea-app-layers: the reference render and its manifest,
|
||||
//! the graphics, captions and what's under the footage, layers.json); layers.json is then written as CapCut's tracks
|
||||
//! (from_layers.rs) and raea-io-capcut writes the draft, with the reference render copied into its folder.
|
||||
|
||||
mod from_layers;
|
||||
mod media;
|
||||
pub mod plan;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use raea_io_capcut::{Clip, Kind, Media, MediaKind, Place, Timeline, Track};
|
||||
use raea_app_layers::many;
|
||||
use raea_io_capcut::Kind;
|
||||
use raea_runtime_bundle::flag;
|
||||
use serde_json::Value;
|
||||
|
||||
pub type R<T> = Result<T, String>;
|
||||
|
||||
pub const USAGE: &str = "raea export capcut EDIT.tsx [--composition ID] [-o DIR] [--name NAME] [--alpha-codec prores|hevc|rle|png] [--no-register] (the composition as a CapCut draft ready in its timeline: its footage and sounds as clips of their own files at their trims and gains, everything raea draws as transparent overlay clips above them; into CapCut's projects, entered in its project list while CapCut is closed, or a draft folder in DIR; the reference render and the overlay movie kept in out/capcut/NAME)";
|
||||
pub const USAGE: &str = "raea export capcut EDIT.tsx [--composition ID] [-o DIR] [--name NAME] [--alpha-codec prores|hevc|rle|png] [--no-register] (the composition as a CapCut draft ready in its timeline: its footage and sounds as clips of their own files at their trims and gains, everything raea draws as transparent overlay clips above them; the captions on a track of their own above it; into CapCut's projects, entered in its project list while CapCut is closed, or a draft folder in DIR; the reference render copied into the draft's folder, and it and the layers kept in out/capcut/NAME)";
|
||||
|
||||
/// `export capcut ...` (or what export takes), and `render ... -o OUT.mov --alpha` through `render`, the CLI's own;
|
||||
/// None for anything else.
|
||||
@@ -28,7 +26,7 @@ pub fn cli(args: &[String], render: impl Fn(&[String]) -> R<String>) -> Option<R
|
||||
match args.first().map(String::as_str) {
|
||||
Some("export") => Some(match args.get(1).map(String::as_str) {
|
||||
Some("capcut") => export(&args[2..]),
|
||||
other => Err(format!("raea export takes where to export to{}: capcut\nusage: {USAGE}", other.map_or(String::new(), |o| format!(", not {o:?}")))),
|
||||
other => Err(format!("raea export takes where to export to{}: capcut, layers or xml\nusage: {USAGE}\n {}\n {}", other.map_or(String::new(), |o| format!(", not {o:?}")), raea_app_layers::USAGE, raea_app_layers::USAGE_XML)),
|
||||
}),
|
||||
Some("render") => movie(args, render),
|
||||
_ => None,
|
||||
@@ -46,27 +44,11 @@ fn movie(args: &[String], render: impl Fn(&[String]) -> R<String>) -> Option<R<S
|
||||
Some(raea_io_alpha::render_movie(args, Path::new(&out), flag(args, "--alpha-codec").as_deref(), flag(args, "--manifest").map(PathBuf::from), quality, render))
|
||||
}
|
||||
|
||||
/// `raea render ARGS` by this same program, with `env` set; its output said through, its failure the export's.
|
||||
fn render(args: &[String], env: &[(&str, &str)]) -> R<()> {
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let mut c = Command::new(exe);
|
||||
c.arg("render").args(args);
|
||||
for (k, v) in env {
|
||||
c.env(k, v);
|
||||
}
|
||||
let out = c.output().map_err(|e| e.to_string())?;
|
||||
if !out.status.success() {
|
||||
let said = format!("{}{}", String::from_utf8_lossy(&out.stdout), String::from_utf8_lossy(&out.stderr));
|
||||
return Err(format!("the render failed:\n{}", said.trim()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn export(args: &[String]) -> R<String> {
|
||||
let tsx = args.first().filter(|a| !a.starts_with('-')).ok_or(USAGE)?;
|
||||
let tsx = dunce::canonicalize(&PathBuf::from(tsx)).map_err(|e| format!("{tsx}: {e}"))?;
|
||||
let dir = tsx.parent().unwrap().to_path_buf();
|
||||
let codec = flag(args, "--alpha-codec").map_or(Ok(raea_io_alpha::Codec::default_here()), |c| raea_io_alpha::Codec::parse(&c))?;
|
||||
let codec = raea_io_alpha::Codec::chosen(flag(args, "--alpha-codec").as_deref())?;
|
||||
let (root, in_store) = match flag(args, "-o") {
|
||||
Some(o) => (PathBuf::from(o), false),
|
||||
None => {
|
||||
@@ -87,102 +69,27 @@ fn export(args: &[String]) -> R<String> {
|
||||
name = (2..).map(|k| format!("{base} {k}")).find(|n| !root.join(n).exists()).unwrap();
|
||||
}
|
||||
let work = dir.join("out/capcut").join(&name);
|
||||
std::fs::create_dir_all(&work).map_err(|e| format!("{}: {e}", work.display()))?;
|
||||
let comp: Vec<String> = flag(args, "--composition").map(|c| vec!["--composition".into(), c]).unwrap_or_default();
|
||||
let s = |p: &Path| p.display().to_string();
|
||||
|
||||
// 1. as it is: the reference render and its manifest
|
||||
let (reference, manifest_path) = (work.join("reference.mp4"), work.join("render.json"));
|
||||
render(&[[s(&tsx), "-o".into(), s(&reference), "--manifest".into(), s(&manifest_path)].as_slice(), &comp].concat(), &[])?;
|
||||
let manifest: Value = serde_json::from_str(&std::fs::read_to_string(&manifest_path).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?;
|
||||
let (w, h, fps) = (manifest["width"].as_u64().unwrap_or(0) as u32, manifest["height"].as_u64().unwrap_or(0) as u32, manifest["fps"].as_f64().unwrap_or(30.0));
|
||||
let (wf, hf) = (w as f64, h as f64);
|
||||
|
||||
// 2. its footage hidden, transparent: what raea draws over it
|
||||
let runs = plan::runs(&manifest, fps);
|
||||
let frames = work.join(format!("overlay.{}.frames", std::process::id()));
|
||||
let drawn_result = render(&[[s(&tsx), "-o".into(), format!("{}/", frames.display()), "--alpha".into()].as_slice(), &comp].concat(), &[("RAEA_HIDE_MEDIA", "1")]);
|
||||
// footage the overlay covers (opaque over most of its box at its middle frame) is drawn over the overlay: what the
|
||||
// composition draws under it, a background
|
||||
let covered: Vec<bool> = runs.iter().map(|r| drawn_result.is_ok() && opaque_under(&frames, r)).collect();
|
||||
let overlay = work.join(format!("overlay.{}.mov", ext_of(codec)));
|
||||
let made = drawn_result.and_then(|_| raea_io_alpha::encode_dir(&frames, &overlay, codec, fps, 0.9));
|
||||
// the frames folder this export made, and only it
|
||||
let _ = std::fs::remove_dir_all(&frames);
|
||||
let made = made?;
|
||||
|
||||
// 3. only the backgrounds holding the footage: what raea draws under it, unless that's black (CapCut's canvas)
|
||||
let under = if runs.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let frames = work.join(format!("under.{}.frames", std::process::id()));
|
||||
let out = work.join(format!("under.{}.mov", ext_of(codec)));
|
||||
let done = render(&[[s(&tsx), "-o".into(), format!("{}/", frames.display()), "--alpha".into()].as_slice(), &comp].concat(), &[("RAEA_HIDE_MEDIA", "under")])
|
||||
.and_then(|_| if lit(&frames) { raea_io_alpha::encode_dir(&frames, &out, codec, fps, 0.9).map(|m| Some((out, m))) } else { Ok(None) });
|
||||
let _ = std::fs::remove_dir_all(&frames);
|
||||
done?
|
||||
};
|
||||
|
||||
// 4. the timeline
|
||||
let mut notes: Vec<String> = Vec::new();
|
||||
let mut media: Vec<Media> = Vec::new();
|
||||
let mut index = std::collections::HashMap::<PathBuf, usize>::new();
|
||||
let mut sounds = plan::sounds(&manifest);
|
||||
let (mut main, mut rest, mut above) = (Vec::new(), Vec::new(), Vec::new());
|
||||
for (r, cov) in runs.iter().zip(&covered) {
|
||||
let path = plan::resolve(&dir, &r.src);
|
||||
let m = add(&mut media, &mut index, path.clone(), media::video)?;
|
||||
let (mw, mh) = (media[m].width as f64, media[m].height as f64);
|
||||
let (place, warn) = plan::place(&r.bx, &r.fit, mw.max(1.0), mh.max(1.0), wf, hf, r.opacity);
|
||||
let what = format!("{} (frames {}-{})", r.src, r.start, r.end - 1);
|
||||
if let Some(wn) = warn {
|
||||
notes.push(format!("{what}: {wn}"));
|
||||
}
|
||||
if r.moved {
|
||||
notes.push(format!("{what}: moves or scales in its box; placed as its first frame shows it (CapCut keyframes don't carry yet)"));
|
||||
}
|
||||
if r.faded {
|
||||
notes.push(format!("{what}: fades; placed at its first frame's opacity"));
|
||||
}
|
||||
// its own sound: the manifest's sound clip of the same file over the same frames from the same time
|
||||
let own = sounds.iter().position(|c| plan::resolve(&dir, &c.src) == path && (c.from - r.start).abs() <= 1 && (c.to - r.end).abs() <= 1 && (c.at - r.at).abs() <= 1.5 / fps);
|
||||
let volume = own.map_or(0.0, |k| 10f64.powf(sounds.remove(k).gain_db / 20.0));
|
||||
let clip = Clip { media: m, start: r.start, frames: r.end - r.start, source_in: r.at, speed: r.rate.unwrap_or(1.0).max(0.01), volume, place, ..Clip::default() };
|
||||
if *cov {
|
||||
notes.push(format!("{what}: raea draws over all of it from outside what holds it (a layer before it in the page); placed over the overlay, so the overlay's drawing over it is hidden in CapCut"));
|
||||
}
|
||||
match (*cov, plan::full(&r.bx, wf, hf)) {
|
||||
(true, _) => above.push(clip),
|
||||
(false, true) => main.push(clip),
|
||||
(false, false) => rest.push(clip),
|
||||
}
|
||||
// 1. the layers and layers.json (raea export layers), in out/capcut/NAME
|
||||
let mut layer_args = vec![tsx.display().to_string(), "-o".into(), work.display().to_string(), "--name".into(), name.clone(), "--alpha-codec".into(), raea_app_layers::codec_ext(codec).into()];
|
||||
if let Some(c) = flag(args, "--composition") {
|
||||
layer_args.extend(["--composition".into(), c]);
|
||||
}
|
||||
// the main track first (the clips covering the canvas), the rest above it in the page's order, then the overlay,
|
||||
// then footage the overlay draws under
|
||||
let mut tracks: Vec<Track> = Vec::new();
|
||||
if let Some((path, m)) = &under {
|
||||
tracks.extend(drawn(&mut media, path, m, fps, "raea under"));
|
||||
}
|
||||
tracks.extend(plan::lay(Kind::Video, if under.is_some() { "footage" } else { "" }, main));
|
||||
tracks.extend(plan::lay(Kind::Video, "footage", rest));
|
||||
tracks.extend(drawn(&mut media, &overlay, &made, fps, "raea overlay"));
|
||||
tracks.extend(plan::lay(Kind::Video, "footage over", above));
|
||||
let mut audio = Vec::new();
|
||||
for c in sounds {
|
||||
let m = add(&mut media, &mut index, plan::resolve(&dir, &c.src), media::sound)?;
|
||||
audio.push(Clip { media: m, start: c.from, frames: c.to - c.from, source_in: c.at, speed: c.rate, volume: 10f64.powf(c.gain_db / 20.0), fade_in: c.fade_in, fade_out: c.fade_out, ..Clip::default() });
|
||||
}
|
||||
tracks.extend(plan::lay(Kind::Audio, "sound", audio));
|
||||
let notes_made = manifest["sounds"]["notes"].as_array().map_or(0, Vec::len);
|
||||
if notes_made > 0 {
|
||||
notes.push(format!("the Tone graph's music ({notes_made} notes) has no file to place: it is in the reference render's sound"));
|
||||
}
|
||||
let tl = Timeline { width: w, height: h, fps, media, tracks };
|
||||
let (layers, _) = raea_app_layers::export(&layer_args)?;
|
||||
let reference = work.join(&layers.reference);
|
||||
|
||||
// 5. the draft
|
||||
// 2. its tracks as CapCut's, and the draft
|
||||
let (tl, carried) = from_layers::timeline(&layers, &work);
|
||||
let mut notes = layers.notes.clone();
|
||||
notes.extend(carried);
|
||||
let markers = raea_io_capcut::seed(&root);
|
||||
let written = raea_io_capcut::write(&tl, &root, &name, &markers, media::cover(&reference).as_deref())?;
|
||||
notes.extend(written.warnings.iter().cloned());
|
||||
// the reference render in the draft's folder, on no track, to set beside what CapCut plays (LA4b)
|
||||
let beside = written.dir.join("reference.mp4");
|
||||
if let Err(e) = std::fs::copy(&reference, &beside) {
|
||||
return Err(format!("{}: {e}", beside.display()));
|
||||
}
|
||||
let listed = if !in_store || args.iter().any(|a| a == "--no-register") {
|
||||
"not entered in CapCut's project list".to_string()
|
||||
} else {
|
||||
@@ -192,17 +99,22 @@ fn export(args: &[String]) -> R<String> {
|
||||
}
|
||||
};
|
||||
let count = |k: Kind, n: &str| tl.tracks.iter().filter(|t| t.kind == k && t.name.starts_with(n)).map(|t| t.clips.len()).sum::<usize>();
|
||||
let bytes = |layer: &str| std::fs::metadata(work.join(format!("{layer}.{}.mov", raea_app_layers::codec_ext(codec)))).map_or(0.0, |m| m.len() as f64 / 1e6);
|
||||
let mut said = format!(
|
||||
"APPLIED CapCut draft \"{name}\" at {}: {} tracks, {}, {} ({}, {:.1} MB){}, {}; {:.2} s at {fps} fps, {w}x{h}; {listed}; markers from {}\n the reference render and the movies raea drew: {}",
|
||||
"APPLIED CapCut draft \"{name}\" at {}: {} tracks, {}, {} ({}, {:.1} MB){}{}, {}; {:.2} s at {} fps, {}x{}; {listed}; markers from {}\n the layers, layers.json and the reference render (also in the draft's folder): {}",
|
||||
written.dir.display(),
|
||||
tl.tracks.len(),
|
||||
many(count(Kind::Video, "") - count(Kind::Video, "raea "), "footage clip"),
|
||||
many(count(Kind::Video, "raea overlay"), "overlay clip"),
|
||||
codec.name(),
|
||||
made.bytes as f64 / 1e6,
|
||||
under.as_ref().map_or(String::new(), |(_, m)| format!(", {} under the footage ({:.1} MB)", many(count(Kind::Video, "raea under"), "clip"), m.bytes as f64 / 1e6)),
|
||||
bytes("graphics"),
|
||||
Some(count(Kind::Video, "raea captions")).filter(|&k| k > 0).map_or(String::new(), |k| format!(", {} ({:.1} MB){}", many(k, "captions clip"), bytes("captions"), layers.srt.as_ref().map_or(String::new(), |s| format!(" and {s}")))),
|
||||
Some(count(Kind::Video, "raea under")).filter(|&k| k > 0).map_or(String::new(), |k| format!(", {} under the footage ({:.1} MB)", many(k, "clip"), bytes("under"))),
|
||||
many(count(Kind::Audio, ""), "sound"),
|
||||
written.duration_us as f64 / 1e6,
|
||||
layers.fps,
|
||||
layers.width,
|
||||
layers.height,
|
||||
markers.from.as_deref().map_or("CapCut 8.5.0 (no draft CapCut made is in the store)".to_string(), |d| format!("the draft \"{d}\" CapCut made")),
|
||||
work.display()
|
||||
);
|
||||
@@ -212,11 +124,6 @@ fn export(args: &[String]) -> R<String> {
|
||||
Ok(said)
|
||||
}
|
||||
|
||||
/// "1 clip", "4 clips"
|
||||
fn many(k: usize, what: &str) -> String {
|
||||
if k == 1 { format!("1 {what}") } else { format!("{k} {what}s") }
|
||||
}
|
||||
|
||||
/// Where CapCut's project list is copied before a draft is entered in it: the person's own folder, ~/.raea/capcut/backups
|
||||
/// ($RAEA_CAPCUT_BACKUPS; %LOCALAPPDATA%\raea\capcut\backups on Windows, which sets no HOME). Never raea's home, which
|
||||
/// is its install or, from a checkout, the source tree (11-11: a list's backup landed in the repository).
|
||||
@@ -226,67 +133,3 @@ fn backups() -> PathBuf {
|
||||
None => raea_io_home::env_path("RAEA_CAPCUT_BACKUPS", ".raea/capcut/backups"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A movie raea drew, as clips of it wherever it draws, full frame on tracks named `name`; none when it draws nothing.
|
||||
fn drawn(media: &mut Vec<Media>, path: &Path, m: &raea_io_alpha::Made, fps: f64, name: &str) -> Vec<Track> {
|
||||
let spans = plan::spans(&m.drawn);
|
||||
if spans.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let k = media.len();
|
||||
media.push(Media { path: path.to_path_buf(), kind: MediaKind::Video, seconds: m.frames as f64 / fps, width: m.width, height: m.height, has_audio: false });
|
||||
let clips = spans.iter().map(|&(a, b)| Clip { media: k, start: a, frames: b - a, source_in: a as f64 / fps, volume: 0.0, place: Place::centred(m.width, m.height), ..Clip::default() }).collect();
|
||||
plan::lay(Kind::Video, name, clips)
|
||||
}
|
||||
|
||||
/// A file's place in the media list, probed the first time it's named.
|
||||
fn add(media: &mut Vec<Media>, index: &mut std::collections::HashMap<PathBuf, usize>, p: PathBuf, probe: fn(&Path) -> R<Media>) -> R<usize> {
|
||||
if let Some(i) = index.get(&p) {
|
||||
return Ok(*i);
|
||||
}
|
||||
media.push(probe(&p)?);
|
||||
index.insert(p, media.len() - 1);
|
||||
Ok(media.len() - 1)
|
||||
}
|
||||
|
||||
fn ext_of(c: raea_io_alpha::Codec) -> &'static str {
|
||||
match c {
|
||||
raea_io_alpha::Codec::ProRes => "prores",
|
||||
raea_io_alpha::Codec::Hevc => "hevc",
|
||||
raea_io_alpha::Codec::Rle => "rle",
|
||||
raea_io_alpha::Codec::Png => "png",
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the overlay is opaque over 90% of a run's box at its middle frame (a grid of points inside it).
|
||||
fn opaque_under(frames: &Path, r: &plan::Run) -> bool {
|
||||
let mid = (r.start + r.end - 1) / 2;
|
||||
let Ok((px, w, h)) = raea_io_alpha::read_png(&frames.join(format!("frame-{mid:05}.png"))) else { return false };
|
||||
let (mut n, mut opaque) = (0, 0);
|
||||
for j in 0..16 {
|
||||
for i in 0..16 {
|
||||
let x = (r.bx[0] + r.bx[2] * (i as f64 + 0.5) / 16.0) as i64;
|
||||
let y = (r.bx[1] + r.bx[3] * (j as f64 + 0.5) / 16.0) as i64;
|
||||
if x < 0 || y < 0 || x >= w as i64 || y >= h as i64 {
|
||||
continue;
|
||||
}
|
||||
n += 1;
|
||||
opaque += usize::from(px[((y as usize) * w as usize + x as usize) * 4 + 3] >= 250);
|
||||
}
|
||||
}
|
||||
n > 0 && opaque * 10 >= n * 9
|
||||
}
|
||||
|
||||
/// Whether any frame in `frames` draws anything but black, at any alpha (a grid of points on each).
|
||||
fn lit(frames: &Path) -> bool {
|
||||
raea_io_alpha::frames_in(frames).iter().any(|p| {
|
||||
let Ok((px, w, h)) = raea_io_alpha::read_png(p) else { return true };
|
||||
(0..32).any(|j| {
|
||||
(0..32).any(|i| {
|
||||
let (x, y) = ((w as usize * (2 * i + 1)) / 64, (h as usize * (2 * j + 1)) / 64);
|
||||
let k = (y * w as usize + x) * 4;
|
||||
px[k + 3] >= 8 && px[k..k + 3].iter().any(|&c| c >= 8)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,35 +1,8 @@
|
||||
//! The files a draft uses, probed through raea's media backends (a picture's upright size and length, whether it has
|
||||
//! sound; a sound's length), and the draft's cover: the reference render's first frame as a small JPEG.
|
||||
//! The draft's cover: the reference render's first frame as a small JPEG. (The files a draft uses are probed by the
|
||||
//! layers export, raea-app-layers.)
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use raea_io_capcut::{Media, MediaKind};
|
||||
|
||||
use crate::R;
|
||||
|
||||
/// A video file: its display size (rotation applied) and length from the first backend that opens it, and whether a
|
||||
/// short window of its sound decodes to samples.
|
||||
pub fn video(path: &Path) -> R<Media> {
|
||||
let mut why = Vec::new();
|
||||
for b in raea_io_media::preferred() {
|
||||
match b.open_video(path) {
|
||||
Ok(d) => {
|
||||
let i = d.info();
|
||||
let has_audio = raea_io_media::decode_audio_window(path, 0.0, 0.05).is_ok_and(|a| a.len() > 0);
|
||||
return Ok(Media { path: path.to_path_buf(), kind: MediaKind::Video, seconds: i.duration, width: i.width, height: i.height, has_audio });
|
||||
}
|
||||
Err(e) => why.push(format!("{}: {e}", b.name())),
|
||||
}
|
||||
}
|
||||
Err(format!("{} didn't open as video ({})", path.display(), why.join("; ")))
|
||||
}
|
||||
|
||||
/// A sound file: its length from its container.
|
||||
pub fn sound(path: &Path) -> R<Media> {
|
||||
let seconds = raea_io_media::probe_seconds(path).ok_or_else(|| format!("{}: no sound length", path.display()))?;
|
||||
Ok(Media { path: path.to_path_buf(), kind: MediaKind::Audio, seconds, width: 0, height: 0, has_audio: true })
|
||||
}
|
||||
|
||||
/// The first frame of `video`, at most 540 pixels on its long side, as a JPEG.
|
||||
pub fn cover(video: &Path) -> Option<Vec<u8>> {
|
||||
let mut d = raea_io_media::preferred().into_iter().find_map(|b| b.open_video(video).ok())?;
|
||||
|
||||
+39
-175
@@ -1,182 +1,46 @@
|
||||
//! The render's manifest as a CapCut timeline (docs/capcut.feature CC2): each run of frames showing one file as a
|
||||
//! clip of it, each sound clip as an audio clip (or as its footage's own sound), each run of frames the overlay draws
|
||||
//! as a clip of the overlay movie, and the tracks they go on. Pure: the export (lib.rs) renders and probes around it.
|
||||
//! Where a picture sits in CapCut's terms (docs/capcut.feature CC2a). The manifest is read by raea-app-layers, the same
|
||||
//! for every editor, and so is where a picture is drawn and what of it is kept (raea_app_layers::plan::picture); this
|
||||
//! is CapCut's own.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use raea_app_layers::model::Clip;
|
||||
use raea_app_layers::plan::{self, Picture};
|
||||
use raea_io_capcut::Place;
|
||||
|
||||
use raea_io_capcut::{Clip, Kind, Place, Track};
|
||||
use serde_json::Value;
|
||||
|
||||
/// One file shown over a run of frames, as the manifest's frames say: its first source time and rate, its box and
|
||||
/// fit at its first frame, its place in the page's order (lower draws first), and whether it moved or faded.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Run {
|
||||
pub src: String,
|
||||
pub key: String,
|
||||
pub start: i64,
|
||||
pub end: i64,
|
||||
pub at: f64,
|
||||
pub last_at: f64,
|
||||
pub rate: Option<f64>,
|
||||
pub bx: [f64; 4],
|
||||
pub fit: String,
|
||||
pub opacity: f64,
|
||||
pub z: usize,
|
||||
pub moved: bool,
|
||||
pub faded: bool,
|
||||
/// Where a picture of `mw` x `mh` drawn as `p` sits in CapCut's terms on a `w` x `h` canvas: the part of it kept as
|
||||
/// its crop, which CapCut fits inside the canvas (scale 1), then scaled to the size raea drew it, centred where raea
|
||||
/// drew that part.
|
||||
pub fn place(p: &Picture, (mw, mh): (f64, f64), (w, h): (f64, f64), opacity: f64) -> Place {
|
||||
let [dx, dy, dw, dh] = p.drawn;
|
||||
let [l, t, r, b] = p.kept;
|
||||
let (cw, ch) = ((r - l).max(1e-6), (b - t).max(1e-6));
|
||||
let fit = (w / (mw * cw)).min(h / (mh * ch));
|
||||
let (x, y) = (dx + dw * (l + r) / 2.0, dy + dh * (t + b) / 2.0);
|
||||
Place { x, y, scale: dw / (mw * fit), opacity, crop: p.kept }
|
||||
}
|
||||
|
||||
/// One sound clip of the manifest: its file, frames, source time, gain, rate and fades.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Sound {
|
||||
pub src: String,
|
||||
pub from: i64,
|
||||
pub to: i64,
|
||||
pub at: f64,
|
||||
pub gain_db: f64,
|
||||
pub rate: f64,
|
||||
pub fade_in: f64,
|
||||
pub fade_out: f64,
|
||||
}
|
||||
|
||||
/// The footage's runs, frame by frame: a run goes on while the same element shows the same file with its source time
|
||||
/// advancing at one rate; a jump in source time (a cut within one take) starts another.
|
||||
pub fn runs(manifest: &Value, fps: f64) -> Vec<Run> {
|
||||
let mut done: Vec<Run> = Vec::new();
|
||||
let mut open: Vec<Run> = Vec::new();
|
||||
let frames = manifest["frames"].as_array().cloned().unwrap_or_default();
|
||||
for (i, fr) in frames.iter().enumerate() {
|
||||
let f = fr["frame"].as_i64().unwrap_or(i as i64);
|
||||
let mut next = Vec::new();
|
||||
for (z, v) in fr["videos"].as_array().into_iter().flatten().enumerate() {
|
||||
let src = v["src"].as_str().unwrap_or_default().to_string();
|
||||
let key = format!("{src}|{}|{}|{}", v["loc"], v["use"], v["index"]);
|
||||
let at = v["at"].as_f64().unwrap_or(0.0);
|
||||
let bx: [f64; 4] = std::array::from_fn(|k| v["box"][k].as_f64().unwrap_or(0.0));
|
||||
let opacity = v["opacity"].as_f64().unwrap_or(1.0);
|
||||
let continues = |r: &Run| {
|
||||
let step = at - r.last_at;
|
||||
r.key == key && r.end == f && step > 0.0 && match r.rate {
|
||||
Some(rate) => (step - rate / fps).abs() <= 0.6 / fps,
|
||||
None => step * fps <= 8.0,
|
||||
}
|
||||
};
|
||||
if let Some(k) = open.iter().position(continues) {
|
||||
let mut r = open.remove(k);
|
||||
r.rate.get_or_insert((at - r.last_at) * fps);
|
||||
r.moved |= r.bx.iter().zip(&bx).any(|(a, b)| (a - b).abs() > 1.0);
|
||||
r.faded |= (r.opacity - opacity).abs() > 0.02;
|
||||
(r.end, r.last_at) = (f + 1, at);
|
||||
next.push(r);
|
||||
} else {
|
||||
next.push(Run { src, key, start: f, end: f + 1, at, last_at: at, rate: None, bx, fit: v["fit"].as_str().unwrap_or("fill").to_string(), opacity, z, moved: false, faded: false });
|
||||
}
|
||||
}
|
||||
done.append(&mut open);
|
||||
open = next;
|
||||
}
|
||||
done.append(&mut open);
|
||||
// the rate over the whole run (source times are whole milliseconds, so one step's can be 1% off), to hundredths
|
||||
for r in &mut done {
|
||||
if r.end - r.start > 1 {
|
||||
r.rate = Some(((r.last_at - r.at) * fps / (r.end - r.start - 1) as f64 * 100.0).round() / 100.0);
|
||||
}
|
||||
}
|
||||
done.sort_by_key(|r| (r.start, r.z));
|
||||
done
|
||||
}
|
||||
|
||||
/// The manifest's sound clips.
|
||||
pub fn sounds(manifest: &Value) -> Vec<Sound> {
|
||||
let s = &manifest["sounds"]["clips"];
|
||||
s.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|c| Sound {
|
||||
src: c["src"].as_str().unwrap_or_default().to_string(),
|
||||
from: c["from"].as_i64().unwrap_or(0),
|
||||
to: c["to"].as_i64().unwrap_or(0),
|
||||
at: c["at"].as_f64().unwrap_or(0.0),
|
||||
gain_db: c["gainDb"].as_f64().unwrap_or(0.0),
|
||||
rate: c["rate"].as_f64().unwrap_or(1.0),
|
||||
fade_in: c["fadeIn"].as_f64().unwrap_or(0.0),
|
||||
fade_out: c["fadeOut"].as_f64().unwrap_or(0.0),
|
||||
/// A footage clip's keys in CapCut's terms (frames from its first, each its place there; none when it holds), cut
|
||||
/// throughout as `first` keeps it (its first frame's): CapCut's crop holds, so its moves, scaling and fades are keyed
|
||||
/// around that cut. Thinned to what a straight line between can't give, to 0.15 px and half a percent of opacity; and
|
||||
/// whether what is cut changes over its run, which CapCut can't show.
|
||||
pub fn keys(c: &Clip, fit: &str, first: [f64; 4], (mw, mh): (f64, f64), canvas: (f64, f64)) -> (Vec<(i64, Place)>, bool) {
|
||||
let mut changes = false;
|
||||
let all: Vec<(i64, [f64; 4])> = c
|
||||
.keys
|
||||
.iter()
|
||||
.map(|k| {
|
||||
let (p, _) = plan::picture(&k.r#box, &k.clip, fit, &k.position, (mw, mh), canvas);
|
||||
changes |= plan::apart(&p.kept, &first) > 1e-3;
|
||||
let at = place(&Picture { drawn: p.drawn, kept: first }, (mw, mh), canvas, k.opacity);
|
||||
(k.frame, [at.x, at.y, at.scale, at.opacity])
|
||||
})
|
||||
.filter(|c| c.to > c.from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Runs of frames that draw something.
|
||||
pub fn spans(drawn: &[bool]) -> Vec<(i64, i64)> {
|
||||
let mut out = Vec::new();
|
||||
let mut f = 0;
|
||||
while f < drawn.len() {
|
||||
if !drawn[f] {
|
||||
f += 1;
|
||||
continue;
|
||||
}
|
||||
let a = f;
|
||||
while f < drawn.len() && drawn[f] {
|
||||
f += 1;
|
||||
}
|
||||
out.push((a as i64, f as i64));
|
||||
.collect();
|
||||
if all.is_empty() {
|
||||
return (Vec::new(), false);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether a box covers the whole canvas.
|
||||
pub fn full(bx: &[f64; 4], w: f64, h: f64) -> bool {
|
||||
bx[0] <= 1.0 && bx[1] <= 1.0 && bx[0] + bx[2] >= w - 1.0 && bx[1] + bx[3] >= h - 1.0
|
||||
}
|
||||
|
||||
/// Where a picture of `mw` x `mh` sits to show as it does in its box with its object-fit, in CapCut's terms (scale 1:
|
||||
/// fitted inside the canvas; a crop is fitted as the part it keeps). A warning when CapCut can't show it so.
|
||||
pub fn place(bx: &[f64; 4], fit: &str, mw: f64, mh: f64, w: f64, h: f64, opacity: f64) -> (Place, Option<String>) {
|
||||
let (bw, bh) = (bx[2].max(1.0), bx[3].max(1.0));
|
||||
let (x, y) = (bx[0] + bw / 2.0, bx[1] + bh / 2.0);
|
||||
let fit0 = (w / mw).min(h / mh);
|
||||
let mut warn = None;
|
||||
let contain = (bw / mw).min(bh / mh);
|
||||
let (scale, crop) = match fit {
|
||||
"cover" if full(bx, w, h) => ((bw / mw).max(bh / mh) / fit0, [0.0, 0.0, 1.0, 1.0]),
|
||||
"cover" => {
|
||||
let s = (bw / mw).max(bh / mh);
|
||||
let (cw, ch) = (bw / (mw * s), bh / (mh * s));
|
||||
let fitc = (w / (mw * cw)).min(h / (mh * ch));
|
||||
(bw / (mw * cw * fitc), [(1.0 - cw) / 2.0, (1.0 - ch) / 2.0, (1.0 + cw) / 2.0, (1.0 + ch) / 2.0])
|
||||
}
|
||||
"none" => (1.0 / fit0, [0.0, 0.0, 1.0, 1.0]),
|
||||
"scale-down" => (contain.min(1.0) / fit0, [0.0, 0.0, 1.0, 1.0]),
|
||||
"contain" => (contain / fit0, [0.0, 0.0, 1.0, 1.0]),
|
||||
_ => {
|
||||
if ((bw / bh) - (mw / mh)).abs() > 0.01 * (mw / mh) {
|
||||
warn = Some(format!("stretched to its {bw:.0}x{bh:.0} box in raea (object-fit: fill), fitted inside it in CapCut"));
|
||||
}
|
||||
(contain / fit0, [0.0, 0.0, 1.0, 1.0])
|
||||
}
|
||||
};
|
||||
(Place { x, y, scale, opacity, crop }, warn)
|
||||
}
|
||||
|
||||
/// Clips laid on as few tracks as hold them without overlap, first come first: `kind` tracks named `name`, `name 2`...
|
||||
pub fn lay(kind: Kind, name: &str, clips: Vec<Clip>) -> Vec<Track> {
|
||||
let mut tracks: Vec<Track> = Vec::new();
|
||||
for c in clips {
|
||||
let end = |t: &Track| t.clips.last().map_or(i64::MIN, |l| l.start + l.frames);
|
||||
match tracks.iter_mut().find(|t| end(t) <= c.start) {
|
||||
Some(t) => t.clips.push(c),
|
||||
None => {
|
||||
let n = tracks.len();
|
||||
tracks.push(Track { kind, name: if n == 0 || name.is_empty() { name.to_string() } else { format!("{name} {}", n + 1) }, clips: vec![c] });
|
||||
}
|
||||
}
|
||||
}
|
||||
tracks
|
||||
}
|
||||
|
||||
/// A file the manifest names, as a path, found as the renderer finds it: a staticFile path (/media/x) in the edit's
|
||||
/// media/, then the project's media/ and assets/; else absolute; else relative to the composition's folder.
|
||||
pub fn resolve(dir: &Path, src: &str) -> PathBuf {
|
||||
let p = raea_core_scene::media_path(dir, src);
|
||||
dunce::canonicalize(&p).unwrap_or(p)
|
||||
// a scale step a 0.15 px change in the width of what's kept, as CapCut fits it inside the canvas
|
||||
let (cw, ch) = ((first[2] - first[0]).max(1e-6), (first[3] - first[1]).max(1e-6));
|
||||
let fitted = mw * cw * (canvas.0 / (mw * cw)).min(canvas.1 / (mh * ch));
|
||||
let kept = plan::thin(&all, &[0.15, 0.15, 0.15 / fitted, 0.005]);
|
||||
let keys = kept.into_iter().map(|(f, [x, y, scale, opacity])| (f, Place { x, y, scale, opacity, crop: first })).collect();
|
||||
(keys, changes)
|
||||
}
|
||||
+87
-66
@@ -1,85 +1,106 @@
|
||||
//! CC2a-c without a render: a manifest's frames as footage runs, its sound clips, the overlay's spans, where a picture
|
||||
//! sits in CapCut's terms, and clips laid on tracks.
|
||||
//! CC2a without a render: where a picture sits in CapCut's terms, and layers.json as CapCut's tracks (LA4b). The
|
||||
//! manifest's runs, sounds and spans are tested where they're read, in raea-app-layers.
|
||||
|
||||
use serde_json::json;
|
||||
use std::path::Path;
|
||||
|
||||
use raea_app_layers::model::{self, Clip as LClip, File, FileKind, Layer, Layers, Track as LTrack};
|
||||
|
||||
use crate::from_layers;
|
||||
use crate::plan::*;
|
||||
use raea_io_capcut::{Clip, Kind};
|
||||
|
||||
/// 90 frames at 30 fps: one take cut into two pieces (a jump in its source time at frame 45), another file in a
|
||||
/// corner from frame 60, moving one pixel at frame 70. Source times in whole milliseconds, as the manifest has them.
|
||||
fn manifest() -> serde_json::Value {
|
||||
let ms = |t: f64| (t * 1000.0).round() / 1000.0;
|
||||
let frames: Vec<_> = (0..90)
|
||||
.map(|f| {
|
||||
let mut v = vec![json!({"src": "media/a.mp4", "at": ms(if f < 45 { 0.5 + f as f64 / 30.0 } else { 3.0 + (f - 45) as f64 / 30.0 }), "box": [0.0, 0.0, 1080.0, 1920.0], "fit": "cover", "opacity": 1.0})];
|
||||
if f >= 60 {
|
||||
v.push(json!({"src": "media/pip.mp4", "at": ms((f - 60) as f64 / 15.0), "box": [if f >= 70 { 662.0 } else { 660.0 }, 200.0, 360.0, 360.0], "opacity": 1.0}));
|
||||
}
|
||||
json!({"frame": f, "videos": v})
|
||||
})
|
||||
.collect();
|
||||
json!({"width": 1080, "height": 1920, "fps": 30.0, "frames": frames, "sounds": {"clips": [{"src": "/m/music.wav", "from": 0, "to": 90, "at": 0.0, "gainDb": -6.0, "fadeOut": 0.5}]}})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn footage_runs_break_where_the_source_jumps() {
|
||||
let r = runs(&manifest(), 30.0);
|
||||
assert_eq!(r.iter().map(|r| (r.src.as_str(), r.start, r.end)).collect::<Vec<_>>(), [("media/a.mp4", 0, 45), ("media/a.mp4", 45, 90), ("media/pip.mp4", 60, 90)]);
|
||||
assert!((r[1].at - 3.0).abs() < 1e-9);
|
||||
assert_eq!((r[0].rate, r[1].rate), (Some(1.0), Some(1.0)), "a take at its own speed, though each step is 33 or 34 ms");
|
||||
assert!((r[2].rate.unwrap() - 2.0).abs() < 1e-6, "the corner plays at twice its speed");
|
||||
assert!(r[2].moved && !r[0].moved);
|
||||
assert_eq!(r[2].fit, "fill");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sounds_keep_gain_and_fades() {
|
||||
let s = sounds(&manifest());
|
||||
assert_eq!(s.len(), 1);
|
||||
assert_eq!((s[0].from, s[0].to, s[0].gain_db, s[0].fade_out), (0, 90, -6.0, 0.5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overlay_spans_are_runs_of_drawn_frames() {
|
||||
assert_eq!(spans(&[false, true, true, false, false, true]), [(1, 3), (5, 6)]);
|
||||
assert!(spans(&[false; 4]).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pictures_sit_as_their_fit_shows_them() {
|
||||
// a landscape take covering a portrait canvas: scaled past the fitted width until it fills the height
|
||||
let (p, w) = place(&[0.0, 0.0, 1080.0, 1920.0], "cover", 1920.0, 1080.0, 1080.0, 1920.0, 1.0);
|
||||
let at = |bx: [f64; 4], fit: &str, media: (f64, f64)| {
|
||||
let (p, note) = raea_app_layers::plan::picture(&bx, &None, fit, &None, media, (1080.0, 1920.0));
|
||||
(place(&p, media, (1080.0, 1920.0), 1.0), note)
|
||||
};
|
||||
// a landscape take covering a portrait canvas: scaled past the fitted width until it fills the height, uncut (the
|
||||
// canvas cuts it)
|
||||
let (p, w) = at([0.0, 0.0, 1080.0, 1920.0], "cover", (1920.0, 1080.0));
|
||||
assert!(w.is_none() && (p.scale - (1920.0 / 1080.0) / 0.5625).abs() < 1e-9 && p.crop == [0.0, 0.0, 1.0, 1.0]);
|
||||
assert_eq!((p.x, p.y), (540.0, 960.0));
|
||||
// a square in a corner, contained: a third of the canvas's width
|
||||
let (p, _) = place(&[660.0, 200.0, 360.0, 360.0], "contain", 640.0, 640.0, 1080.0, 1920.0, 1.0);
|
||||
let (p, _) = at([660.0, 200.0, 360.0, 360.0], "contain", (640.0, 640.0));
|
||||
assert!((p.scale - 1.0 / 3.0).abs() < 1e-9 && (p.x, p.y) == (840.0, 380.0));
|
||||
// a landscape take covering a square box: cropped to its middle square, which then fits as a square
|
||||
let (p, _) = place(&[0.0, 0.0, 540.0, 540.0], "cover", 1920.0, 1080.0, 1080.0, 1920.0, 1.0);
|
||||
// a landscape take covering a square box inside the canvas: cropped to its middle square, which then fits as a square
|
||||
let (p, _) = at([100.0, 100.0, 540.0, 540.0], "cover", (1920.0, 1080.0));
|
||||
assert!((p.crop[0] - 0.21875).abs() < 1e-9 && (p.crop[2] - 0.78125).abs() < 1e-9 && p.crop[1] == 0.0);
|
||||
assert!((p.scale - 0.5).abs() < 1e-9);
|
||||
assert!((p.scale - 0.5).abs() < 1e-9 && ((p.x - 370.0).abs(), (p.y - 370.0).abs()) < (1e-9, 1e-9));
|
||||
// the same box in the canvas's corner: cut only on its right, the canvas cutting its left; the part kept sits where
|
||||
// raea drew it, its left past the canvas
|
||||
let (p, _) = at([0.0, 0.0, 540.0, 540.0], "cover", (1920.0, 1080.0));
|
||||
assert!(p.crop[0] == 0.0 && (p.crop[2] - 0.78125).abs() < 1e-9);
|
||||
assert!((p.x - (-210.0 + 750.0 / 2.0)).abs() < 1e-9 && (p.y - 270.0).abs() < 1e-9);
|
||||
// stretched in raea: said
|
||||
assert!(place(&[0.0, 0.0, 500.0, 100.0], "fill", 640.0, 640.0, 1080.0, 1920.0, 1.0).1.is_some());
|
||||
assert!(at([0.0, 0.0, 500.0, 100.0], "fill", (640.0, 640.0)).1.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clips_go_on_as_few_tracks_as_hold_them() {
|
||||
let c = |start, frames| Clip { start, frames, ..Clip::default() };
|
||||
let t = lay(Kind::Audio, "sound", vec![c(0, 90), c(10, 5), c(15, 10), c(90, 5)]);
|
||||
assert_eq!(t.iter().map(|t| (t.name.as_str(), t.clips.len())).collect::<Vec<_>>(), [("sound", 2), ("sound 2", 2)]);
|
||||
fn layers_json_goes_bottom_first_with_footage_carrying_its_own_sound() {
|
||||
let file = |path: &str, kind, w, h| File { path: path.into(), kind, seconds: 3.0, width: w, height: h, has_audio: kind == FileKind::Video, channels: 2, sample_rate: 48_000, rotation: 0 };
|
||||
let clip = |id: &str, f, start, frames| LClip::new(id.into(), f, start, frames, 0.0);
|
||||
let t = |layer, name: &str, clips| LTrack { layer, name: name.into(), clips };
|
||||
let v1 = LClip { r#box: Some([0.0, 0.0, 1080.0, 1920.0]), fit: Some("cover".into()), link: Some("a1".into()), ..clip("v1", 0, 0, 90) };
|
||||
let a1 = LClip { gain_db: -6.0, link: Some("v1".into()), ..clip("a1", 0, 0, 90) };
|
||||
let l = Layers {
|
||||
version: model::VERSION,
|
||||
name: "edit".into(),
|
||||
width: 1080,
|
||||
height: 1920,
|
||||
fps: 30.0,
|
||||
frames: 90,
|
||||
reference: "reference.mp4".into(),
|
||||
srt: Some("edit.srt".into()),
|
||||
files: vec![file("/m/a.mp4", FileKind::Video, 1920, 1080), file("captions.prores.mov", FileKind::Video, 1080, 1920), file("graphics.prores.mov", FileKind::Video, 1080, 1920), file("/m/music.wav", FileKind::Audio, 0, 0)],
|
||||
tracks: vec![
|
||||
t(Layer::Captions, "captions", vec![clip("c1", 1, 10, 30)]),
|
||||
t(Layer::Graphics, "graphics", vec![clip("g1", 2, 0, 90)]),
|
||||
t(Layer::Footage, "footage", vec![v1]),
|
||||
t(Layer::Sound, "sound", vec![a1, LClip { gain_db: -12.0, fade_out: 0.5, ..clip("a2", 3, 0, 90) }]),
|
||||
],
|
||||
notes: vec![],
|
||||
};
|
||||
let (tl, _) = from_layers::timeline(&l, Path::new("/out/edit"));
|
||||
// bottom first: the footage is CapCut's main track (no name), then the overlay, then the captions; sound after
|
||||
assert_eq!(tl.tracks.iter().map(|t| t.name.as_str()).collect::<Vec<_>>(), ["", "raea overlay", "raea captions", "sound"]);
|
||||
// a layer's movie is found beside layers.json; the footage where it is
|
||||
assert_eq!(tl.media[1].path, Path::new("/out/edit/captions.prores.mov"));
|
||||
assert_eq!(tl.media[0].path, Path::new("/m/a.mp4"));
|
||||
// the footage carries its own sound at its gain (-6 dB), so that sound isn't a clip of its own; the music is
|
||||
let foot = &tl.tracks[0].clips[0];
|
||||
assert!((foot.volume - 10f64.powf(-6.0 / 20.0)).abs() < 1e-9);
|
||||
assert_eq!(tl.tracks[3].clips.len(), 1);
|
||||
assert!((tl.tracks[3].clips[0].volume - 10f64.powf(-12.0 / 20.0)).abs() < 1e-9 && tl.tracks[3].clips[0].fade_out == 0.5);
|
||||
// the layers' movies fill the canvas, silent
|
||||
let cap = &tl.tracks[2].clips[0];
|
||||
assert_eq!((cap.start, cap.frames, cap.volume, cap.place.scale, cap.place.x, cap.place.y), (10, 30, 0.0, 1.0, 540.0, 960.0));
|
||||
// footage with no linked sound plays silent
|
||||
let mut quiet = l.clone();
|
||||
quiet.tracks[2].clips[0].link = None;
|
||||
quiet.tracks[3].clips.remove(0);
|
||||
assert_eq!(from_layers::timeline(&quiet, Path::new("/out/edit")).0.tracks[0].clips[0].volume, 0.0);
|
||||
}
|
||||
|
||||
/// staticFile("x.mp4") is "/media/x.mp4" in the manifest: the export finds it where the render did, in media/ beside
|
||||
/// the edit, as it finds a relative path; an absolute path stays as it is
|
||||
/// CC2f: a footage clip's keys in CapCut's terms, around the cut its first frame shows: a steady move is its two ends,
|
||||
/// a move inside a card keeps the card's cut, and a cut that changes (the split close) is said
|
||||
#[test]
|
||||
fn a_static_file_is_found_in_the_edits_media_folder() {
|
||||
let dir = std::env::temp_dir().join(format!("raea-capcut-resolve-{}", std::process::id()));
|
||||
std::fs::create_dir_all(dir.join("media")).unwrap();
|
||||
std::fs::write(dir.join("media/a.mp4"), "").unwrap();
|
||||
let want = dunce::canonicalize(&dir.join("media/a.mp4")).unwrap();
|
||||
assert_eq!(resolve(&dir, "/media/a.mp4"), want);
|
||||
assert_eq!(resolve(&dir, "media/a.mp4"), want);
|
||||
assert_eq!(resolve(&dir, want.to_str().unwrap()), want);
|
||||
std::fs::remove_dir_all(&dir).unwrap();
|
||||
fn keyed_footage_is_keyed_around_its_first_cut() {
|
||||
use raea_app_layers::model::Key;
|
||||
let canvas = (1080.0, 1920.0);
|
||||
let key = |frame: i64, bx: [f64; 4], clip: Option<[f64; 4]>| Key { frame, r#box: bx, clip, position: None, opacity: 1.0 };
|
||||
let first = |c: &LClip| raea_app_layers::plan::picture(&c.r#box.unwrap(), &c.clip, "cover", &None, (1080.0, 1920.0), canvas).0.kept;
|
||||
// a picture in picture sliding right 10 px a frame: its two ends
|
||||
let slide = LClip { r#box: Some([100.0, 500.0, 400.0, 400.0]), keys: (0..24).map(|f| key(f, [100.0 + 10.0 * f as f64, 500.0, 400.0, 400.0], None)).collect(), ..LClip::new("v".into(), 0, 0, 24, 0.0) };
|
||||
let (got, changes) = keys(&slide, "cover", first(&slide), (1080.0, 1920.0), canvas);
|
||||
assert!(!changes && got.len() == 2 && got[1].0 == 23 && (got[1].1.x - got[0].1.x - 230.0).abs() < 1e-6);
|
||||
// inside a card that moves with it, cutting its sides: the same cut throughout, keyed as it moves
|
||||
let card = |f: i64| key(f, [80.0 + 4.0 * f as f64, 300.0, 600.0, 1066.7], Some([140.0 + 4.0 * f as f64, 300.0, 480.0, 1066.7]));
|
||||
let carded = LClip { r#box: Some(card(0).r#box), clip: card(0).clip, keys: (0..24).map(card).collect(), ..LClip::new("v".into(), 0, 0, 24, 0.0) };
|
||||
let (got, changes) = keys(&carded, "cover", first(&carded), (1080.0, 1920.0), canvas);
|
||||
assert!(!changes && got.len() == 2 && got.iter().all(|(_, p)| p.crop[0] > 0.09 && p.crop[2] < 0.91));
|
||||
// the split close: its box shrinking to the seam changes what's cut, which CapCut's crop can't follow
|
||||
let split = |f: i64, h: f64| key(f, [0.0, -260.0 * (1920.0 - h) / 1060.0, 1080.0, 1920.0], (h < 1920.0).then_some([0.0, 0.0, 1080.0, h]));
|
||||
let closing = LClip { r#box: Some(split(0, 1920.0).r#box), keys: vec![split(0, 1920.0), split(12, 860.0)], ..LClip::new("v".into(), 0, 0, 24, 0.0) };
|
||||
let (got, changes) = keys(&closing, "cover", first(&closing), (1080.0, 1920.0), canvas);
|
||||
assert!(changes && got.len() == 2 && got[1].1.crop == [0.0, 0.0, 1.0, 1.0]);
|
||||
}
|
||||
@@ -7,7 +7,6 @@ publish = false
|
||||
description = "`raea check`: the floor's measurable lines on an export, ranked P0-P3"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
# taste.ts rules, as the raea CLI evaluates them (docs/projects.feature PJ0)
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
# a transcript's words, read as `raea world` reads them (docs/direction.feature DR1)
|
||||
@@ -19,6 +18,12 @@ raea-io-trace = { path = "../../io/trace" }
|
||||
raea-io-ffmpeg = { path = "../../io/ffmpeg" }
|
||||
# caption contrast and loudness, measured as `raea world` measures a render (DR2)
|
||||
raea-sys-measure = { path = "../../systems/measure" }
|
||||
# what it reads of a video, through FFmpeg or raea's own decoders where it isn't installed
|
||||
raea-app-check-read = { path = "read" }
|
||||
# who can fix what it finds: the encode's or the picture's own, carried, a source (split out to keep this crate small)
|
||||
raea-app-check-cause = { path = "cause" }
|
||||
# the text rules on a render's manifest (split out: raea render holds its own text to them)
|
||||
raea-app-check-text = { path = "text" }
|
||||
# the flashing screen (WCAG 2.3.1), split out to keep this crate small
|
||||
raea-app-check-flash = { path = "flash" }
|
||||
# what the person sent from the raea app, handed to the agent (split out to keep this crate small)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "raea-app-check-cause"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "Who can fix what raea check finds: the encode's or the picture's own, carried from an earlier export, a source rather than a delivery"
|
||||
|
||||
[dependencies]
|
||||
# a project's record of renders and checks (DR3)
|
||||
raea-core-facts = { path = "../../../core/facts" }
|
||||
image = { version = "0.25", default-features = false, features = ["png"] }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1"
|
||||
@@ -0,0 +1,174 @@
|
||||
//! Who can fix what `raea check` finds, so a round is spent only on what another render can change (11-19: two
|
||||
//! Telluride projects took nine renders, five of them for findings no render could move). Three things, for any rule:
|
||||
//!
|
||||
//! - **Introduced or there already.** A rule an encode can cause is measured again on the composition's own frames,
|
||||
//! rendered without encoding (`unencoded`), and the export is set against them (`against`): what the picture already
|
||||
//! held is the footage's (a note), what the export adds is the encode's (the error, with a fix raea has).
|
||||
//! - **Carried.** A finding an earlier export of the same composition had at the same moment (`earlier`, `carried`)
|
||||
//! says since when: the change between them didn't move it, so doing that again won't.
|
||||
//! - **A source isn't a delivery.** A take or a download checked on its own (`is_source`) isn't held to a delivery's
|
||||
//! loudness target.
|
||||
//!
|
||||
//! None of it changes what a rule measures or where it draws the line.
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use raea_core_facts::{Finding, record};
|
||||
|
||||
pub type R<T> = Result<T, String>;
|
||||
|
||||
/// Whether a record entry is the render that wrote `out` (a path as the record names it)
|
||||
fn rendered(e: &record::Entry, out: &str) -> bool {
|
||||
e.by == "raea render" && e.out.as_deref() == Some(out)
|
||||
}
|
||||
|
||||
/// The composition a video was rendered from, and its project: the newest `raea render` writing it in the project's
|
||||
/// record (DR3). None outside a project, or for a video no render there wrote (a take, a download).
|
||||
pub fn composition_of(video: &Path) -> Option<(PathBuf, PathBuf)> {
|
||||
let project = record::up(video, ".raea/project")?;
|
||||
let want = record::rel(&project, video);
|
||||
let made = record::read(&project).into_iter().rev().find(|e| e.kind == "video" && rendered(e, &want))?;
|
||||
let of = project.join(&made.of);
|
||||
of.is_file().then_some((project, of))
|
||||
}
|
||||
|
||||
/// Whether a file is one of a project's sources (a take or a download under assets/ or media/ that no render wrote):
|
||||
/// it isn't a delivery, so a delivery's rules (its loudness target) don't hold it
|
||||
pub fn is_source(video: &Path) -> bool {
|
||||
let Some(project) = record::up(video, ".raea/project") else { return false };
|
||||
let me = record::rel(&project, video);
|
||||
(me.starts_with("assets/") || me.starts_with("media/")) && !record::read(&project).iter().any(|e| rendered(e, &me))
|
||||
}
|
||||
|
||||
/// Luma as a decoder of raea's export gives it to the check (BT.709, full range: FFmpeg's format=gray of the
|
||||
/// encoder's limited-range picture), from 8-bit RGBA `width` wide, its top-left `w` x `h`
|
||||
pub fn luma(rgba: &[u8], width: usize, w: usize, h: usize) -> Vec<u8> {
|
||||
let mut y = Vec::with_capacity(w * h);
|
||||
for r in 0..h {
|
||||
for p in rgba[r * width * 4..][..w * 4].chunks_exact(4) {
|
||||
y.push((0.2126 * p[0] as f32 + 0.7152 * p[1] as f32 + 0.0722 * p[2] as f32).round().clamp(0.0, 255.0) as u8);
|
||||
}
|
||||
}
|
||||
y
|
||||
}
|
||||
|
||||
/// `frames` as `comp` draws them, never encoded, as luma `w` x `h` (top-left): `raea render COMP --at F,... -o DIR/`
|
||||
/// (PNG) run by `raea` from the project, kept out of its record as the quick check's stills are
|
||||
pub fn unencoded(raea: &Path, project: &Path, comp: &Path, frames: &[i64], w: usize, h: usize) -> R<Vec<Vec<u8>>> {
|
||||
let mut wanted: Vec<i64> = frames.to_vec();
|
||||
wanted.sort_unstable();
|
||||
wanted.dedup();
|
||||
let tmp = std::env::temp_dir().join(format!("raea-unencoded-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
std::fs::create_dir_all(&tmp).map_err(|e| format!("{}: {e}", tmp.display()))?;
|
||||
let at = wanted.iter().map(|f| f.to_string()).collect::<Vec<_>>().join(",");
|
||||
let read = (|| {
|
||||
let run = Command::new(raea).arg("render").arg(comp).args(["--at", &at, "-o"]).arg(format!("{}/", tmp.display())).current_dir(project).env("RAEA_RECORD", "off").output().map_err(|e| e.to_string())?;
|
||||
let mut pngs: Vec<PathBuf> = std::fs::read_dir(&tmp).map_err(|e| e.to_string())?.filter_map(|e| e.ok().map(|e| e.path())).filter(|p| p.extension().is_some_and(|x| x == "png")).collect();
|
||||
pngs.sort();
|
||||
if pngs.len() != wanted.len() {
|
||||
let said = String::from_utf8_lossy(&run.stderr).lines().chain(String::from_utf8_lossy(&run.stdout).lines()).find(|l| l.contains("REFUSED") || l.contains("rror")).unwrap_or("").to_string();
|
||||
return Err(format!("its render gave {} of {} frames {said}", pngs.len(), wanted.len()).trim_end().to_string());
|
||||
}
|
||||
let mut by_frame = std::collections::HashMap::new();
|
||||
for (f, p) in wanted.iter().zip(&pngs) {
|
||||
let img = image::open(p).map_err(|e| format!("{}: {e}", p.display()))?.to_rgba8();
|
||||
let (iw, ih) = (img.width() as usize, img.height() as usize);
|
||||
if iw < w || ih < h {
|
||||
return Err(format!("it draws {iw}x{ih}, smaller than the export's {w}x{h}"));
|
||||
}
|
||||
by_frame.insert(*f, luma(img.as_raw(), iw, w, h));
|
||||
}
|
||||
Ok(frames.iter().map(|f| by_frame[f].clone()).collect())
|
||||
})();
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
read
|
||||
}
|
||||
|
||||
/// The frame a check reads for each sample taken every `every` seconds from 0: the last frame before the sample's
|
||||
/// middle, as ffmpeg's fps filter picks it (and raea-app-check-read's readers), held to the picture's `last` frame
|
||||
pub fn sampled(samples: usize, every: f64, fps: f64, last: i64) -> Vec<i64> {
|
||||
(0..samples).map(|k| (((k as f64 + 0.5) * every * fps).ceil() as i64 - 1).clamp(0, last.max(0))).collect()
|
||||
}
|
||||
|
||||
/// A sampled measure of the export against the same measure of the unencoded frames.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct Against {
|
||||
/// samples over the rule's line that the export made worse by more than its noise
|
||||
pub worse: usize,
|
||||
/// samples over the line before encoding: the picture's own
|
||||
pub before: usize,
|
||||
/// samples compared
|
||||
pub of: usize,
|
||||
/// the mean of the export's measure less the unencoded one's
|
||||
pub added: f64,
|
||||
}
|
||||
|
||||
impl Against {
|
||||
/// Whether the export added to it, beyond what a clean encode moves: at least three samples (and a tenth) worse,
|
||||
/// and more than half the noise on average
|
||||
pub fn by_encode(&self, noise: f64) -> bool {
|
||||
self.worse >= 3usize.max(self.of / 10) && self.added > noise / 2.0
|
||||
}
|
||||
|
||||
/// The first sample the export made worse
|
||||
pub fn first(out: &[Option<f64>], before: &[Option<f64>], line: f64, noise: f64) -> Option<usize> {
|
||||
out.iter().zip(before).position(|(o, b)| o.unwrap_or(0.0) > line && o.unwrap_or(0.0) - b.unwrap_or(0.0) > noise)
|
||||
}
|
||||
}
|
||||
|
||||
/// Per sample, the export's measure against the unencoded frames' (None: nothing to measure, read as 0), over a
|
||||
/// rule's `line`, where a clean encode moves it at most `noise`
|
||||
pub fn against(out: &[Option<f64>], before: &[Option<f64>], line: f64, noise: f64) -> Against {
|
||||
let n = out.len().min(before.len());
|
||||
let at = |s: &[Option<f64>], i: usize| s[i].unwrap_or(0.0);
|
||||
let worse = (0..n).filter(|&i| at(out, i) > line && at(out, i) - at(before, i) > noise).count();
|
||||
let was = (0..n).filter(|&i| at(before, i) > line).count();
|
||||
let added = (0..n).map(|i| at(out, i) - at(before, i)).sum::<f64>() / n.max(1) as f64;
|
||||
Against { worse, before: was, of: n, added }
|
||||
}
|
||||
|
||||
/// The newest check, in the project's record, of an earlier export of the composition `video` was rendered from
|
||||
pub fn earlier(video: &Path) -> Option<record::Entry> {
|
||||
let project = record::up(video, ".raea/project")?;
|
||||
let me = record::rel(&project, video);
|
||||
let entries = record::read(&project);
|
||||
let made = entries.iter().rposition(|e| rendered(e, &me))?;
|
||||
// the composition's exports rendered before this one; a versioned copy (NAME-v2.tsx) is the same piece
|
||||
let stem = |of: &str| piece(&Path::new(of).file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or_default());
|
||||
let comp = stem(&entries[made].of);
|
||||
let exports: Vec<String> = entries[..made].iter().filter(|e| e.by == "raea render" && e.kind == "video" && stem(&e.of) == comp).filter_map(|e| e.out.clone()).filter(|o| *o != me).collect();
|
||||
entries.into_iter().rev().find(|e| e.by == "raea check" && exports.contains(&e.of))
|
||||
}
|
||||
|
||||
/// A composition's name without its version: walkaround-v2 is walkaround
|
||||
pub fn piece(stem: &str) -> String {
|
||||
match stem.rfind("-v") {
|
||||
Some(i) if i + 2 < stem.len() && stem[i + 2..].bytes().all(|b| b.is_ascii_digit()) => stem[..i].to_string(),
|
||||
_ => stem.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The same finding in another export: the same rule, about the same thing, at the same moment (within a second; a
|
||||
/// finding about the whole piece matches one about the whole piece). Its words may differ ("worst 13%", "worst 15%").
|
||||
pub fn alike(a: &Finding, b: &Finding, fps: f64) -> bool {
|
||||
let about = |f: &Finding| f.about.iter().map(|a| a.key.clone().unwrap_or_else(|| a.name.clone())).collect::<Vec<_>>();
|
||||
a.check == b.check && about(a) == about(b) && match (a.frames, b.frames) {
|
||||
(Some([x, _]), Some([y, _])) => ((x - y).abs() as f64) <= fps.max(1.0),
|
||||
(None, None) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Each finding an earlier check had at the same moment says so, and that its fix hasn't moved it: rank and words
|
||||
/// otherwise as measured
|
||||
pub fn carried(now: &mut [Finding], before: &record::Entry, fps: f64) {
|
||||
for f in now.iter_mut() {
|
||||
if before.findings.iter().any(|b| alike(b, f, fps)) {
|
||||
f.says.push_str(&format!(" [also in {} ({}): what changed between them didn't move it]", before.of, before.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -0,0 +1,107 @@
|
||||
use super::*;
|
||||
use raea_core_facts::Level;
|
||||
|
||||
// The 28 samples `raea check` takes of the 11-16 Telluride walkaround (55.8 s, 24 fps, phone footage), as its
|
||||
// blotching measures them: rendered to PNG with no encoding (BEFORE), those PNGs through x264 crf 12, and raea's own
|
||||
// exports at --quality high and master. Blotching's line is 0.009; x264 moved a sample at most 0.005.
|
||||
const BEFORE: [Option<f64>; 28] = [Some(0.0), None, Some(0.052), Some(0.062), None, Some(0.062), None, None, Some(0.076), Some(0.009), Some(0.03), Some(0.039), Some(0.068), None, None, None, None, Some(0.077), Some(0.062), None, None, Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0)];
|
||||
const X264: [Option<f64>; 28] = [Some(0.0), None, Some(0.052), Some(0.062), None, Some(0.059), None, None, Some(0.078), Some(0.008), Some(0.028), Some(0.034), Some(0.071), None, None, None, None, Some(0.078), Some(0.062), None, Some(0.039), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0)];
|
||||
const HIGH: [Option<f64>; 28] = [Some(0.0), None, Some(0.042), Some(0.024), Some(0.052), Some(0.064), Some(0.05), None, Some(0.126), Some(0.063), Some(0.061), Some(0.122), Some(0.088), Some(0.04), Some(0.029), Some(0.047), Some(0.044), Some(0.096), Some(0.09), None, Some(0.029), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0)];
|
||||
const MASTER: [Option<f64>; 28] = [Some(0.0), None, Some(0.026), Some(0.002), None, Some(0.03), None, None, Some(0.022), None, None, None, None, None, None, None, None, Some(0.071), Some(0.053), None, None, Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0)];
|
||||
const LINE: f64 = 0.009;
|
||||
const NOISE: f64 = 0.005;
|
||||
|
||||
/// What the picture already held is told from what the encode added: a clean encode and raea's master add nothing,
|
||||
/// its high adds to 14 of 28 samples, and 9 samples hold the footage's own either way
|
||||
#[test]
|
||||
fn the_picture_s_own_is_told_from_the_encode_s() {
|
||||
let clean = against(&X264, &BEFORE, LINE, NOISE);
|
||||
assert!(!clean.by_encode(NOISE), "{clean:?}");
|
||||
assert!(clean.added.abs() < 0.002, "{clean:?}");
|
||||
let high = against(&HIGH, &BEFORE, LINE, NOISE);
|
||||
assert!(high.by_encode(NOISE), "{high:?}");
|
||||
assert_eq!((high.worse, high.before, high.of), (14, 9, 28));
|
||||
assert_eq!(Against::first(&HIGH, &BEFORE, LINE, NOISE), Some(4));
|
||||
let master = against(&MASTER, &BEFORE, LINE, NOISE);
|
||||
assert!(!master.by_encode(NOISE), "{master:?}");
|
||||
assert_eq!(master.worse, 0);
|
||||
// a small, even addition over a clean picture still counts (VideoToolbox over a dark render, 10-25)
|
||||
assert!(against(&[Some(0.013); 16], &[Some(0.003); 16], LINE, NOISE).by_encode(NOISE));
|
||||
}
|
||||
|
||||
/// The frame read for each sample is the last before its middle, as the fps filter picks it
|
||||
#[test]
|
||||
fn the_sampled_frames_are_the_check_s() {
|
||||
assert_eq!(sampled(3, 2.0, 24.0, 1338), vec![23, 71, 119]);
|
||||
assert_eq!(sampled(2, 2.0, 30.0, 1000), vec![29, 89]);
|
||||
assert_eq!(sampled(2, 2.0, 30000.0 / 1001.0, 1000), vec![29, 89]);
|
||||
assert_eq!(sampled(2, 2.0, 24.0, 50), vec![23, 50]);
|
||||
}
|
||||
|
||||
/// Luma as the check reads raea's export: BT.709 weights, full range, cropped to the top-left
|
||||
#[test]
|
||||
fn luma_is_bt709_cropped() {
|
||||
let px = |r: u8, g: u8, b: u8| [r, g, b, 255];
|
||||
let rgba: Vec<u8> = [px(255, 255, 255), px(0, 0, 0), px(255, 0, 0), px(0, 255, 0)].concat();
|
||||
assert_eq!(luma(&rgba, 2, 2, 2), vec![255, 0, 54, 182]);
|
||||
assert_eq!(luma(&rgba, 2, 1, 2), vec![255, 54]);
|
||||
}
|
||||
|
||||
fn finding(check: &str, frame: Option<i64>, says: &str) -> Finding {
|
||||
let f = Finding::new(check, Level::Error, says, "raea check");
|
||||
match frame {
|
||||
Some(n) => f.frames(n, n + 1),
|
||||
None => f,
|
||||
}
|
||||
}
|
||||
|
||||
/// A finding is carried when the same rule finds the same thing at the same moment, whatever its numbers say
|
||||
#[test]
|
||||
fn a_carried_finding_is_the_same_rule_at_the_same_moment() {
|
||||
let fps = 24.0;
|
||||
assert!(alike(&finding("blotching", Some(96), "worst 13%"), &finding("blotching", Some(96), "worst 15%"), fps));
|
||||
assert!(alike(&finding("clipping", Some(624), "9 runs"), &finding("clipping", Some(640), "6 runs"), fps));
|
||||
assert!(!alike(&finding("clipping", Some(624), "9 runs"), &finding("clipping", Some(1104), "11 runs"), fps));
|
||||
assert!(!alike(&finding("clipping", Some(624), "x"), &finding("dropout", Some(624), "x"), fps));
|
||||
assert!(alike(&finding("brand", None, "a"), &finding("brand", None, "b"), fps));
|
||||
assert_eq!(piece("walkaround-v2"), "walkaround");
|
||||
assert_eq!(piece("edit-video"), "edit-video");
|
||||
assert_eq!(piece("telluride-v12"), "telluride");
|
||||
}
|
||||
|
||||
/// A project whose record holds two renders of one composition and a check of the first: the second's check finds
|
||||
/// that one, its blotching carried and its clipping new; a take under assets/ is a source, an export isn't
|
||||
#[test]
|
||||
fn the_earlier_check_is_of_the_composition_s_other_export() {
|
||||
let dir = std::env::temp_dir().join(format!("raea-cause-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
for d in [".raea/record", "out", "assets/footage", "compositions"] {
|
||||
std::fs::create_dir_all(dir.join(d)).unwrap();
|
||||
}
|
||||
std::fs::write(dir.join(".raea/project"), "[project]\n\tid = pj_test\n").unwrap();
|
||||
for f in ["out/a-v1.mp4", "out/a-v2.mp4", "assets/footage/take.mov", "compositions/a.tsx", "compositions/a-v2.tsx"] {
|
||||
std::fs::write(dir.join(f), b"").unwrap();
|
||||
}
|
||||
let entry = |id: &str, by: &str, of: &str, out: Option<&str>, kind: &str, findings: Vec<Finding>| record::Entry { id: id.into(), at: 0, by: by.into(), of: of.into(), out: out.map(Into::into), kind: kind.into(), commit: None, findings, despite: vec![] };
|
||||
let entries = [
|
||||
entry("20261116-170223-a", "raea render", "compositions/a.tsx", Some("out/a-v1.mp4"), "video", vec![]),
|
||||
entry("20261116-170252-a-v1", "raea check", "out/a-v1.mp4", None, "check", vec![finding("blotching", Some(96), "worst 13%")]),
|
||||
entry("20261116-171601-a-v2", "raea render", "compositions/a-v2.tsx", Some("out/a-v2.mp4"), "video", vec![]),
|
||||
];
|
||||
for e in &entries {
|
||||
std::fs::write(dir.join(format!(".raea/record/{}.json", e.id)), serde_json::to_vec(e).unwrap()).unwrap();
|
||||
}
|
||||
let v2 = dir.join("out/a-v2.mp4");
|
||||
assert_eq!(composition_of(&v2).map(|(_, c)| c.ends_with("compositions/a-v2.tsx")), Some(true));
|
||||
let before = earlier(&v2).expect("the check of a-v1");
|
||||
assert_eq!(before.of, "out/a-v1.mp4");
|
||||
let mut now = vec![finding("blotching", Some(96), "worst 15%"), finding("clipping", Some(624), "9 runs")];
|
||||
carried(&mut now, &before, 24.0);
|
||||
assert!(now[0].says.contains("also in out/a-v1.mp4 (20261116-170252-a-v1)"), "{}", now[0].says);
|
||||
assert_eq!(now[1].says, "9 runs");
|
||||
// nothing was rendered before a-v1, so its check has no earlier one, even with a-v2's check in the record
|
||||
assert!(earlier(&dir.join("out/a-v1.mp4")).is_none());
|
||||
assert!(is_source(&dir.join("assets/footage/take.mov")));
|
||||
assert!(!is_source(&v2));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
[package]
|
||||
name = "raea-app-check-read"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "What `raea check` reads of a video: FFmpeg's probe, and raea's own decoders standing in for FFmpeg where it isn't installed"
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1"
|
||||
raea-io-home = { path = "../../../io/home" }
|
||||
raea-io-media = { path = "../../../io/media", default-features = false }
|
||||
raea-app-media = { path = "../../media" }
|
||||
# ffmpeg's flag for every decoded frame, by its version (the one read's flashing frames)
|
||||
raea-io-ffmpeg = { path = "../../../io/ffmpeg" }
|
||||
# caption contrast, as `raea world` measures it (DR2)
|
||||
raea-sys-measure = { path = "../../../systems/measure" }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
# the one read's named pipes
|
||||
libc = "0.2"
|
||||
@@ -0,0 +1,219 @@
|
||||
//! What `raea check` reads of a video: through FFmpeg where it's on the PATH (the reference its rules were tuned on),
|
||||
//! else through raea's own decoders (raea-app-media), so `raea check` works wherever `raea media probe` and `raea media
|
||||
//! loudness` do, with nothing to install. 0.1.7 refused any video without FFmpeg, which Windows never has (Shane 11-18:
|
||||
//! "can we make it so ffmpeg does work the way we need it?"). RAEA_CHECK_NATIVE=1 reads natively with FFmpeg there too;
|
||||
//! tests/parity.rs holds the two to the same answers. Each reader names the FFmpeg command it stands in for.
|
||||
pub mod once;
|
||||
pub use once::{log_level, showinfo_base, showinfo_frame};
|
||||
use raea_io_media::VideoDecoder;
|
||||
use serde_json::Value;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
pub type R<T> = Result<T, String>;
|
||||
|
||||
/// Whether to read natively: FFmpeg's ffmpeg or ffprobe isn't on the PATH, or RAEA_CHECK_NATIVE is on
|
||||
pub fn native() -> bool {
|
||||
raea_io_home::env_on("RAEA_CHECK_NATIVE") || !(on_path("ffmpeg") && on_path("ffprobe"))
|
||||
}
|
||||
|
||||
fn on_path(tool: &str) -> bool {
|
||||
let exe = if cfg!(windows) { format!("{tool}.exe") } else { tool.to_string() };
|
||||
std::env::var_os("PATH").is_some_and(|p| std::env::split_paths(&p).any(|d| d.join(&exe).is_file()))
|
||||
}
|
||||
|
||||
fn open(video: &str) -> R<(Box<dyn VideoDecoder>, raea_io_media::Info)> {
|
||||
let d = raea_app_media::open_video(Path::new(video))?;
|
||||
let info = d.info().clone();
|
||||
Ok((d, info))
|
||||
}
|
||||
|
||||
/// A luma byte as FFmpeg's format=gray gives it from a limited-range picture: full range, 16-235 spread to 0-255 and
|
||||
/// rounded (FFmpeg 9: 16 is 0, 126 is 128, 235 is 255)
|
||||
fn gray(y: u8) -> u8 {
|
||||
(((y.clamp(16, 235) as u32 - 16) * 255 + 109) / 219) as u8
|
||||
}
|
||||
|
||||
/// What `raea check` needs to know of a video before it reads it
|
||||
pub struct Probe {
|
||||
pub w: f64,
|
||||
pub h: f64,
|
||||
pub duration: f64,
|
||||
/// when the picture ends, on the clock FFmpeg's filters read: it starts at the file's first stream, sound can run on
|
||||
/// past the picture, and the container's duration counts that
|
||||
pub picture: f64,
|
||||
pub audio: bool,
|
||||
/// the picture's frames a second (0 when it doesn't say)
|
||||
pub fps: f64,
|
||||
}
|
||||
|
||||
/// The picture's size, the file's duration, where the picture ends and whether there's sound: ffprobe's stream and
|
||||
/// format entries, or raea's own probe without FFmpeg
|
||||
pub fn probe(video: &str) -> R<Probe> {
|
||||
if native() {
|
||||
let p = raea_app_media::probe_of(Path::new(video))?;
|
||||
let v = p.video.as_ref().ok_or("no video stream")?;
|
||||
let picture = p.track.as_ref().map_or(v.duration, |t| t.duration);
|
||||
return Ok(Probe { w: v.width as f64, h: v.height as f64, duration: p.duration.max(picture), picture, audio: p.audio.is_some(), fps: v.fps });
|
||||
}
|
||||
let entries = "stream=codec_type,width,height,r_frame_rate,duration,start_time:format=duration,start_time";
|
||||
let out = Command::new("ffprobe").args(["-v", "error", "-show_entries", entries, "-of", "json", video]).output().map_err(|e| format!("ffprobe: {e}"))?;
|
||||
let v: Value = serde_json::from_slice(&out.stdout).map_err(|e| format!("ffprobe: {e}"))?;
|
||||
let streams = v["streams"].as_array().cloned().unwrap_or_default();
|
||||
let vid = streams.iter().find(|s| s["codec_type"] == "video").ok_or("no video stream")?;
|
||||
let seconds = |field: &Value| -> Option<f64> { field.as_str()?.parse().ok() };
|
||||
let duration = seconds(&v["format"]["duration"]).unwrap_or(0.0);
|
||||
let origin = seconds(&v["format"]["start_time"]).unwrap_or(0.0);
|
||||
let picture = match seconds(&vid["duration"]) {
|
||||
Some(length) => seconds(&vid["start_time"]).unwrap_or(origin) - origin + length,
|
||||
None => last_packet_end(video).map_or(duration, |end| end - origin),
|
||||
};
|
||||
let audio = streams.iter().any(|s| s["codec_type"] == "audio");
|
||||
let fps = vid["r_frame_rate"].as_str().and_then(|r| {
|
||||
let (n, d) = r.split_once('/').unwrap_or((r, "1"));
|
||||
Some(n.parse::<f64>().ok()? / d.parse::<f64>().ok().filter(|d| *d > 0.0)?)
|
||||
});
|
||||
Ok(Probe { w: vid["width"].as_f64().unwrap_or(1920.0), h: vid["height"].as_f64().unwrap_or(1080.0), duration, picture, audio, fps: fps.unwrap_or(0.0) })
|
||||
}
|
||||
|
||||
/// Where the picture's last packet ends, for a container that doesn't state the video stream's own length (Matroska)
|
||||
fn last_packet_end(video: &str) -> Option<f64> {
|
||||
let out = Command::new("ffprobe").args(["-v", "error", "-select_streams", "v:0", "-show_entries", "packet=pts_time,duration_time", "-of", "csv=p=0", video]).output().ok()?;
|
||||
String::from_utf8_lossy(&out.stdout)
|
||||
.lines()
|
||||
.filter_map(|l| {
|
||||
let mut parts = l.split(',');
|
||||
let t: f64 = parts.next()?.trim().parse().ok()?;
|
||||
Some(t + parts.next().and_then(|d| d.trim().parse::<f64>().ok()).unwrap_or(0.0))
|
||||
})
|
||||
.max_by(f64::total_cmp)
|
||||
}
|
||||
|
||||
/// `ffmpeg -i V -vf scale=32:18:flags=area,format=gray -f rawvideo -` averaged a frame, and the rate `ffmpeg -i` says
|
||||
/// (defects.rs lumas): each frame's mean light, 0 to 1, and the frames a second
|
||||
pub fn lumas(video: &str) -> R<(Vec<f32>, f64)> {
|
||||
let (mut d, info) = open(video)?;
|
||||
let mut out = Vec::new();
|
||||
for (_, at) in raea_app_media::frames_of(Path::new(video), &info, None, None) {
|
||||
let (y, ..) = raea_app_media::yuv(d.frame_nv12_at(at)?);
|
||||
out.push(y.iter().map(|&p| gray(p) as f32).sum::<f32>() / (y.len().max(1) as f32 * 255.0));
|
||||
}
|
||||
Ok((out, raea_app_media::standard_fps(info.fps)))
|
||||
}
|
||||
|
||||
/// `ffmpeg -i V -vf fps=0.5,crop=W:H:0:0,format=gray -f rawvideo -` (picture.rs blotching): every 2 s, the picture's
|
||||
/// top-left W x H in grey
|
||||
pub fn crops(video: &str, w: usize, h: usize, mut each: impl FnMut(&[u8])) -> R<()> {
|
||||
let (mut d, info) = open(video)?;
|
||||
let frames = raea_app_media::frames_of(Path::new(video), &info, None, None);
|
||||
for (tick, _) in raea_app_media::times(raea_app_media::video_span(Path::new(video), &info), None, None, 0.5) {
|
||||
// the last frame before the tick's middle, as the fps filter picks it (by the frames' own times: a read at the
|
||||
// middle less a microsecond came back a frame late)
|
||||
let Some(&(_, at)) = frames.iter().take_while(|(pts, _)| *pts < tick + 1.0).last() else { continue };
|
||||
let f = d.frame_nv12_at(at)?;
|
||||
let fw = f.width as usize;
|
||||
let (y, ..) = raea_app_media::yuv(f);
|
||||
let crop: Vec<u8> = (0..h.min(y.len() / fw.max(1))).flat_map(|r| y[r * fw..r * fw + w.min(fw)].iter().map(|&p| gray(p))).collect();
|
||||
each(&crop);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// flash.rs's graph (showinfo, the picture at W x H area-sampled beside it point-sampled, rgb24): every frame with
|
||||
/// its time, until `each` says stop. How many frames were read.
|
||||
pub fn flash_frames(video: &str, w: usize, h: usize, mut each: impl FnMut(f64, &[u8])) -> R<usize> {
|
||||
let (mut d, info) = open(video)?;
|
||||
let mut buf = vec![0u8; w * 2 * h * 3];
|
||||
let mut n = 0;
|
||||
for (pts, at) in raea_app_media::frames_of(Path::new(video), &info, None, None) {
|
||||
let f = d.frame_at(at)?;
|
||||
let (sw, sh) = (f.width as usize, f.height as usize);
|
||||
for y in 0..h {
|
||||
let (y0, y1) = (y * sh / h, ((y + 1) * sh / h).max(y * sh / h + 1));
|
||||
for x in 0..w {
|
||||
let (x0, x1) = (x * sw / w, ((x + 1) * sw / w).max(x * sw / w + 1));
|
||||
let mut sum = [0u32; 3];
|
||||
for sy in y0..y1 {
|
||||
for p in f.rgba[(sy * sw + x0) * 4..(sy * sw + x1) * 4].chunks_exact(4) {
|
||||
(0..3).for_each(|c| sum[c] += p[c] as u32);
|
||||
}
|
||||
}
|
||||
let count = ((y1 - y0) * (x1 - x0)) as u32;
|
||||
let near = ((y * sh + sh / 2) / h * sw + (x * sw + sw / 2) / w) * 4;
|
||||
for c in 0..3 {
|
||||
buf[(y * w * 2 + x) * 3 + c] = ((sum[c] + count / 2) / count) as u8;
|
||||
buf[(y * w * 2 + w + x) * 3 + c] = f.rgba[near + c];
|
||||
}
|
||||
}
|
||||
}
|
||||
each(pts, &buf);
|
||||
n += 1;
|
||||
}
|
||||
Ok(n)
|
||||
}
|
||||
|
||||
/// `ffmpeg -i V -vn -ac 1 -ar RATE -f f32le -` (sound.rs sound): the sound folded to mono at `rate`
|
||||
pub fn mono(video: &str, rate: u32) -> R<Vec<f32>> {
|
||||
if native() {
|
||||
return Ok(raea_app_media::audio_folded(Path::new(video), rate, true, None, None, false)?.channels.swap_remove(0));
|
||||
}
|
||||
ffmpeg_f32(video, 1, rate)
|
||||
}
|
||||
|
||||
/// `ffmpeg -i V -vn -ac N -ar R -f f32le -`: the sound as N interleaved channels of floats
|
||||
fn ffmpeg_f32(video: &str, channels: u32, rate: u32) -> R<Vec<f32>> {
|
||||
let out = Command::new("ffmpeg").args(["-v", "error", "-i", video, "-vn", "-ac", &channels.to_string(), "-ar", &rate.to_string(), "-f", "f32le", "-"]).output().map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
if !out.status.success() {
|
||||
return Err(format!("ffmpeg couldn't read the sound of {video}: {}", String::from_utf8_lossy(&out.stderr).trim()));
|
||||
}
|
||||
Ok(out.stdout.chunks_exact(4).map(|b| f32::from_le_bytes([b[0], b[1], b[2], b[3]])).collect())
|
||||
}
|
||||
|
||||
/// `ffmpeg -i V -vn -ac 2 -ar R -f f32le -` (defects.rs clipping): each channel at its own level. Clipping is a
|
||||
/// channel's: on the mono fold (L + R) * 0.707 a centred voice reads 3 dB hotter than either side, and a master at
|
||||
/// -1.6 dBTP read as full scale (11-19, the walkaround's flat tops).
|
||||
pub fn channels(video: &str, rate: u32) -> R<Vec<Vec<f32>>> {
|
||||
if native() {
|
||||
return Ok(raea_app_media::audio_folded(Path::new(video), rate, false, None, None, false)?.channels);
|
||||
}
|
||||
let x = ffmpeg_f32(video, 2, rate)?;
|
||||
Ok(vec![x.iter().step_by(2).copied().collect(), x.iter().skip(1).step_by(2).copied().collect()])
|
||||
}
|
||||
|
||||
/// `ffmpeg -i V -vn -af ebur128=metadata=1,ametadata=print:key=lavfi.r128.M:file=- -f null -` (sound.rs sound): the
|
||||
/// momentary loudness (400 ms) every 100 ms, each time and its LUFS
|
||||
pub fn meter(video: &str) -> R<(Vec<f64>, Vec<f64>)> {
|
||||
let a = raea_app_media::audio_folded(Path::new(video), raea_io_media::audio::RATE, false, None, None, false)?;
|
||||
let n = (a.duration() * 10.0).floor() as usize;
|
||||
Ok(((0..n).map(|i| i as f64 / 10.0).collect(), raea_io_media::audio::momentary(&a, 10.0, n)))
|
||||
}
|
||||
|
||||
/// `ffmpeg -i V -an -vf freezedetect=n=NOISE_DB:d=MIN -f null -`'s log (sound.rs freezes reads it either way)
|
||||
pub fn freezes(video: &str, noise_db: f64, min: f64) -> R<String> {
|
||||
let found = raea_app_media::freezes(Path::new(video), 10f64.powf(noise_db / 20.0), min)?;
|
||||
Ok(found.into_iter().map(|(s, end)| match end {
|
||||
Some((d, e)) => format!("freeze_start: {s}\nfreeze_duration: {d}\nfreeze_end: {e}\n"),
|
||||
None => format!("freeze_start: {s}\n"),
|
||||
}).collect())
|
||||
}
|
||||
|
||||
/// raea_sys_measure::contrast's read (`ffmpeg -ss AT -i V -frames:v 1 -vf crop=... -pix_fmt rgb24`): a text's contrast
|
||||
/// against what's behind it, None when the crop falls outside the frame
|
||||
pub fn contrast(video: &str, at: f64, crop: [u32; 4], color: &str) -> Option<f64> {
|
||||
let [x, y, w, h] = [crop[0] & !1, crop[1] & !1, crop[2].max(2) & !1, crop[3].max(2) & !1].map(|v| v as usize);
|
||||
let (mut d, _) = open(video).ok()?;
|
||||
let f = d.frame_at(at).ok()?;
|
||||
let fw = f.width as usize;
|
||||
if x + w > fw || y + h > f.height as usize {
|
||||
return None;
|
||||
}
|
||||
let rgb: Vec<u8> = (y..y + h).flat_map(|r| f.rgba[(r * fw + x) * 4..(r * fw + x + w) * 4].chunks_exact(4).flat_map(|p| [p[0], p[1], p[2]]).collect::<Vec<_>>()).collect();
|
||||
raea_sys_measure::ratio_behind(&rgb, raea_sys_measure::lum(raea_sys_measure::rgb_of(color)))
|
||||
}
|
||||
|
||||
/// raea_sys_measure::loudness's read (`ffmpeg -i V -vn -af ebur128=peak=true -f null -`): the integrated loudness and
|
||||
/// true peak, None when there's no sound
|
||||
pub fn loudness(video: &str) -> Option<(f64, Option<f64>)> {
|
||||
let a = raea_app_media::audio_folded(Path::new(video), raea_io_media::audio::RATE, false, None, None, false).ok().filter(|a| a.len() > 0)?;
|
||||
Some((raea_io_media::audio::lufs(&a), Some(raea_io_media::audio::true_peak_db(&a))))
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
//! The picture read once for four of raea check's rules (11-19: flashing, freezes, flash frames and blotching each
|
||||
//! decoded the whole file, 3.7 s apiece on a 56 s export, and decoding is the machine's whole CPU, so reading them at
|
||||
//! the same time saved nothing). One FFmpeg decodes it and splits the frames into the four filter chains the rules
|
||||
//! were tuned on, each to its own output with its own options as when it ran alone, so each rule reads the same bytes:
|
||||
//!
|
||||
//! - the flashing screen's area- and point-sampled frames (showinfo, rgb24, passthrough) to stdout, their times on stderr;
|
||||
//! - freezedetect into a null output, its findings on stderr;
|
||||
//! - each frame's 32x18 grey (the flash-frame rule) to a named pipe;
|
||||
//! - every 2 s the grey crop blotching scores, to another.
|
||||
//!
|
||||
//! Unix only (named pipes); elsewhere, and where FFmpeg isn't installed, the rules read on their own as before.
|
||||
#[cfg(unix)]
|
||||
use std::io::{BufRead, Read};
|
||||
#[cfg(unix)]
|
||||
use std::path::Path;
|
||||
#[cfg(unix)]
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
use crate::R;
|
||||
|
||||
/// What the one read gave the rules beside the frames it handed on
|
||||
pub struct Once {
|
||||
/// the flashing screen's frames read, and whether one came without its time (the read was stopped)
|
||||
pub frames: usize,
|
||||
pub lost: bool,
|
||||
/// FFmpeg ran to its end
|
||||
pub ok: bool,
|
||||
/// errors decoding the picture, and the first of them
|
||||
pub errors: usize,
|
||||
pub first: String,
|
||||
/// freezedetect's lines
|
||||
pub freezes: String,
|
||||
/// each frame's mean brightness, 0 to 1 (defects.rs lumas)
|
||||
pub lumas: Vec<f32>,
|
||||
}
|
||||
|
||||
/// A frame's number and time from showinfo's log, exact: its `pts` in ticks of the time base. `pts_time` is rounded to six
|
||||
/// significant digits, which is enough to push a legal third flash across the one-second line.
|
||||
pub fn showinfo_frame(line: &str, base: Option<(i64, i64)>) -> Option<(usize, f64)> {
|
||||
let rest = line.split(" n:").nth(1)?;
|
||||
let n = rest.split_whitespace().next()?.parse().ok()?;
|
||||
let pts: i64 = rest.split("pts:").nth(1)?.split_whitespace().next()?.parse().ok()?;
|
||||
let (num, den) = base?;
|
||||
Some((n, pts as f64 * num as f64 / den as f64))
|
||||
}
|
||||
|
||||
pub fn showinfo_base(line: &str) -> Option<(i64, i64)> {
|
||||
let (num, den) = line.split("config in time_base:").nth(1)?.split(',').next()?.trim().split_once('/')?;
|
||||
Some((num.parse().ok()?, den.parse().ok()?))
|
||||
}
|
||||
|
||||
/// A line's severity under `-loglevel level+`: the first bracket after any `[context @ address]`. Searching the whole line
|
||||
/// would take a file's own metadata for an error when its title happens to say one.
|
||||
pub fn log_level(line: &str) -> Option<&str> {
|
||||
let mut rest = line.trim_start();
|
||||
if rest.starts_with('[') && rest[..rest.find(']')?].contains(" @ ") {
|
||||
rest = rest[rest.find(']')? + 1..].trim_start();
|
||||
}
|
||||
let rest = rest.strip_prefix('[')?;
|
||||
Some(&rest[..rest.find(']')?])
|
||||
}
|
||||
|
||||
/// Each 32x18 grey frame's mean brightness, 0 to 1 (`scale=32:18:flags=area,format=gray`, defects.rs lumas)
|
||||
pub fn lumas_of(grey: &[u8]) -> Vec<f32> {
|
||||
let mut out = Vec::with_capacity(grey.len() / (32 * 18));
|
||||
for f in grey.as_chunks::<{ 32 * 18 }>().0 {
|
||||
let mut sum = 0f32;
|
||||
for &p in f {
|
||||
sum += p as f32;
|
||||
}
|
||||
out.push(sum / (32.0 * 18.0 * 255.0));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether the four rules can read in one: FFmpeg is the reader, and the system has named pipes
|
||||
pub fn can() -> bool {
|
||||
cfg!(unix) && !crate::native()
|
||||
}
|
||||
|
||||
/// The one read: the flashing screen's frames (`flash`, w x h each side) to `screen` with their times, the grey crop
|
||||
/// (`crop`, w x h; None when blotching doesn't read) every 2 s to `crops`, freezedetect at `still` seconds
|
||||
#[cfg(not(unix))]
|
||||
pub fn picture(_: &str, _: (usize, usize), _: Option<(usize, usize)>, _: f64, _: impl FnMut(f64, &[u8]) + Send, _: impl FnMut(&[u8]) + Send) -> R<Once> {
|
||||
Err("one read needs named pipes".into())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn picture(video: &str, flash: (usize, usize), crop: Option<(usize, usize)>, still: f64, mut screen: impl FnMut(f64, &[u8]) + Send, mut crops: impl FnMut(&[u8]) + Send) -> R<Once> {
|
||||
let dir = std::env::temp_dir().join(format!("raea-once-{}-{}", std::process::id(), std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_or(0, |d| d.as_nanos())));
|
||||
std::fs::create_dir_all(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
let (lumas_at, crops_at) = (dir.join("lumas"), dir.join("crops"));
|
||||
let read = (|| {
|
||||
fifo(&lumas_at)?;
|
||||
if crop.is_some() {
|
||||
fifo(&crops_at)?;
|
||||
}
|
||||
let (w, h) = flash;
|
||||
let mut graph = format!(
|
||||
"[0:v:0]split={}[f][z][l]{};[f]showinfo,split=2[area][point];[area]scale={w}:{h}:flags=area[a];[point]scale={w}:{h}:flags=neighbor[p];[a][p]hstack=inputs=2,format=rgb24[fo];[z]freezedetect=n=-60dB:d={still}[zo];[l]scale=32:18:flags=area,format=gray[lo]",
|
||||
if crop.is_some() { 4 } else { 3 },
|
||||
if crop.is_some() { "[b]" } else { "" }
|
||||
);
|
||||
if let Some((cw, ch)) = crop {
|
||||
graph.push_str(&format!(";[b]fps=0.5,crop={cw}:{ch}:0:0,format=gray[bo]"));
|
||||
}
|
||||
let sync = raea_io_ffmpeg::passthrough();
|
||||
let mut args: Vec<String> = ["-hide_banner", "-nostats", "-nostdin", "-y", "-loglevel", "level+info", "-i", video, "-filter_complex", &graph].map(String::from).to_vec();
|
||||
args.extend(["-map", "[fo]", sync[0], sync[1], "-f", "rawvideo", "pipe:1", "-map", "[zo]", "-f", "null", "-", "-map", "[lo]", "-f", "rawvideo"].map(String::from));
|
||||
args.push(lumas_at.display().to_string());
|
||||
if crop.is_some() {
|
||||
args.extend(["-map", "[bo]", "-f", "rawvideo"].map(String::from));
|
||||
args.push(crops_at.display().to_string());
|
||||
}
|
||||
let mut child = Command::new("ffmpeg").args(&args).stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped()).spawn().map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
let (mut out, err) = (child.stdout.take().unwrap(), child.stderr.take().unwrap());
|
||||
let (times, clock) = std::sync::mpsc::channel();
|
||||
std::thread::scope(|s| {
|
||||
// each output read apart from the others, so that none can fill while another is being waited on
|
||||
let log = s.spawn(move || {
|
||||
let (mut err, mut line) = (std::io::BufReader::new(err), Vec::new());
|
||||
let (mut base, mut errors, mut first, mut freezes) = (None, 0usize, String::new(), String::new());
|
||||
while err.read_until(b'\n', &mut line).is_ok_and(|n| n > 0) {
|
||||
let text = String::from_utf8_lossy(&line);
|
||||
if matches!(log_level(&text), Some("error" | "fatal" | "panic")) {
|
||||
errors += 1;
|
||||
if first.is_empty() {
|
||||
first = text.trim().to_string();
|
||||
}
|
||||
} else if text.trim_start().starts_with("[Parsed_showinfo") {
|
||||
base = showinfo_base(&text).or(base);
|
||||
if let Some(frame) = showinfo_frame(&text, base) {
|
||||
let _ = times.send(frame);
|
||||
}
|
||||
} else if text.contains("freezedetect") {
|
||||
freezes.push_str(&text);
|
||||
}
|
||||
line.clear();
|
||||
}
|
||||
(errors, first, freezes)
|
||||
});
|
||||
let lumas = s.spawn(|| {
|
||||
let mut b = Vec::new();
|
||||
let _ = std::fs::File::open(&lumas_at).and_then(|mut f| f.read_to_end(&mut b));
|
||||
lumas_of(&b)
|
||||
});
|
||||
let crop_reader = crop.map(|(cw, ch)| {
|
||||
let at = &crops_at;
|
||||
let crops = &mut crops;
|
||||
s.spawn(move || {
|
||||
if let Ok(mut f) = std::fs::File::open(at) {
|
||||
let mut buf = vec![0u8; cw * ch];
|
||||
while f.read_exact(&mut buf).is_ok() {
|
||||
crops(&buf);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
let mut buf = vec![0u8; w * 2 * h * 3];
|
||||
let (mut frames, mut lost) = (0usize, false);
|
||||
while out.read_exact(&mut buf).is_ok() {
|
||||
// the frame's own line is written before its pixels, so one that doesn't come isn't going to
|
||||
match clock.recv_timeout(std::time::Duration::from_secs(60)) {
|
||||
Ok((n, t)) if n == frames => screen(t, &buf),
|
||||
_ => {
|
||||
lost = true;
|
||||
let _ = child.kill();
|
||||
break;
|
||||
}
|
||||
}
|
||||
frames += 1;
|
||||
}
|
||||
drop(out);
|
||||
let ok = child.wait().is_ok_and(|s| s.success());
|
||||
// a pipe FFmpeg never opened (it stopped first) would hold its reader in open(): opening it to write lets go
|
||||
for p in [&lumas_at, &crops_at] {
|
||||
let _ = unblock(p);
|
||||
}
|
||||
let (errors, first, freezes) = log.join().unwrap_or_default();
|
||||
let lumas = lumas.join().unwrap_or_default();
|
||||
if let Some(c) = crop_reader {
|
||||
let _ = c.join();
|
||||
}
|
||||
Ok(Once { frames, lost, ok, errors, first, freezes, lumas })
|
||||
})
|
||||
})();
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
read
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn fifo(p: &Path) -> R<()> {
|
||||
let c = std::ffi::CString::new(p.as_os_str().as_encoded_bytes()).map_err(|e| e.to_string())?;
|
||||
// SAFETY: a NUL-terminated path, and mkfifo reads nothing else
|
||||
if unsafe { libc::mkfifo(c.as_ptr(), 0o600) } != 0 {
|
||||
return Err(format!("{}: {}", p.display(), std::io::Error::last_os_error()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn unblock(p: &Path) -> std::io::Result<()> {
|
||||
use std::os::unix::fs::OpenOptionsExt;
|
||||
std::fs::OpenOptions::new().write(true).custom_flags(libc::O_NONBLOCK).open(p).map(drop)
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
//! Each native reader against the FFmpeg read it stands in for (lib.rs names the command), on a clip FFmpeg makes: a
|
||||
//! moving test picture that freezes for its last 4 s, over stereo sound whose level swells. `raea check` without FFmpeg
|
||||
//! must reach the verdicts it reaches with it, so each answer is held to FFmpeg's within what a rule could notice.
|
||||
//! Skipped where FFmpeg isn't installed (there is nothing to compare against).
|
||||
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
fn ffmpeg(args: &[&str]) -> (Vec<u8>, String) {
|
||||
let out = Command::new("ffmpeg").args(["-hide_banner", "-nostats", "-nostdin"]).args(args).output().expect("ffmpeg runs");
|
||||
assert!(out.status.success(), "ffmpeg {args:?}: {}", String::from_utf8_lossy(&out.stderr));
|
||||
(out.stdout, String::from_utf8_lossy(&out.stderr).into_owned())
|
||||
}
|
||||
|
||||
fn clip(dir: &Path) -> String {
|
||||
let file = dir.join("clip.mp4").to_string_lossy().into_owned();
|
||||
let picture = "testsrc2=size=320x180:rate=30:duration=5,tpad=stop_mode=clone:stop_duration=4";
|
||||
let sound = "aevalsrc=0.4*sin(2*PI*440*t)*(0.55+0.45*sin(2*PI*0.25*t))|0.25*sin(2*PI*660*t):s=48000:d=9";
|
||||
ffmpeg(&["-y", "-f", "lavfi", "-i", picture, "-f", "lavfi", "-i", sound, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "-b:a", "192k", "-shortest", &file]);
|
||||
file
|
||||
}
|
||||
|
||||
/// The mean absolute difference of two byte runs, in levels
|
||||
fn apart(a: &[u8], b: &[u8]) -> f64 {
|
||||
a.iter().zip(b).map(|(x, y)| x.abs_diff(*y) as u64).sum::<u64>() as f64 / a.len().max(1) as f64
|
||||
}
|
||||
|
||||
/// Root-mean-square level in dB of each 100 ms of `x` at `rate`
|
||||
fn levels(x: &[f32], rate: usize) -> Vec<f64> {
|
||||
x.chunks_exact(rate / 10).map(|c| 10.0 * (c.iter().fold(0.0, |s, v| s + v * v) as f64 / c.len() as f64 + 1e-12).log10()).collect()
|
||||
}
|
||||
|
||||
/// Each measure's name, how far the native read is from FFmpeg's, and how far it may be: all printed, then held
|
||||
struct Off(Vec<(String, f64, f64)>);
|
||||
|
||||
impl Off {
|
||||
fn by(&mut self, what: impl Into<String>, off: f64, most: f64) {
|
||||
self.0.push((what.into(), off, most));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_native_reads_match_ffmpeg_s() {
|
||||
if Command::new("ffmpeg").arg("-version").output().is_err() {
|
||||
eprintln!("skipped: no FFmpeg to compare against");
|
||||
return;
|
||||
}
|
||||
let dir = std::env::temp_dir().join(format!("raea-check-read-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let v = &clip(&dir);
|
||||
let mut off = Off(vec![]);
|
||||
let by_ffmpeg = raea_app_check_read::probe(v).unwrap();
|
||||
// SAFETY: set before any reader runs, on this test's only thread
|
||||
unsafe { std::env::set_var("RAEA_CHECK_NATIVE", "1") };
|
||||
assert!(raea_app_check_read::native());
|
||||
let p = raea_app_check_read::probe(v).unwrap();
|
||||
assert_eq!((p.w, p.h, p.audio), (by_ffmpeg.w, by_ffmpeg.h, by_ffmpeg.audio));
|
||||
assert!((p.duration - by_ffmpeg.duration).abs() < 0.05 && (p.picture - by_ffmpeg.picture).abs() < 0.05, "{} {} vs {} {}", p.duration, p.picture, by_ffmpeg.duration, by_ffmpeg.picture);
|
||||
|
||||
// flash-frame's light per frame
|
||||
let (gray, _) = ffmpeg(&["-v", "error", "-i", v, "-map", "0:v:0", "-vf", "scale=32:18:flags=area,format=gray", "-f", "rawvideo", "-"]);
|
||||
let theirs: Vec<f64> = gray.chunks_exact(32 * 18).map(|f| f.iter().map(|&b| b as f64).sum::<f64>() / (32.0 * 18.0 * 255.0)).collect();
|
||||
let (ours, fps) = raea_app_check_read::lumas(v).unwrap();
|
||||
assert_eq!((ours.len(), fps), (theirs.len(), 30.0));
|
||||
off.by("a frame's light, of 1", ours.iter().zip(&theirs).map(|(a, b)| (*a as f64 - b).abs()).fold(0.0, f64::max), 0.01);
|
||||
|
||||
// blotching's dark crops every 2 s
|
||||
let (w, h) = (320, 176);
|
||||
let (gray, _) = ffmpeg(&["-v", "error", "-i", v, "-vf", &format!("fps=0.5,crop={w}:{h}:0:0,format=gray"), "-f", "rawvideo", "-"]);
|
||||
let mut crops = vec![];
|
||||
raea_app_check_read::crops(v, w, h, |c| crops.push(c.to_vec())).unwrap();
|
||||
assert_eq!(crops.len(), gray.len() / (w * h));
|
||||
for (i, (a, b)) in crops.iter().zip(gray.chunks_exact(w * h)).enumerate() {
|
||||
let bias = a.iter().zip(b).map(|(x, y)| *x as f64 - *y as f64).sum::<f64>() / a.len() as f64;
|
||||
off.by(format!("blotching crop {i}, levels (bias {bias:+.2})"), apart(a, b), 3.0);
|
||||
}
|
||||
|
||||
// the flashing screen's frames: area-sampled beside point-sampled RGB
|
||||
let (fw, fh) = (192, 108);
|
||||
let graph = format!("split=2[area][point];[area]scale={fw}:{fh}:flags=area[a];[point]scale={fw}:{fh}:flags=neighbor[b];[a][b]hstack=inputs=2,format=rgb24");
|
||||
let (rgb, _) = ffmpeg(&["-v", "error", "-i", v, "-map", "0:v:0", "-vf", &graph, "-f", "rawvideo", "-"]);
|
||||
let (mut frames, mut times) = (vec![], vec![]);
|
||||
let n = raea_app_check_read::flash_frames(v, fw, fh, |t, buf| {
|
||||
times.push(t);
|
||||
frames.push(buf.to_vec());
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(n, rgb.len() / (fw * 2 * fh * 3));
|
||||
assert!(times.windows(2).all(|t| (t[1] - t[0] - 1.0 / 30.0).abs() < 1e-3), "frame times step by a frame");
|
||||
off.by("a flash frame, levels", frames.iter().zip(rgb.chunks_exact(fw * 2 * fh * 3)).map(|(a, b)| apart(a, b)).fold(0.0, f64::max), 6.0);
|
||||
|
||||
// the sound folded to mono, 100 ms at a time
|
||||
let (pcm, _) = ffmpeg(&["-v", "error", "-i", v, "-vn", "-ac", "1", "-ar", "24000", "-f", "f32le", "-"]);
|
||||
let theirs = levels(&pcm.chunks_exact(4).map(|b| f32::from_le_bytes([b[0], b[1], b[2], b[3]])).collect::<Vec<_>>(), 24000);
|
||||
let ours = levels(&raea_app_check_read::mono(v, 24000).unwrap(), 24000);
|
||||
assert!(ours.len().abs_diff(theirs.len()) <= 1, "{} windows vs {}", ours.len(), theirs.len());
|
||||
off.by("100 ms of mono sound, dB", ours.iter().zip(&theirs).skip(1).map(|(a, b)| (a - b).abs()).fold(0.0, f64::max), 0.5);
|
||||
|
||||
// momentary loudness every 100 ms
|
||||
let (log, _) = ffmpeg(&["-i", v, "-vn", "-af", "ebur128=metadata=1,ametadata=print:key=lavfi.r128.M:file=-", "-f", "null", "-"]);
|
||||
let theirs: Vec<f64> = String::from_utf8_lossy(&log).lines().filter_map(|l| l.strip_prefix("lavfi.r128.M=")?.trim().parse().ok()).collect();
|
||||
let (at, ours) = raea_app_check_read::meter(v).unwrap();
|
||||
assert!(ours.len().abs_diff(theirs.len()) <= 2 && at.len() == ours.len(), "{} readings vs {}", ours.len(), theirs.len());
|
||||
off.by("a momentary loudness, LU", ours.iter().zip(&theirs).skip(4).map(|(a, b)| (a - b).abs()).fold(0.0, f64::max), 0.5);
|
||||
|
||||
// the freeze: 5 s in, to the end
|
||||
let (_, log) = ffmpeg(&["-i", v, "-an", "-vf", "freezedetect=n=-60dB:d=3", "-f", "null", "-"]);
|
||||
let starts = |log: &str| log.lines().filter_map(|l| l.split("freeze_start: ").nth(1)?.trim().parse::<f64>().ok()).collect::<Vec<_>>();
|
||||
let (theirs, ours) = (starts(&log), starts(&raea_app_check_read::freezes(v, -60.0, 3.0).unwrap()));
|
||||
assert!(ours.len() == 1 && theirs.len() == 1, "freezes from {ours:?} vs {theirs:?}");
|
||||
off.by("the freeze's start, s", (ours[0] - theirs[0]).abs(), 0.1);
|
||||
|
||||
// the mix's loudness and a caption's contrast, against raea-sys-measure's FFmpeg reads
|
||||
let (i, tp) = raea_app_check_read::loudness(v).unwrap();
|
||||
let (fi, ftp) = raea_sys_measure::loudness(Path::new(v)).unwrap();
|
||||
off.by("integrated loudness, LU", (i - fi).abs(), 0.3);
|
||||
off.by("true peak, dB", (tp.unwrap() - ftp.unwrap()).abs(), 0.5);
|
||||
let ours = raea_app_check_read::contrast(v, 1.0, [40, 60, 120, 60], "rgb(255, 255, 255)").unwrap();
|
||||
let theirs = raea_sys_measure::contrast(Path::new(v), 1.0, [40, 60, 120, 60], "rgb(255, 255, 255)").unwrap();
|
||||
off.by("a caption's contrast, share", (ours / theirs - 1.0).abs(), 0.05);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
for (what, by, most) in &off.0 {
|
||||
eprintln!("{} {what}: {by:.4} (at most {most})", if by < most { "ok " } else { "OVER" });
|
||||
}
|
||||
assert!(off.0.iter().all(|(_, by, most)| by < most), "a native read is further from FFmpeg's than a rule allows");
|
||||
}
|
||||
|
||||
/// The one read (once.rs) against the four reads it stands in for, each run alone as raea check ran it: each rule gets
|
||||
/// the same bytes, frames and log lines. Away from Unix the rules read alone (no named pipes), and this is skipped.
|
||||
#[test]
|
||||
fn one_read_gives_each_rule_what_its_own_read_gave() {
|
||||
if !raea_app_check_read::once::can() {
|
||||
eprintln!("skipped: the rules read alone here");
|
||||
return;
|
||||
}
|
||||
let dir = std::env::temp_dir().join(format!("raea-once-test-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let file = dir.join("clip.mp4").to_string_lossy().into_owned();
|
||||
ffmpeg(&["-y", "-f", "lavfi", "-i", "testsrc2=size=320x180:rate=30:duration=5,tpad=stop_mode=clone:stop_duration=4", "-c:v", "libx264", "-pix_fmt", "yuv420p", &file]);
|
||||
let (w, h, cw, ch) = (192usize, 108usize, 320usize, 176usize);
|
||||
let (mut frames, mut crops) = (Vec::new(), Vec::new());
|
||||
let once = raea_app_check_read::once::picture(&file, (w, h), Some((cw, ch)), 3.0, |t, b| frames.push((t, b.to_vec())), |b| crops.extend_from_slice(b)).unwrap();
|
||||
assert!(once.ok && !once.lost && once.errors == 0);
|
||||
// the flashing screen's frames, as flash.rs read them alone
|
||||
let sync = raea_io_ffmpeg::passthrough();
|
||||
let graph = format!("showinfo,split=2[area][point];[area]scale={w}:{h}:flags=area[a];[point]scale={w}:{h}:flags=neighbor[b];[a][b]hstack=inputs=2,format=rgb24");
|
||||
let (alone, log) = ffmpeg(&["-loglevel", "level+info", "-i", &file, "-map", "0:v:0", "-vf", &graph, sync[0], sync[1], "-f", "rawvideo", "-"]);
|
||||
assert_eq!(frames.len(), alone.len() / (w * 2 * h * 3));
|
||||
assert_eq!(frames.iter().flat_map(|f| f.1.iter().copied()).collect::<Vec<u8>>(), alone);
|
||||
let base = log.lines().find_map(raea_app_check_read::showinfo_base);
|
||||
let times: Vec<f64> = log.lines().filter(|l| l.trim_start().starts_with("[Parsed_showinfo")).filter_map(|l| raea_app_check_read::showinfo_frame(l, base)).map(|f| f.1).collect();
|
||||
assert_eq!(frames.iter().map(|f| f.0).collect::<Vec<f64>>(), times);
|
||||
// each frame's brightness, as defects.rs read it
|
||||
let (grey, _) = ffmpeg(&["-v", "error", "-i", &file, "-map", "0:v:0", "-vf", "scale=32:18:flags=area,format=gray", "-f", "rawvideo", "-"]);
|
||||
assert_eq!(once.lumas, raea_app_check_read::once::lumas_of(&grey));
|
||||
// blotching's crops, as picture.rs read them
|
||||
let (alone, _) = ffmpeg(&["-v", "error", "-i", &file, "-vf", &format!("fps=0.5,crop={cw}:{ch}:0:0,format=gray"), "-f", "rawvideo", "-"]);
|
||||
assert_eq!(crops, alone);
|
||||
// and freezedetect's freeze, as sound.rs read it
|
||||
let (_, log) = ffmpeg(&["-i", &file, "-an", "-vf", "freezedetect=n=-60dB:d=3", "-f", "null", "-"]);
|
||||
let starts = |s: &str| s.lines().filter_map(|l| l.split("freeze_start: ").nth(1).map(|x| x.trim().to_string())).collect::<Vec<_>>();
|
||||
assert_eq!(starts(&once.freezes), starts(&log));
|
||||
assert!(!starts(&log).is_empty());
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
+30
-11
@@ -11,8 +11,12 @@ pub(crate) const FULL: f32 = 0.999;
|
||||
pub(crate) const FLAT_LEVEL: f32 = 0.05;
|
||||
pub(crate) const CLIP_RUNS: usize = 3;
|
||||
|
||||
pub(crate) fn clipped(x: &[f32]) -> Vec<(f64, String)> {
|
||||
let mut per: Vec<usize> = vec![0; x.len() / SR + 1];
|
||||
pub(crate) fn clipped(channels: &[Vec<f32>]) -> Vec<(f64, String)> {
|
||||
let len = channels.iter().map(Vec::len).max().unwrap_or(0);
|
||||
let mut per: Vec<usize> = vec![0; len / SR + 1];
|
||||
// each channel's runs, a second's count the most any channel had: clipping is a channel's
|
||||
for x in channels {
|
||||
let mut own: Vec<usize> = vec![0; len / SR + 1];
|
||||
let mut i = 0;
|
||||
while i < x.len() {
|
||||
let v = x[i];
|
||||
@@ -22,18 +26,22 @@ pub(crate) fn clipped(x: &[f32]) -> Vec<(f64, String)> {
|
||||
j += 1;
|
||||
}
|
||||
if j - i >= 3 {
|
||||
per[i / SR] += 1;
|
||||
own[i / SR] += 1;
|
||||
}
|
||||
} else if v.abs() >= FLAT_LEVEL {
|
||||
while j < x.len() && x[j].to_bits() == v.to_bits() {
|
||||
j += 1;
|
||||
}
|
||||
if j - i >= 4 {
|
||||
per[i / SR] += 1;
|
||||
own[i / SR] += 1;
|
||||
}
|
||||
}
|
||||
i = j;
|
||||
}
|
||||
for (p, o) in per.iter_mut().zip(own) {
|
||||
*p = (*p).max(o);
|
||||
}
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
let mut s = 0;
|
||||
while s < per.len() {
|
||||
@@ -113,6 +121,9 @@ pub(crate) fn flash_frames(luma: &[f32], fps: f64) -> Vec<(f64, String)> {
|
||||
|
||||
/// Each frame's mean brightness (0-1), decoded small and grey
|
||||
fn lumas(video: &str) -> R<(Vec<f32>, f64)> {
|
||||
if crate::read::native() {
|
||||
return crate::read::lumas(video);
|
||||
}
|
||||
let out = Command::new("ffmpeg")
|
||||
.args(["-v", "error", "-nostdin", "-i", video, "-map", "0:v:0", "-vf", "scale=32:18:flags=area,format=gray", "-f", "rawvideo", "-"])
|
||||
.output()
|
||||
@@ -120,20 +131,28 @@ fn lumas(video: &str) -> R<(Vec<f32>, f64)> {
|
||||
if !out.status.success() {
|
||||
return Err(format!("ffmpeg couldn't read the picture of {video}: {}", String::from_utf8_lossy(&out.stderr).trim()));
|
||||
}
|
||||
let l = out.stdout.as_chunks::<{ 32 * 18 }>().0.iter().map(|f| f.iter().map(|&p| p as f32).sum::<f32>() / (32.0 * 18.0 * 255.0)).collect();
|
||||
Ok((crate::read::once::lumas_of(&out.stdout), ffmpeg_rate(video)?))
|
||||
}
|
||||
|
||||
/// The frame rate `ffmpeg -i` says
|
||||
pub(crate) fn ffmpeg_rate(video: &str) -> R<f64> {
|
||||
let rate = ffmpeg_stderr(&["-hide_banner", "-i", video])?;
|
||||
let fps = rate.split(" fps").next().and_then(|s| s.rsplit(", ").next()).and_then(|s| s.trim().parse().ok()).unwrap_or(30.0);
|
||||
Ok((l, fps))
|
||||
Ok(rate.split(" fps").next().and_then(|s| s.rsplit(", ").next()).and_then(|s| s.trim().parse().ok()).unwrap_or(30.0))
|
||||
}
|
||||
|
||||
pub(crate) fn flash_frame_rule(video: &str, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
let (l, fps) = lumas(video)?;
|
||||
let found = flash_frames(&l, fps);
|
||||
flash_frame_from(&l, fps, issues, passed);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The stray frames each frame's brightness shows
|
||||
pub(crate) fn flash_frame_from(l: &[f32], fps: f64, issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let found = flash_frames(l, fps);
|
||||
if found.is_empty() {
|
||||
passed.push("flash-frame: no stray black or white frame".into());
|
||||
}
|
||||
issues.extend(moments("flash-frame", 1, found));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Each moment a rule found, as an issue of that priority
|
||||
@@ -142,8 +161,8 @@ pub(crate) fn moments(rule: &'static str, p: u8, found: Vec<(f64, String)>) -> i
|
||||
}
|
||||
|
||||
/// The sound's defects on the decoded mix (sound.rs decodes it once)
|
||||
pub(crate) fn sound_defects(x: &[f32], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
for (rule, found, ok) in [("clipping", clipped(x), "clipping: no flat-topped runs"), ("dropout", dropouts(x), "dropout: the sound never drops to silence and back")] {
|
||||
pub(crate) fn sound_defects(x: &[f32], channels: &[Vec<f32>], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
for (rule, found, ok) in [("clipping", clipped(channels), "clipping: no flat-topped runs"), ("dropout", dropouts(x), "dropout: the sound never drops to silence and back")] {
|
||||
if found.is_empty() {
|
||||
passed.push(ok.into());
|
||||
}
|
||||
|
||||
+48
-24
@@ -5,35 +5,54 @@ use raea_app_check_flash::FlashScreen;
|
||||
/// the area sample and the point sample side by side
|
||||
const FLASH_W: usize = 192;
|
||||
|
||||
/// A frame's number and time from showinfo's log, exact: its `pts` in ticks of the time base. `pts_time` is rounded to six
|
||||
/// significant digits, which is enough to push a legal third flash across the one-second line.
|
||||
pub(crate) fn showinfo_frame(line: &str, base: Option<(i64, i64)>) -> Option<(usize, f64)> {
|
||||
let rest = line.split(" n:").nth(1)?;
|
||||
let n = rest.split_whitespace().next()?.parse().ok()?;
|
||||
let pts: i64 = rest.split("pts:").nth(1)?.split_whitespace().next()?.parse().ok()?;
|
||||
let (num, den) = base?;
|
||||
Some((n, pts as f64 * num as f64 / den as f64))
|
||||
pub(crate) use crate::read::{log_level, showinfo_base, showinfo_frame};
|
||||
|
||||
/// The flashing screen's frame height for the picture's shape
|
||||
fn flash_h(probe: &Probe) -> usize {
|
||||
(((FLASH_W as f64 * probe.h / probe.w.max(1.0)) / 2.0).round() as usize * 2).max(6)
|
||||
}
|
||||
|
||||
pub(crate) fn showinfo_base(line: &str) -> Option<(i64, i64)> {
|
||||
let (num, den) = line.split("config in time_base:").nth(1)?.split(',').next()?.trim().split_once('/')?;
|
||||
Some((num.parse().ok()?, den.parse().ok()?))
|
||||
}
|
||||
|
||||
/// A line's severity under `-loglevel level+`: the first bracket after any `[context @ address]`. Searching the whole line
|
||||
/// would take a file's own metadata for an error when its title happens to say one.
|
||||
pub(crate) fn log_level(line: &str) -> Option<&str> {
|
||||
let mut rest = line.trim_start();
|
||||
if rest.starts_with('[') && rest[..rest.find(']')?].contains(" @ ") {
|
||||
rest = rest[rest.find(']')? + 1..].trim_start();
|
||||
/// Freezes, flashing, flash frames and blotching, in that order, from one read of the picture (raea-app-check-read
|
||||
/// once.rs: one decode where there were four); each reads on its own where one read can't be had
|
||||
pub(crate) fn picture_rules(video: &str, probe: &Probe, taste: Option<&Taste>, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
if !crate::read::once::can() {
|
||||
freezes(video, probe, taste, issues, passed)?;
|
||||
flashing(video, probe, issues, passed)?;
|
||||
flash_frame_rule(video, issues, passed)?;
|
||||
return blotching(video, probe, issues, passed);
|
||||
}
|
||||
let rest = rest.strip_prefix('[')?;
|
||||
Some(&rest[..rest.find(']')?])
|
||||
let (w, h) = (FLASH_W, flash_h(probe));
|
||||
let kept = x264_kept(video);
|
||||
let (cw, ch) = (probe.w as usize / 8 * 8, probe.h as usize / 8 * 8);
|
||||
let mut screen = FlashScreen::new(w, h);
|
||||
let mut scores = Vec::new();
|
||||
let once = crate::read::once::picture(video, (w, h), kept.is_none().then_some((cw, ch)), taste.map_or(3.0, |t| t.value), |t, buf| screen.push(buf, t), scorer(&mut scores, cw, ch))?;
|
||||
freezes_from(&once.freezes, probe, taste, issues, passed);
|
||||
if once.lost {
|
||||
return Err(format!("{video}: flashing can't be screened, frame {} has no timestamp of its own", once.frames));
|
||||
}
|
||||
if !once.ok || once.frames == 0 {
|
||||
return Err(format!("{video}: flashing can't be screened, FFmpeg decoded {} frames ({})", once.frames, once.first));
|
||||
}
|
||||
screened(screen, once.errors, &once.first, issues, passed);
|
||||
flash_frame_from(&once.lumas, ffmpeg_rate(video)?, issues, passed);
|
||||
match kept {
|
||||
Some(crf) => passed.push(format!("blotching: encoded by x264 at crf {crf}, which keeps the darks")),
|
||||
None => blotching_from(video, probe, &scores, issues, passed),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn flashing(video: &str, probe: &Probe, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
let w = FLASH_W;
|
||||
let h = (((w as f64 * probe.h / probe.w.max(1.0)) / 2.0).round() as usize * 2).max(6);
|
||||
let (w, h) = (FLASH_W, flash_h(probe));
|
||||
if crate::read::native() {
|
||||
let mut screen = FlashScreen::new(w, h);
|
||||
if crate::read::flash_frames(video, w, h, |t, buf| screen.push(buf, t))? == 0 {
|
||||
return Err(format!("{video}: flashing can't be screened, no frame decoded"));
|
||||
}
|
||||
screened(screen, 0, "", issues, passed);
|
||||
return Ok(());
|
||||
}
|
||||
let graph = format!("showinfo,split=2[area][point];[area]scale={w}:{h}:flags=area[a];[point]scale={w}:{h}:flags=neighbor[b];[a][b]hstack=inputs=2,format=rgb24");
|
||||
let sync = raea_io_ffmpeg::passthrough();
|
||||
let mut child = Command::new("ffmpeg")
|
||||
@@ -92,6 +111,12 @@ pub(crate) fn flashing(video: &str, probe: &Probe, issues: &mut Vec<Issue>, pass
|
||||
if !status.success() || frames == 0 {
|
||||
return Err(format!("{video}: flashing can't be screened, FFmpeg decoded {frames} frames ({first})"));
|
||||
}
|
||||
screened(screen, errors, &first, issues, passed);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// What the screen found, after `errors` errors decoding the picture (`first` the first of them)
|
||||
fn screened(screen: FlashScreen, errors: usize, first: &str, issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
if errors > 0 {
|
||||
issues.push(Issue {
|
||||
rule: "decode",
|
||||
@@ -110,5 +135,4 @@ pub(crate) fn flashing(video: &str, probe: &Probe, issues: &mut Vec<Issue>, pass
|
||||
None if errors == 0 => passed.push("flashing: no more than 3 flashes a second found (a screen, not a certification)".to_string()),
|
||||
None => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
+22
-67
@@ -22,23 +22,18 @@ mod flash;
|
||||
use flash::*;
|
||||
mod defects;
|
||||
use defects::*;
|
||||
mod text;
|
||||
use text::*;
|
||||
/// what a render's text breaks, from its manifest (split out: a render holds its own text to it)
|
||||
use raea_app_check_text::*;
|
||||
/// who can fix what it finds: the encode's or the picture's own, carried from an earlier export, a source
|
||||
use raea_app_check_cause as cause;
|
||||
/// a video read through FFmpeg, or raea's own decoders where it isn't installed
|
||||
use raea_app_check_read::{self as read, Probe};
|
||||
pub mod quick;
|
||||
pub mod hook;
|
||||
pub use raea_app_check_inbox as inbox;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
type R<T> = Result<T, String>;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Issue {
|
||||
rule: &'static str,
|
||||
p: u8,
|
||||
at: Option<f64>,
|
||||
says: String,
|
||||
}
|
||||
|
||||
/// `raea check …` with the person's taste, none or more (taste.ts and the kinds beside it, which the raea CLI evaluates: it owns the engine):
|
||||
/// its rules' checks hold the export to the person's own lines.
|
||||
@@ -145,7 +140,7 @@ fn measured(args: &[String], taste: Vec<Taste>) -> R<(String, Vec<Issue>, Vec<St
|
||||
if !std::path::Path::new(&video).exists() {
|
||||
return Err(format!("no file at {video}\n{USAGE}"));
|
||||
}
|
||||
let probe = Probe::of(&video)?;
|
||||
let probe = read::probe(&video)?;
|
||||
let (mut issues, mut passed) = (Vec::new(), Vec::new());
|
||||
let manifest: Option<Value> = match flag(args, "--manifest") {
|
||||
Some(m) => Some(serde_json::from_str(&std::fs::read_to_string(m).map_err(|e| format!("{m}: {e}"))?).map_err(|e| format!("{m}: {e}"))?),
|
||||
@@ -157,14 +152,17 @@ fn measured(args: &[String], taste: Vec<Taste>) -> R<(String, Vec<Issue>, Vec<St
|
||||
loudness(&video, taste_of(&taste, "loudness"), &mut issues, &mut passed)?;
|
||||
sound(&video, words.as_deref(), &mut issues, &mut passed)?;
|
||||
}
|
||||
freezes(&video, &probe, taste_of(&taste, "still-max"), &mut issues, &mut passed)?;
|
||||
flashing(&video, &probe, &mut issues, &mut passed)?;
|
||||
flash_frame_rule(&video, &mut issues, &mut passed)?;
|
||||
blotching(&video, &probe, &mut issues, &mut passed)?;
|
||||
picture_rules(&video, &probe, taste_of(&taste, "still-max"), &mut issues, &mut passed)?;
|
||||
brand_kit(&[flag(args, "--manifest").unwrap_or(""), video.as_str()], &mut issues, &mut passed);
|
||||
if let Some(p) = flag(args, "--things") {
|
||||
things(p, &mut issues, &mut passed)?;
|
||||
}
|
||||
// a take or a download isn't a delivery: the mix sets the delivery's level, so its own is said, not held to the target
|
||||
if cause::is_source(std::path::Path::new(&video)) {
|
||||
for i in issues.iter_mut().filter(|i| i.rule == "loudness") {
|
||||
(i.p, i.says) = (3, format!("a source, not a delivery: {} (the mix sets the delivery's level)", i.says));
|
||||
}
|
||||
}
|
||||
if let Some(manifest) = &manifest {
|
||||
let runs = text_runs(manifest);
|
||||
let (w, h) = (manifest["width"].as_f64().unwrap_or(probe.w), manifest["height"].as_f64().unwrap_or(probe.h));
|
||||
@@ -202,19 +200,17 @@ fn things(p: &str, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
/// `fps`), with `more` (a render's own), worst first then by time.
|
||||
fn findings_of(mut issues: Vec<Issue>, more: Vec<Finding>, fps: f64) -> Vec<Finding> {
|
||||
issues.sort_by(|a, b| a.p.cmp(&b.p).then(a.at.unwrap_or(0.0).total_cmp(&b.at.unwrap_or(0.0))));
|
||||
let mut found = Vec::new();
|
||||
for i in &issues {
|
||||
// an issue at a second is about the frame it falls on
|
||||
let (f, fr) = (Finding::new(i.rule, Level::of_rank(i.p), &i.says, "raea check"), (i.at.unwrap_or(0.0) * fps).round() as i64);
|
||||
found.push(if i.at.is_some() { f.frames(fr, fr + 1) } else { f });
|
||||
}
|
||||
finding::ranked(found.into_iter().chain(more).collect())
|
||||
finding::ranked(issues.iter().map(|i| i.finding("raea check", fps)).chain(more).collect())
|
||||
}
|
||||
|
||||
/// The findings (`findings_of`), written to -o as JSON when asked, and the report's text with the count last. True
|
||||
/// when an error is among them.
|
||||
fn report(video: &str, issues: Vec<Issue>, more: Vec<Finding>, passed: Vec<String>, out: Option<&str>, fps: f64) -> R<(String, bool)> {
|
||||
let found = findings_of(issues, more, fps);
|
||||
let mut found = findings_of(issues, more, fps);
|
||||
// what an earlier export of the same composition already had says so: the change between them didn't move it
|
||||
if let Some(e) = cause::earlier(std::path::Path::new(video)) {
|
||||
cause::carried(&mut found, &e, fps);
|
||||
}
|
||||
let bad = found.iter().any(|f| f.level == Level::Error);
|
||||
if let Some(out) = out {
|
||||
let j = json!({"file": video, "fps": fps, "findings": found, "passed": passed});
|
||||
@@ -228,47 +224,6 @@ fn report(video: &str, issues: Vec<Issue>, more: Vec<Finding>, passed: Vec<Strin
|
||||
s.push_str(&line);
|
||||
s.push('\n');
|
||||
}
|
||||
Ok((s + &format!("raea check: {}", finding::count(&found)), bad))
|
||||
}
|
||||
|
||||
struct Probe {
|
||||
w: f64,
|
||||
h: f64,
|
||||
duration: f64,
|
||||
/// when the picture ends, on the clock FFmpeg's filters read: it starts at the file's first stream, sound can run on
|
||||
/// past the picture, and the container's duration counts that
|
||||
picture: f64,
|
||||
audio: bool,
|
||||
}
|
||||
|
||||
/// Where the picture's last packet ends, for a container that doesn't state the video stream's own length (Matroska)
|
||||
fn last_packet_end(video: &str) -> Option<f64> {
|
||||
let out = Command::new("ffprobe").args(["-v", "error", "-select_streams", "v:0", "-show_entries", "packet=pts_time,duration_time", "-of", "csv=p=0", video]).output().ok()?;
|
||||
String::from_utf8_lossy(&out.stdout)
|
||||
.lines()
|
||||
.filter_map(|l| {
|
||||
let mut parts = l.split(',');
|
||||
let t: f64 = parts.next()?.trim().parse().ok()?;
|
||||
Some(t + parts.next().and_then(|d| d.trim().parse::<f64>().ok()).unwrap_or(0.0))
|
||||
})
|
||||
.max_by(f64::total_cmp)
|
||||
}
|
||||
|
||||
impl Probe {
|
||||
fn of(video: &str) -> R<Probe> {
|
||||
let entries = "stream=codec_type,width,height,r_frame_rate,duration,start_time:format=duration,start_time";
|
||||
let out = Command::new("ffprobe").args(["-v", "error", "-show_entries", entries, "-of", "json", video]).output().map_err(|e| format!("ffprobe: {e}"))?;
|
||||
let v: Value = serde_json::from_slice(&out.stdout).map_err(|e| format!("ffprobe: {e}"))?;
|
||||
let streams = v["streams"].as_array().cloned().unwrap_or_default();
|
||||
let vid = streams.iter().find(|s| s["codec_type"] == "video").ok_or("no video stream")?;
|
||||
let seconds = |field: &Value| field.as_str().and_then(|d| d.parse::<f64>().ok());
|
||||
let duration = seconds(&v["format"]["duration"]).unwrap_or(0.0);
|
||||
let origin = seconds(&v["format"]["start_time"]).unwrap_or(0.0);
|
||||
let picture = match seconds(&vid["duration"]) {
|
||||
Some(length) => seconds(&vid["start_time"]).unwrap_or(origin) - origin + length,
|
||||
None => last_packet_end(video).map_or(duration, |end| end - origin),
|
||||
};
|
||||
let audio = streams.iter().any(|s| s["codec_type"] == "audio");
|
||||
Ok(Probe { w: vid["width"].as_f64().unwrap_or(1920.0), h: vid["height"].as_f64().unwrap_or(1080.0), duration, picture, audio })
|
||||
}
|
||||
s.push_str(&format!("raea check: {}", finding::count(&found)));
|
||||
Ok((s, bad))
|
||||
}
|
||||
+106
-33
@@ -101,54 +101,127 @@ pub(crate) fn x264_crf(head: &[u8]) -> Option<f64> {
|
||||
/// in its darks is the picture's own (8-bit glows and faint panels), which blotch_score can't always tell apart
|
||||
pub(crate) const X264_KEEPS: f64 = 16.0;
|
||||
|
||||
pub(crate) fn blotching(video: &str, probe: &Probe, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
/// How far a clean encode moves a sample's blotching (x264 crf 12 over the walkaround's unencoded frames, 11-19: at most 0.005)
|
||||
pub(crate) const BLOTCH_NOISE: f64 = 0.005;
|
||||
|
||||
/// Blotching's samples against the same frames of the composition drawn without encoding (raea-app-check-cause): None
|
||||
/// when the video isn't a render in a raea project's record
|
||||
fn blotching_cause(video: &str, probe: &Probe, scores: &[Option<f64>], w: usize, h: usize) -> Option<R<(cause::Against, Vec<Option<f64>>)>> {
|
||||
let (project, comp) = cause::composition_of(std::path::Path::new(video))?;
|
||||
Some((|| {
|
||||
if probe.fps <= 0.0 {
|
||||
return Err("the video doesn't say its frame rate".to_string());
|
||||
}
|
||||
let frames = cause::sampled(scores.len(), 2.0, probe.fps, (probe.picture * probe.fps).round() as i64 - 1);
|
||||
let me = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let before: Vec<Option<f64>> = cause::unencoded(&me, &project, &comp, &frames, w, h)?.iter().map(|y| blotch_score(y, w, h)).collect();
|
||||
Ok((cause::against(scores, &before, BLOTCHY, BLOTCH_NOISE), before))
|
||||
})())
|
||||
}
|
||||
|
||||
/// The crf an x264 encode that keeps the darks was made at: blotching isn't read for it
|
||||
pub(crate) fn x264_kept(video: &str) -> Option<f64> {
|
||||
let mut head = Vec::new();
|
||||
if let Ok(f) = std::fs::File::open(video) {
|
||||
let _ = std::io::Read::read_to_end(&mut std::io::Read::take(f, 8 << 20), &mut head);
|
||||
}
|
||||
if let Some(crf) = x264_crf(&head).filter(|c| *c <= X264_KEEPS) {
|
||||
x264_crf(&head).filter(|c| *c <= X264_KEEPS)
|
||||
}
|
||||
|
||||
pub(crate) fn blotching(video: &str, probe: &Probe, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
if let Some(crf) = x264_kept(video) {
|
||||
passed.push(format!("blotching: encoded by x264 at crf {crf}, which keeps the darks"));
|
||||
return Ok(());
|
||||
}
|
||||
let (w, h) = (probe.w as usize / 8 * 8, probe.h as usize / 8 * 8);
|
||||
let mut child = Command::new("ffmpeg")
|
||||
.args(["-v", "error", "-i", video, "-vf", &format!("fps=0.5,crop={w}:{h}:0:0,format=gray"), "-f", "rawvideo", "-"])
|
||||
.stdout(std::process::Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
let mut out = child.stdout.take().unwrap();
|
||||
let mut buf = vec![0u8; w * h];
|
||||
let mut scores: Vec<Option<f64>> = Vec::new();
|
||||
let mut frame = scorer(&mut scores, w, h);
|
||||
if crate::read::native() {
|
||||
crate::read::crops(video, w, h, &mut frame)?;
|
||||
} else {
|
||||
let mut child = Command::new("ffmpeg")
|
||||
.args(["-v", "error", "-i", video, "-vf", &format!("fps=0.5,crop={w}:{h}:0:0,format=gray"), "-f", "rawvideo", "-"])
|
||||
.stdout(std::process::Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
let mut out = child.stdout.take().unwrap();
|
||||
let mut buf = vec![0u8; w * h];
|
||||
while std::io::Read::read_exact(&mut out, &mut buf).is_ok() {
|
||||
frame(&buf);
|
||||
}
|
||||
let _ = child.wait();
|
||||
}
|
||||
drop(frame);
|
||||
blotching_from(video, probe, &scores, issues, passed);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Each grey crop's blotching, kept in `scores`
|
||||
pub(crate) fn scorer(scores: &mut Vec<Option<f64>>, w: usize, h: usize) -> impl FnMut(&[u8]) + Send + '_ {
|
||||
move |buf| scores.push(blotch_score(buf, w, h))
|
||||
}
|
||||
|
||||
/// What blotching's samples (one every 2 s) found
|
||||
pub(crate) fn blotching_from(video: &str, probe: &Probe, scores: &[Option<f64>], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let (w, h) = (probe.w as usize / 8 * 8, probe.h as usize / 8 * 8);
|
||||
let (mut bad, mut seen, mut worst) = (Vec::new(), 0, 0f64);
|
||||
let mut t = 0.0;
|
||||
while std::io::Read::read_exact(&mut out, &mut buf).is_ok() {
|
||||
if let Some(s) = blotch_score(&buf, w, h) {
|
||||
seen += 1;
|
||||
worst = worst.max(s);
|
||||
if std::env::var_os("RAEA_CHECK_DEBUG").is_some() {
|
||||
eprintln!("blotch {t:6.1}s {s:.3}");
|
||||
}
|
||||
if s > BLOTCHY {
|
||||
bad.push((t, s));
|
||||
}
|
||||
for (k, s) in scores.iter().enumerate() {
|
||||
let Some(s) = *s else { continue };
|
||||
let t = k as f64 * 2.0;
|
||||
seen += 1;
|
||||
worst = worst.max(s);
|
||||
if std::env::var_os("RAEA_CHECK_DEBUG").is_some() {
|
||||
eprintln!("blotch {t:6.1}s {s:.3}");
|
||||
}
|
||||
if s > BLOTCHY {
|
||||
bad.push((t, s));
|
||||
}
|
||||
t += 2.0;
|
||||
}
|
||||
let _ = child.wait();
|
||||
if !bad.is_empty() {
|
||||
let at = bad[0].0;
|
||||
let share = bad.len() as f64 / seen.max(1) as f64;
|
||||
issues.push(Issue {
|
||||
rule: "blotching",
|
||||
p: if share > 0.2 { 1 } else { 2 },
|
||||
at: Some(at),
|
||||
says: format!(
|
||||
"blocky patches in dark areas in {} of {seen} sampled frames (worst {:.0}% of dark blocks stepping); the encoder starved the near-blacks: export as PNG frames and encode with more bits for darks",
|
||||
bad.len(),
|
||||
worst * 100.0
|
||||
),
|
||||
});
|
||||
let found = format!("blocky patches in dark areas in {} of {seen} sampled frames (worst {:.0}% of dark blocks stepping)", bad.len(), worst * 100.0);
|
||||
let (p, at, says) = match blotching_cause(video, probe, scores, w, h) {
|
||||
// what the composition draws before any encoding is the picture's own (a phone's compression): no render
|
||||
// setting removes it, so it's said, not worked on
|
||||
Some(Ok(a)) if !a.0.by_encode(BLOTCH_NOISE) => (3, Some(at), format!("{found}: the picture's own, there as the composition draws them before any encoding (the footage's compression); the encode added none, so no render setting removes them")),
|
||||
Some(Ok(a)) => {
|
||||
let first = cause::Against::first(scores, &a.1, BLOTCHY, BLOTCH_NOISE).map(|i| i as f64 * 2.0);
|
||||
let own = if a.0.before > 0 { format!("; {} of the samples show the footage's own too, which stays", a.0.before) } else { String::new() };
|
||||
(if a.0.worse as f64 / a.0.of.max(1) as f64 > 0.2 { 1 } else { 2 }, first.or(Some(at)), format!("the encode added blocky patches in dark areas: {} of {} samples are blotchier than the composition draws them unencoded; render with --quality master, which gives the darks the bits they need{own}", a.0.worse, a.0.of))
|
||||
}
|
||||
Some(Err(why)) => (if share > 0.2 { 1 } else { 2 }, Some(at), format!("{found}; whether the encode made them or the picture holds them couldn't be told ({why}): render with --quality master if the encode starved the darks")),
|
||||
None => (if share > 0.2 { 1 } else { 2 }, Some(at), format!("{found}: the encode starved the near-blacks, or the footage holds them; render with --quality master, and check a render made in a raea project to tell which")),
|
||||
};
|
||||
issues.push(Issue { rule: "blotching", p, at, says });
|
||||
} else if seen > 0 {
|
||||
passed.push(format!("blotching: dark areas clean in {seen} sampled frames"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Caption contrast: at each text's middle frame, the pixels behind it against its colour, at least 3:1. The pixels
|
||||
/// behind are the half of the box least like the text.
|
||||
pub(crate) fn contrast(video: &str, runs: &[Run], w: f64, h: f64, probe: &Probe, issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let (sx, sy) = (probe.w / w, probe.h / h);
|
||||
let mut low = 0;
|
||||
let mut measured = 0;
|
||||
for r in runs.iter().filter(|r| r.size >= 20.0).take(80) {
|
||||
let [x, y, bw, bh] = r.box_;
|
||||
let crop = [(x * sx).max(0.0) as u32, (y * sy).max(0.0) as u32, (bw * sx) as u32, (bh * sy) as u32];
|
||||
if crop[0] + crop[2] > probe.w as u32 || crop[1] + crop[3] > probe.h as u32 {
|
||||
continue;
|
||||
}
|
||||
let t = (r.from + r.to) / 2.0;
|
||||
// the same measure `raea world` joins to a text from its render (raea-sys-measure, DR2)
|
||||
let ratio = if crate::read::native() { crate::read::contrast(video, t, crop, &r.color) } else { raea_sys_measure::contrast(std::path::Path::new(video), t, crop, &r.color) };
|
||||
let Some(ratio) = ratio else { continue };
|
||||
measured += 1;
|
||||
if ratio < 3.0 {
|
||||
low += 1;
|
||||
issues.push(Issue { rule: "contrast", p: 1, at: Some(t), says: format!("{} is {ratio:.1}:1 against what's behind it; make it at least 3:1 (a band, a shadow for separation, or another colour)", quote(&r.text)) });
|
||||
}
|
||||
}
|
||||
if measured > 0 && low == 0 {
|
||||
passed.push(format!("contrast: {measured} texts at 3:1 or better against their pixels"));
|
||||
}
|
||||
}
|
||||
+37
-24
@@ -162,13 +162,9 @@ pub(crate) fn bed_up(rms: &[f64], speak: &[bool]) -> Vec<(f64, String)> {
|
||||
/// The sound's rules on an export: dead stops always; with the voice's words, a stretch with no voice over it and a bed
|
||||
/// too close under it
|
||||
pub(crate) fn sound(video: &str, words: Option<&[Word]>, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
let out = Command::new("ffmpeg").args(["-v", "error", "-i", video, "-vn", "-ac", "1", "-ar", &SR.to_string(), "-f", "f32le", "-"]).output().map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
if !out.status.success() {
|
||||
return Err(format!("ffmpeg couldn't read the sound of {video}: {}", String::from_utf8_lossy(&out.stderr).trim()));
|
||||
}
|
||||
let x: Vec<f32> = out.stdout.chunks_exact(4).map(|b| f32::from_le_bytes([b[0], b[1], b[2], b[3]])).collect();
|
||||
let x = crate::read::mono(video, SR as u32)?;
|
||||
let (rms, bands) = levels(&x);
|
||||
sound_defects(&x, issues, passed);
|
||||
sound_defects(&x, &crate::read::channels(video, SR as u32)?, issues, passed);
|
||||
let found = |list: Vec<(f64, String)>, p: u8| crate::defects::moments("sound", p, list);
|
||||
let stops = dead_stops(&rms, &bands);
|
||||
if stops.is_empty() {
|
||||
@@ -178,19 +174,7 @@ pub(crate) fn sound(video: &str, words: Option<&[Word]>, issues: &mut Vec<Issue>
|
||||
let Some(words) = words.filter(|w| !w.is_empty()) else { return Ok(()) };
|
||||
let speak = speaking(words, rms.len());
|
||||
// momentary loudness (EBU R128, 400 ms) every 100 ms, from ffmpeg's meter
|
||||
let meter = Command::new("ffmpeg")
|
||||
.args(["-nostats", "-hide_banner", "-i", video, "-vn", "-af", "ebur128=metadata=1,ametadata=print:key=lavfi.r128.M:file=-", "-f", "null", "-"])
|
||||
.output()
|
||||
.map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
let (mut mt, mut mv) = (Vec::new(), Vec::new());
|
||||
for line in String::from_utf8_lossy(&meter.stdout).lines() {
|
||||
if let Some(t) = line.split("pts_time:").nth(1).filter(|_| line.starts_with("frame:")) {
|
||||
mt.push(t.trim().parse::<f64>().unwrap_or(0.0));
|
||||
} else if let Some(v) = line.strip_prefix("lavfi.r128.M=") {
|
||||
mv.push(v.trim().parse::<f64>().unwrap_or(-120.0));
|
||||
}
|
||||
}
|
||||
mt.truncate(mv.len());
|
||||
let (mt, mv) = if crate::read::native() { crate::read::meter(video)? } else { ffmpeg_meter(video)? };
|
||||
if let Some((voice, over)) = over_voice(&mt, &mv, &speak) {
|
||||
if over.is_empty() {
|
||||
passed.push(format!("sound: nothing without the voice is louder than it ({voice:.1} LUFS momentary)"));
|
||||
@@ -205,6 +189,24 @@ pub(crate) fn sound(video: &str, words: Option<&[Word]>, issues: &mut Vec<Issue>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `ffmpeg ... -af ebur128=metadata=1,ametadata=print:key=lavfi.r128.M:file=-`: each meter reading's time and LUFS
|
||||
fn ffmpeg_meter(video: &str) -> R<(Vec<f64>, Vec<f64>)> {
|
||||
let meter = Command::new("ffmpeg")
|
||||
.args(["-nostats", "-hide_banner", "-i", video, "-vn", "-af", "ebur128=metadata=1,ametadata=print:key=lavfi.r128.M:file=-", "-f", "null", "-"])
|
||||
.output()
|
||||
.map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
let (mut mt, mut mv) = (Vec::new(), Vec::new());
|
||||
for line in String::from_utf8_lossy(&meter.stdout).lines() {
|
||||
if let Some(t) = line.split("pts_time:").nth(1).filter(|_| line.starts_with("frame:")) {
|
||||
mt.push(t.trim().parse::<f64>().unwrap_or(0.0));
|
||||
} else if let Some(v) = line.strip_prefix("lavfi.r128.M=") {
|
||||
mv.push(v.trim().parse::<f64>().unwrap_or(-120.0));
|
||||
}
|
||||
}
|
||||
mt.truncate(mv.len());
|
||||
Ok((mt, mv))
|
||||
}
|
||||
|
||||
pub(crate) fn ffmpeg_stderr(args: &[&str]) -> R<String> {
|
||||
let out = Command::new("ffmpeg").args(args).output().map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
Ok(String::from_utf8_lossy(&out.stderr).into_owned())
|
||||
@@ -212,8 +214,9 @@ pub(crate) fn ffmpeg_stderr(args: &[&str]) -> R<String> {
|
||||
|
||||
/// -14 LUFS integrated (±1) and a true peak at or below -1 dBTP (the floor's mix line)
|
||||
pub(crate) fn loudness(video: &str, taste: Option<&Taste>, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
// the same measure `raea world` joins to a render as its Mix (raea-sys-measure, DR2)
|
||||
let Some((i, peak)) = raea_sys_measure::loudness(std::path::Path::new(video)) else { return Ok(()) };
|
||||
// the same measure `raea world` joins to a render as its Mix (raea-sys-measure, DR2), or raea's own without FFmpeg
|
||||
let measured = if crate::read::native() { crate::read::loudness(video) } else { raea_sys_measure::loudness(std::path::Path::new(video)) };
|
||||
let Some((i, peak)) = measured else { return Ok(()) };
|
||||
let mut ok = true;
|
||||
let target = taste.map_or(-14.0, |t| t.value);
|
||||
if (i - target).abs() > 1.0 {
|
||||
@@ -257,8 +260,19 @@ pub(crate) fn frozen_stretches(log: &str, duration: f64) -> Vec<(f64, f64)> {
|
||||
|
||||
pub(crate) fn freezes(video: &str, probe: &Probe, taste: Option<&Taste>, issues: &mut Vec<Issue>, passed: &mut Vec<String>) -> R<()> {
|
||||
let most = taste.map_or(3.0, |t| t.value);
|
||||
let err = ffmpeg_stderr(&["-hide_banner", "-nostats", "-i", video, "-an", "-vf", &format!("freezedetect=n=-60dB:d={most}"), "-f", "null", "-"])?;
|
||||
let stretches = frozen_stretches(&err, probe.picture);
|
||||
let err = if crate::read::native() {
|
||||
crate::read::freezes(video, -60.0, most)?
|
||||
} else {
|
||||
ffmpeg_stderr(&["-hide_banner", "-nostats", "-i", video, "-an", "-vf", &format!("freezedetect=n=-60dB:d={most}"), "-f", "null", "-"])?
|
||||
};
|
||||
freezes_from(&err, probe, taste, issues, passed);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The freezes freezedetect's lines found (`taste`'s still-max when the person set one, else 3 s)
|
||||
pub(crate) fn freezes_from(err: &str, probe: &Probe, taste: Option<&Taste>, issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let most = taste.map_or(3.0, |t| t.value);
|
||||
let stretches = frozen_stretches(err, probe.picture);
|
||||
for &(s, d) in &stretches {
|
||||
let says = format!("nothing changes for {d:.1} s; give it a reason to hold, or cut it shorter");
|
||||
issues.push(match taste {
|
||||
@@ -269,5 +283,4 @@ pub(crate) fn freezes(video: &str, probe: &Probe, taste: Option<&Taste>, issues:
|
||||
if stretches.is_empty() {
|
||||
passed.push(format!("frozen: nothing holds still for {most} s"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
+12
-4
@@ -356,15 +356,23 @@ fn a_card_sharing_one_word_with_another_line_isnt_held_to_it() {
|
||||
fn clipping_is_found_and_a_loud_clean_tone_isnt() {
|
||||
// a clean tone near full scale, then the same tone clamped (a limiter's flat tops), then pushed past full scale
|
||||
let loud = tone(3.0, &[(0.0, 3.0, -1.0)]);
|
||||
assert!(clipped(&loud).is_empty(), "{:?}", clipped(&loud));
|
||||
let one = |x: &[f32]| clipped(&[x.to_vec()]);
|
||||
assert!(one(&loud).is_empty(), "{:?}", one(&loud));
|
||||
let clamped: Vec<f32> = loud.iter().map(|v| (v * 10.0).clamp(-0.3, 0.3)).collect();
|
||||
assert_eq!(clipped(&clamped).len(), 1);
|
||||
assert_eq!(one(&clamped).len(), 1);
|
||||
let over: Vec<f32> = loud.iter().map(|v| (v * 2.0).clamp(-1.0, 1.0)).collect();
|
||||
assert_eq!(clipped(&over).len(), 1);
|
||||
assert_eq!(one(&over).len(), 1);
|
||||
// one transient hitting full scale once isn't clipping
|
||||
let mut once = tone(3.0, &[(0.0, 3.0, -20.0)]);
|
||||
once[SR] = 1.0;
|
||||
assert!(clipped(&once).is_empty());
|
||||
assert!(one(&once).is_empty());
|
||||
// clipping is a channel's: one side clipped is found; a centred voice at -1.6 dBFS a side is clean, though the mono
|
||||
// fold (L + R) * 0.707 takes it past full scale (11-19: the walkaround's master read as clipping)
|
||||
assert_eq!(clipped(&[loud.clone(), over.clone()]).len(), 1);
|
||||
let centred: Vec<f32> = loud.iter().map(|v| v * 0.92).collect();
|
||||
assert!(clipped(&[centred.clone(), centred.clone()]).is_empty());
|
||||
let folded: Vec<f32> = centred.iter().map(|v| (v + v) * 0.7071).collect();
|
||||
assert_eq!(one(&folded).len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "raea-app-check-text"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea check's text rules on a render's manifest: clipped, UI zones, reading time, face, cues, brand kit"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
serde_json = "1"
|
||||
# a transcript's words, read as `raea world` reads them (docs/direction.feature DR1)
|
||||
raea-core-facts = { path = "../../../core/facts" }
|
||||
@@ -1,25 +1,56 @@
|
||||
use super::*;
|
||||
//! What a render's text breaks, from its manifest alone: clipped, in the platform's UI zones, too brief to read, over
|
||||
//! the face, off its cue, and the brand kit it was styled from. raea check's text rules, split out of raea-app-check so
|
||||
//! `raea render --manifest` holds its own text to them as it finishes, a check's round sooner.
|
||||
use serde_json::Value;
|
||||
|
||||
pub type R<T> = Result<T, String>;
|
||||
|
||||
use raea_core_facts::{Finding, Level};
|
||||
|
||||
/// One thing a rule found: its rule, its rank (P0 breaks the piece to P3 polish), when (seconds) and what to do.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Issue {
|
||||
pub rule: &'static str,
|
||||
pub p: u8,
|
||||
pub at: Option<f64>,
|
||||
pub says: String,
|
||||
}
|
||||
|
||||
impl Issue {
|
||||
/// As a Finding `by` a command (docs/direction.feature DR3: P0 and P1 errors, P2 a warn, P3 a note), about the
|
||||
/// frame its second falls on at `fps`
|
||||
pub fn finding(&self, by: &str, fps: f64) -> Finding {
|
||||
let f = Finding::new(self.rule, Level::of_rank(self.p), &self.says, by);
|
||||
match self.at {
|
||||
Some(t) => {
|
||||
let n = (t * fps).round() as i64;
|
||||
f.frames(n, n + 1)
|
||||
}
|
||||
None => f,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A text as it stays on screen: from the frame it comes on to the frame it leaves. Typing (a text growing into the
|
||||
/// next) and counting (only its digits changing) are one run, judged by its last text.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct Run {
|
||||
pub(crate) text: String,
|
||||
pub(crate) from: f64,
|
||||
pub(crate) to: f64,
|
||||
pub(crate) box_: [f64; 4],
|
||||
pub struct Run {
|
||||
pub text: String,
|
||||
pub from: f64,
|
||||
pub to: f64,
|
||||
pub box_: [f64; 4],
|
||||
/// where its letters are on every frame it shows its whole text (the manifest's `ink`, else its box: a centred line in
|
||||
/// a full-width box is nowhere near x = 0, #89): a text the camera carries (a sign on a panning street) moves
|
||||
/// through the frame's edges and zones, which only counts against it when no frame shows it clear
|
||||
pub(crate) boxes: Vec<[f64; 4]>,
|
||||
pub(crate) color: String,
|
||||
pub(crate) size: f64,
|
||||
pub boxes: Vec<[f64; 4]>,
|
||||
pub color: String,
|
||||
pub size: f64,
|
||||
}
|
||||
|
||||
/// The brand kit the cut was styled from (brand/ at or above the manifest's or the video's folder, as render finds
|
||||
/// brand.css): a kit `raea brand` read from a thin fetch that nobody corrected by hand is a placeholder, P1; a brand.css
|
||||
/// with no brand.json beside it wasn't read from the brand at all, P2
|
||||
pub(crate) fn brand_kit(near: &[&str], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
pub fn brand_kit(near: &[&str], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
for start in near.iter().filter(|p| !p.is_empty()) {
|
||||
let abs = dunce::canonicalize(&std::path::Path::new(start)).unwrap_or_else(|_| std::path::PathBuf::from(start));
|
||||
@@ -50,7 +81,7 @@ pub(crate) fn brand_kit(near: &[&str], issues: &mut Vec<Issue>, passed: &mut Vec
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn text_runs(manifest: &Value) -> Vec<Run> {
|
||||
pub fn text_runs(manifest: &Value) -> Vec<Run> {
|
||||
let fps = manifest["fps"].as_f64().unwrap_or(30.0);
|
||||
let frames = manifest["frames"].as_array().cloned().unwrap_or_default();
|
||||
let mut open: Vec<Run> = Vec::new();
|
||||
@@ -95,11 +126,11 @@ pub(crate) fn text_runs(manifest: &Value) -> Vec<Run> {
|
||||
}
|
||||
|
||||
/// The share of the face's area a text may cover before it's a fault (@raea/video's proofBoxes keeps the same 8%)
|
||||
pub(crate) const FACE_COVER: f64 = 0.08;
|
||||
pub const FACE_COVER: f64 = 0.08;
|
||||
|
||||
/// The face over time from a perception.json (`raea cut`: each clip's first frame, the face at its middle in the
|
||||
/// edit's px): [from, to) in seconds and the face's box, for the stretches that have one
|
||||
pub(crate) fn faces_of(perception: &Value, fps: f64) -> Vec<(f64, f64, [f64; 4])> {
|
||||
pub fn faces_of(perception: &Value, fps: f64) -> Vec<(f64, f64, [f64; 4])> {
|
||||
let mut keys: Vec<(f64, Option<[f64; 4]>)> = perception.as_object().into_iter().flatten().filter_map(|(k, v)| {
|
||||
let face = v["face"].as_object().map(|f| ["x", "y", "w", "h"].map(|n| f.get(n).and_then(Value::as_f64).unwrap_or(0.0)));
|
||||
Some((k.parse::<f64>().ok()? / fps, face))
|
||||
@@ -110,7 +141,7 @@ pub(crate) fn faces_of(perception: &Value, fps: f64) -> Vec<(f64, f64, [f64; 4])
|
||||
|
||||
/// Text over the face: a run that covers more than FACE_COVER of the face's area while that face is up, on every frame
|
||||
/// that shows it whole (a text the camera carries counts only when no frame shows it clear)
|
||||
pub(crate) fn face_cover(runs: &[Run], faces: &[(f64, f64, [f64; 4])], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
pub fn face_cover(runs: &[Run], faces: &[(f64, f64, [f64; 4])], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let share = |b: &[f64; 4], f: &[f64; 4]| {
|
||||
let ox = (b[0] + b[2]).min(f[0] + f[2]) - b[0].max(f[0]);
|
||||
let oy = (b[1] + b[3]).min(f[1] + f[3]) - b[1].max(f[1]);
|
||||
@@ -134,7 +165,7 @@ pub(crate) fn face_cover(runs: &[Run], faces: &[(f64, f64, [f64; 4])], issues: &
|
||||
}
|
||||
|
||||
/// the zones where text can't go, as [top, right, bottom, left] at 1080 wide (sdk/guides/craft/floor.md)
|
||||
pub(crate) fn zones(w: f64, h: f64, shape: Option<&str>, platform: Option<&str>) -> [f64; 4] {
|
||||
pub fn zones(w: f64, h: f64, shape: Option<&str>, platform: Option<&str>) -> [f64; 4] {
|
||||
let r = w / h;
|
||||
let shape = shape.unwrap_or(if r < 0.7 { "9:16" } else if r < 0.9 { "4:5" } else if r < 1.2 { "1:1" } else { "16:9" });
|
||||
let z = match (shape, platform) {
|
||||
@@ -153,12 +184,12 @@ pub(crate) fn zones(w: f64, h: f64, shape: Option<&str>, platform: Option<&str>)
|
||||
/// A caption the voice reads out: every word of the text is said while it's on screen (from a little before it comes
|
||||
/// on). The viewer hears it as it shows, so it needs no reading time of its own (karaoke groups are up for as long as
|
||||
/// they take to say).
|
||||
pub(crate) fn spoken(r: &Run, words: &[Word]) -> bool {
|
||||
pub fn spoken(r: &Run, words: &[Word]) -> bool {
|
||||
let tokens: Vec<String> = r.text.split_whitespace().map(norm).filter(|t| !t.is_empty()).collect();
|
||||
!tokens.is_empty() && tokens.iter().all(|t| words.iter().any(|w| norm(&w.text) == *t && w.start >= r.from - 0.3 && w.start <= r.to + 0.1))
|
||||
}
|
||||
|
||||
pub(crate) fn text_rules(runs: &[Run], heard: Option<&[Word]>, w: f64, h: f64, shape: Option<&str>, platform: Option<&str>, issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
pub fn text_rules(runs: &[Run], heard: Option<&[Word]>, w: f64, h: f64, shape: Option<&str>, platform: Option<&str>, issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let [zt, zr, zb, zl] = zones(w, h, shape, platform);
|
||||
let (mut clipped, mut unsafe_, mut brief) = (0, 0, 0);
|
||||
for r in runs {
|
||||
@@ -194,56 +225,30 @@ pub(crate) fn text_rules(runs: &[Run], heard: Option<&[Word]>, w: f64, h: f64, s
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn quote(s: &str) -> String {
|
||||
pub fn quote(s: &str) -> String {
|
||||
let s: String = s.chars().take(40).collect();
|
||||
format!("\u{201c}{s}\u{201d}")
|
||||
}
|
||||
|
||||
/// Caption contrast: at each text's middle frame, the pixels behind it against its colour, at least 3:1. The pixels
|
||||
/// behind are the half of the box least like the text.
|
||||
pub(crate) fn contrast(video: &str, runs: &[Run], w: f64, h: f64, probe: &Probe, issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let (sx, sy) = (probe.w / w, probe.h / h);
|
||||
let mut low = 0;
|
||||
let mut measured = 0;
|
||||
for r in runs.iter().filter(|r| r.size >= 20.0).take(80) {
|
||||
let [x, y, bw, bh] = r.box_;
|
||||
let crop = [(x * sx).max(0.0) as u32, (y * sy).max(0.0) as u32, (bw * sx) as u32, (bh * sy) as u32];
|
||||
if crop[0] + crop[2] > probe.w as u32 || crop[1] + crop[3] > probe.h as u32 {
|
||||
continue;
|
||||
}
|
||||
let t = (r.from + r.to) / 2.0;
|
||||
// the same measure `raea world` joins to a text from its render (raea-sys-measure, DR2)
|
||||
let Some(ratio) = raea_sys_measure::contrast(std::path::Path::new(video), t, crop, &r.color) else { continue };
|
||||
measured += 1;
|
||||
if ratio < 3.0 {
|
||||
low += 1;
|
||||
issues.push(Issue { rule: "contrast", p: 1, at: Some(t), says: format!("{} is {ratio:.1}:1 against what's behind it; make it at least 3:1 (a band, a shadow for separation, or another colour)", quote(&r.text)) });
|
||||
}
|
||||
}
|
||||
if measured > 0 && low == 0 {
|
||||
passed.push(format!("contrast: {measured} texts at 3:1 or better against their pixels"));
|
||||
}
|
||||
}
|
||||
|
||||
/// A transcript's word: its text, start and end in seconds (its end is its start when the transcript doesn't say).
|
||||
pub(crate) use raea_core_facts::Word;
|
||||
pub use raea_core_facts::Word;
|
||||
|
||||
/// A transcript's words (raea_core_facts::transcript_words: {text, start} in seconds, or t, start_ms, or {text, from}
|
||||
/// in frames at `fps`), as the app's words.json and `raea render --words` have them.
|
||||
pub(crate) fn transcript(path: &str, fps: f64) -> R<Vec<Word>> {
|
||||
pub fn transcript(path: &str, fps: f64) -> R<Vec<Word>> {
|
||||
let v: Value = serde_json::from_str(&std::fs::read_to_string(path).map_err(|e| format!("{path}: {e}"))?).map_err(|e| format!("{path}: {e}"))?;
|
||||
v.as_array().ok_or_else(|| format!("{path}: expected an array of words ({{text, start}} in seconds or {{text, from}} in frames)"))?;
|
||||
Ok(raea_core_facts::transcript_words(&v, fps))
|
||||
}
|
||||
|
||||
pub(crate) use raea_core_facts::word_key as norm;
|
||||
pub use raea_core_facts::word_key as norm;
|
||||
|
||||
pub(crate) const SMALL: [&str; 24] = ["the", "and", "you", "your", "for", "with", "that", "this", "its", "it's", "are", "was", "our", "out", "from", "into", "then", "than", "but", "not", "all", "can", "has", "have"];
|
||||
pub const SMALL: [&str; 24] = ["the", "and", "you", "your", "for", "with", "that", "this", "its", "it's", "are", "was", "our", "out", "from", "into", "then", "than", "but", "not", "all", "can", "has", "have"];
|
||||
|
||||
/// Cues land on their words: a text whose words the voice says nearby comes on with the first of them, not after it.
|
||||
/// The text is found by its first word of weight, and then measured from the first word it shows: a caption "of the
|
||||
/// spend" comes on with "of", when the voice says "of the" just before "spend".
|
||||
pub(crate) fn cues(runs: &[Run], words: &[Word], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
pub fn cues(runs: &[Run], words: &[Word], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let (mut checked, mut off) = (0, 0);
|
||||
for r in runs {
|
||||
let shown: Vec<String> = r.text.split_whitespace().map(norm).filter(|t| !t.is_empty()).collect();
|
||||
@@ -19,6 +19,8 @@ serde_json = "1"
|
||||
# project's compositions
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
raea-app-check = { path = "../check" }
|
||||
# the check's text rules, held to a video render's manifest as it ends
|
||||
raea-app-check-text = { path = "../check/text" }
|
||||
raea-app-registry = { path = "../workspace/registry" }
|
||||
# the project's notes, whose asks' checks raea check runs beside its rules (DR6)
|
||||
raea-app-notes = { path = "../notes" }
|
||||
|
||||
@@ -38,7 +38,7 @@ pub fn rendered(args: &[String]) -> i32 {
|
||||
if args.first().map(String::as_str) != Some("render") {
|
||||
return 0;
|
||||
}
|
||||
let found = finding::taken();
|
||||
let mut found = finding::taken();
|
||||
let through = despite(args, std::env::var("RAEA_DESPITE").ok());
|
||||
let excused: Vec<Despite> = through.iter().map(|(c, w)| Despite { check: c.clone(), why: w.clone() }).collect();
|
||||
let out = raea_runtime_bundle::flag(args, "-o").or_else(|| raea_runtime_bundle::flag(args, "--review")).map(PathBuf::from);
|
||||
@@ -46,6 +46,13 @@ pub fn rendered(args: &[String]) -> i32 {
|
||||
let manifest = raea_runtime_bundle::flag(args, "--manifest").map(PathBuf::from).or_else(|| Some(raea_runtime_world::manifest_for(out.as_deref()?, std::path::Path::new(args.get(1)?))));
|
||||
if let Some(m) = manifest {
|
||||
if let Some(mut v) = std::fs::read(&m).ok().and_then(|b| serde_json::from_slice::<Value>(&b).ok()) {
|
||||
// a video's text, held to the check's text rules as it finishes, a check's round sooner
|
||||
if out.as_deref().and_then(|o| o.extension()).is_some_and(|x| x == "mp4" || x == "mov") {
|
||||
for f in text_found(&v) {
|
||||
println!("{}", f.line());
|
||||
found.push(f);
|
||||
}
|
||||
}
|
||||
v["findings"] = json!(found);
|
||||
if !excused.is_empty() {
|
||||
v["despite"] = json!(excused);
|
||||
@@ -63,6 +70,26 @@ pub fn rendered(args: &[String]) -> i32 {
|
||||
code
|
||||
}
|
||||
|
||||
/// What a video render's text breaks, from its manifest (raea-app-check-text, the rules `raea check` holds it to): text
|
||||
/// off the frame is an error, as the check has it; text in a UI zone a warn, by the default zones, since the platform's
|
||||
/// are the check's to decide (`--platform`); reading time waits for the check, which has the transcript to tell a
|
||||
/// caption the voice reads out from one that has to be read.
|
||||
fn text_found(manifest: &Value) -> Vec<Finding> {
|
||||
let runs = raea_app_check_text::text_runs(manifest);
|
||||
let (w, h, fps) = (manifest["width"].as_f64().unwrap_or(1080.0), manifest["height"].as_f64().unwrap_or(1920.0), manifest["fps"].as_f64().unwrap_or(30.0));
|
||||
let (mut issues, mut passed) = (Vec::new(), Vec::new());
|
||||
raea_app_check_text::text_rules(&runs, None, w, h, None, None, &mut issues, &mut passed);
|
||||
let mut found = Vec::new();
|
||||
for mut i in issues.into_iter().filter(|i| i.rule != "reading") {
|
||||
if i.rule == "safe-area" {
|
||||
i.p = 2;
|
||||
i.says.push_str(" (by the default zones: `raea check --platform P` holds it to the platform's)");
|
||||
}
|
||||
found.push(i.finding("raea render", fps));
|
||||
}
|
||||
found
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -71,6 +98,23 @@ mod tests {
|
||||
v.iter().map(|a| a.to_string()).collect()
|
||||
}
|
||||
|
||||
/// A video's text off the frame fails its render, as the check fails it; text in a UI zone is a warn by the
|
||||
/// default zones; a word on screen too briefly is left to the check, which has the transcript
|
||||
#[test]
|
||||
fn a_video_render_holds_its_text_to_the_check_s_rules() {
|
||||
let text = |t: &str, b: [f64; 4]| json!({"text": t, "box": b, "opacity": 1.0, "size": 60.0, "color": "rgb(255, 255, 255)"});
|
||||
let frames: Vec<Value> = (0..48).map(|f| json!({"frame": f, "videos": [], "text": [
|
||||
text("OFF THE EDGE", [900.0, 800.0, 400.0, 80.0]),
|
||||
text("Per month", [700.0, 1233.0, 318.0, 44.0]),
|
||||
if f < 3 { text("Two words", [200.0, 900.0, 300.0, 80.0]) } else { json!({"text": "", "box": [0, 0, 0, 0]}) },
|
||||
]})).collect();
|
||||
let found = text_found(&json!({"width": 1080, "height": 1920, "fps": 24, "frames": frames}));
|
||||
let got: Vec<(&str, Level)> = found.iter().map(|f| (f.check.as_str(), f.level)).collect();
|
||||
assert_eq!(got, vec![("clipped", Level::Error), ("safe-area", Level::Warn)], "{found:?}");
|
||||
assert!(found[1].says.contains("--platform"));
|
||||
assert_eq!(found[0].frames, Some([0, 1]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_error_fails_the_render_unless_it_is_let_through_and_says_by_what() {
|
||||
let found = vec![Finding::new("clips", Level::Error, "rider in seat", "raea render"), Finding::new("tilted", Level::Warn, "vase leans", "raea render")];
|
||||
|
||||
@@ -32,6 +32,11 @@ pub const USAGE: &str = "raea export-game EDIT.tsx -o OUT [--target mac-app|mac-
|
||||
|
||||
/// `raea export-game EDIT.tsx -o OUT ...`
|
||||
pub fn export(args: &[String]) -> R<String> {
|
||||
// its targets are a Mac's, signed with codesign, and raea's Windows and Linux releases carry no game player: there
|
||||
// it said "no player ... (build it: cargo build ...)", which a person can't act on
|
||||
if !cfg!(target_os = "macos") {
|
||||
return Err("raea export-game makes a Mac game (an .app or a command) and runs on a Mac; Windows and Linux games aren't there yet (sdk/react/docs/game-export.md)".into());
|
||||
}
|
||||
let usage = USAGE;
|
||||
let tsx = PathBuf::from(args.get(1).filter(|a| !a.starts_with("--")).ok_or(usage)?);
|
||||
let tsx = dunce::canonicalize(&tsx).map_err(|e| format!("{}: {e}", tsx.display()))?;
|
||||
|
||||
@@ -99,10 +99,22 @@ fn shape(expr: &str, out: &Path, meshes: &mut BTreeMap<String, String>) -> R<Val
|
||||
Some(f) => f.clone(),
|
||||
None => {
|
||||
let f = format!("meshes/mesh{k}.glb");
|
||||
let m = raea_core_shape::solid(expr)?;
|
||||
raea_core_shape::export(&m, &out.join(&f).to_string_lossy(), "glb")?;
|
||||
// and as an .obj, which Godot imports as a mesh of its own (a .glb comes in as a scene)
|
||||
raea_core_shape::export(&m, &out.join(f.replace(".glb", ".obj")).to_string_lossy(), "obj")?;
|
||||
let (glb, obj) = (out.join(&f).to_string_lossy().into_owned(), out.join(f.replace(".glb", ".obj")).to_string_lossy().into_owned());
|
||||
match expr.strip_prefix("buffer:") {
|
||||
// a mesh given by its own vertices (a <BufferMesh>, a three.js geometry through raea/r3f): written as it
|
||||
// is, with its normals and texture coordinates, since it needn't be a closed solid
|
||||
Some(b) => {
|
||||
let (t, uv) = raea_core_shape::buffer_tris(b)?;
|
||||
raea_core_shape::export_tris(&t, uv.as_deref(), &glb, "glb")?;
|
||||
raea_core_shape::export_tris(&t, uv.as_deref(), &obj, "obj")?;
|
||||
}
|
||||
None => {
|
||||
let m = raea_core_shape::solid(expr)?;
|
||||
raea_core_shape::export(&m, &glb, "glb")?;
|
||||
raea_core_shape::export(&m, &obj, "obj")?;
|
||||
}
|
||||
}
|
||||
meshes.insert(expr.to_string(), f.clone());
|
||||
f
|
||||
}
|
||||
@@ -310,6 +322,10 @@ mod tests {
|
||||
assert!(out.join(v["file"].as_str().unwrap()).is_file());
|
||||
// the same mesh twice is one file
|
||||
assert_eq!(shape("difference(box(1, 1, 1), sphere(0.6))", &out, &mut m).unwrap(), v);
|
||||
// a buffer mesh (an open quad, as raea/r3f gives a three.js PlaneGeometry) is a mesh file too, not refused
|
||||
let q = shape(r#"buffer:{"positions": [0,0,0, 1,0,0, 1,1,0, 0,1,0], "indices": [0,1,2, 0,2,3]}"#, &out, &mut m).unwrap();
|
||||
assert_eq!(q["type"], "mesh");
|
||||
assert!(out.join(q["file"].as_str().unwrap()).is_file() && out.join(q["obj"].as_str().unwrap()).is_file());
|
||||
let _ = std::fs::remove_dir_all(&out);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "raea-app-layers"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "`raea export layers`: a composition as its layers (captions, graphics, footage, under, sound) and the timeline that places them, layers.json, which every editor's export is written from (docs/layers.feature LA4)"
|
||||
|
||||
[dependencies]
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
raea-io-alpha = { path = "../../io/alpha" }
|
||||
raea-io-media = { path = "../../io/media", default-features = false, features = ["soft-audio", "apple"] }
|
||||
# the renderer's own lookup of a staticFile path (/media/x), so the export finds the files the render drew
|
||||
raea-core-scene = { path = "../../core/scene" }
|
||||
# canonicalize without Windows' \\?\ prefix, as the rest of raea does
|
||||
dunce = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
@@ -0,0 +1,21 @@
|
||||
// docs/layers.feature LA3a: captions whose words light up as they're said, over full-frame footage
|
||||
import { AbsoluteFill, Composition, Video, registerRoot, staticFile, useCurrentFrame } from "raea";
|
||||
|
||||
const WORDS = ["Each", "word", "lights", "up"];
|
||||
|
||||
function Edit() {
|
||||
const f = useCurrentFrame();
|
||||
const lit = Math.min(WORDS.length - 1, Math.floor(f / 12));
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#000" }}>
|
||||
<Video src={staticFile("clip.mp4")} style={{ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover" }} />
|
||||
<div data-raea-role="caption" style={{ position: "absolute", left: 0, right: 0, bottom: 80, textAlign: "center", fontSize: 60, fontWeight: 800, color: "#fff" }}>
|
||||
{WORDS.map((w, i) => (
|
||||
<span key={w} style={{ color: i === lit ? "#ffd400" : "#fff" }}>{w} </span>
|
||||
))}
|
||||
</div>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="edit" width={1280} height={720} fps={30} durationInFrames={60} component={Edit} />);
|
||||
@@ -0,0 +1,20 @@
|
||||
// docs/layers.feature LA3a: full-frame footage with a lower third (a bar and words) and captions
|
||||
import { AbsoluteFill, Composition, Sequence, Video, registerRoot, staticFile } from "raea";
|
||||
|
||||
function Edit() {
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#000" }}>
|
||||
<Video src={staticFile("clip.mp4")} style={{ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover" }} />
|
||||
<div style={{ position: "absolute", left: 0, bottom: 200, width: 620, height: 90, background: "#ff3b30" }}>
|
||||
<span style={{ position: "absolute", left: 32, top: 18, fontSize: 44, color: "#fff" }}>Jane Doe, raea</span>
|
||||
</div>
|
||||
<Sequence from={10} durationInFrames={40}>
|
||||
<div data-raea-role="caption" style={{ position: "absolute", left: 0, right: 0, bottom: 60, textAlign: "center", fontSize: 52, color: "#fff", textShadow: "0 2px 6px #000" }}>
|
||||
The words as they're said
|
||||
</div>
|
||||
</Sequence>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="edit" width={1280} height={720} fps={30} durationInFrames={60} component={Edit} />);
|
||||
@@ -0,0 +1,15 @@
|
||||
// docs/layers.feature LA3a: footage as a picture in picture on a coloured card, over a background
|
||||
import { AbsoluteFill, Composition, Video, registerRoot, staticFile } from "raea";
|
||||
|
||||
function Edit() {
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#14161c" }}>
|
||||
<div style={{ position: "absolute", left: 120, top: 120, width: 700, height: 420, background: "#2050ff", borderRadius: 24 }}>
|
||||
<Video src={staticFile("clip.mp4")} style={{ position: "absolute", left: 30, top: 30, width: 640, height: 360 }} />
|
||||
</div>
|
||||
<div style={{ position: "absolute", left: 880, top: 160, fontSize: 56, fontWeight: 800, color: "#fff" }}>On the card</div>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="edit" width={1280} height={720} fps={30} durationInFrames={60} component={Edit} />);
|
||||
@@ -0,0 +1,29 @@
|
||||
// docs/layers.feature LA3a: 3D with a title over it and a caption (the 3D is in the graphics layer, never the captions')
|
||||
import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";
|
||||
import { Entity } from "raea/3d";
|
||||
import { StandardMaterial } from "raea/pbr";
|
||||
import { Cuboid, Mesh3d } from "raea/mesh";
|
||||
import { AmbientLight, DirectionalLight } from "raea/light";
|
||||
import { Quat, Transform } from "raea/transform";
|
||||
import { Camera3d } from "raea/camera";
|
||||
|
||||
function Edit() {
|
||||
const turn = (useCurrentFrame() / 30) * (Math.PI / 3);
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#14161c" }}>
|
||||
<Camera3d transform={Transform.fromXyz(0, 1.6, 6).lookingAt([0, 0.5, 0])} projection={{ Perspective: { fov: (40 * Math.PI) / 180 } }} />
|
||||
<AmbientLight brightness={160} />
|
||||
<DirectionalLight transform={Transform.fromXyz(3, 5, 4).lookingAt([0, 0, 0])} illuminance={11200} />
|
||||
<Entity transform={Transform.IDENTITY.withRotation(Quat.fromEuler("XYZ", 0, turn, 0))}>
|
||||
<Mesh3d transform={Transform.fromXyz(0, 0.6, 0)}>
|
||||
<Cuboid half_size={[0.6, 0.6, 0.6]} />
|
||||
<StandardMaterial base_color="#e8b04a" perceptual_roughness={0.35} />
|
||||
</Mesh3d>
|
||||
</Entity>
|
||||
<div style={{ position: "absolute", top: 60, width: "100%", textAlign: "center", fontSize: 64, fontWeight: 800, color: "#fff" }}>Made to be seen</div>
|
||||
<div data-raea-role="caption" style={{ position: "absolute", bottom: 60, width: "100%", textAlign: "center", fontSize: 48, color: "#ff0" }}>a caption over 3D</div>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="edit" width={1280} height={720} fps={30} durationInFrames={60} component={Edit} />);
|
||||
@@ -0,0 +1,204 @@
|
||||
//! docs/layers.feature LA3a: the layers put back together are the render. Each fixture (apps/layers/fixtures) is
|
||||
//! exported in layers by a built raea, its passes' frames kept; at each clip's first, middle and last frame the layers
|
||||
//! are composited bottom to top (under, footage as layers.json places it, graphics, captions) and compared with the
|
||||
//! reference render's frame. A test of the method, run by hand on a machine with a GPU:
|
||||
//! cargo test -p raea-app-layers composite -- --ignored --nocapture (RAEA_BIN: the raea, default target/release/raea;
|
||||
//! RAEA_LAYERS_PROJECT=DIR/EDIT.tsx checks that composition, its media/ beside it, in place of the fixtures, and
|
||||
//! RAEA_LAYERS_COMPOSITION=ID one of its compositions by id)
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use crate::model::{Clip, Key, Layer, Layers, key_at};
|
||||
|
||||
/// The least PSNR (dB) a composited frame has against the reference render's: the reference is an H.264 movie and the
|
||||
/// footage is decoded and scaled here as the page does it, so a frame is never exact.
|
||||
const MIN_PSNR: f64 = 30.0;
|
||||
|
||||
/// An RGB picture, 0..1, row by row.
|
||||
struct Picture {
|
||||
w: usize,
|
||||
h: usize,
|
||||
px: Vec<[f32; 3]>,
|
||||
}
|
||||
|
||||
impl Picture {
|
||||
fn black(w: usize, h: usize) -> Picture {
|
||||
Picture { w, h, px: vec![[0.0; 3]; w * h] }
|
||||
}
|
||||
|
||||
/// `rgba` (straight alpha, 8 bits) laid over this at full size, times `opacity`.
|
||||
fn over(&mut self, rgba: &[u8], opacity: f32) {
|
||||
for (k, p) in self.px.iter_mut().enumerate() {
|
||||
let a = rgba[k * 4 + 3] as f32 / 255.0 * opacity;
|
||||
for c in 0..3 {
|
||||
p[c] = p[c] * (1.0 - a) + rgba[k * 4 + c] as f32 / 255.0 * a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A picture of `mw` x `mh` (RGBA) as a footage clip shows it at `key` (layers.json's place for that frame): where
|
||||
/// plan::picture draws it and keeps it, or stretched over its box for object-fit: fill (as raea draws it; an editor
|
||||
/// fits it inside), sampled bilinearly, times its opacity.
|
||||
fn draw(&mut self, rgba: &[u8], mw: usize, mh: usize, key: &Key, fit: &str) {
|
||||
let (canvas, media) = ((self.w as f64, self.h as f64), (mw as f64, mh as f64));
|
||||
// where the whole picture is, and the edges of what of it shows
|
||||
let ([ox, oy, dw, dh], [l, t, r, b]) = if fit == "fill" {
|
||||
let [x, y, w, h] = crate::plan::shown(&key.r#box, &key.clip);
|
||||
(key.r#box, [x, y, x + w, y + h])
|
||||
} else {
|
||||
let (p, _) = crate::plan::picture(&key.r#box, &key.clip, fit, &key.position, media, canvas);
|
||||
let [dx, dy, dw, dh] = p.drawn;
|
||||
(p.drawn, [dx + p.kept[0] * dw, dy + p.kept[1] * dh, dx + p.kept[2] * dw, dy + p.kept[3] * dh])
|
||||
};
|
||||
let (sx, sy, opacity) = (dw / media.0, dh / media.1, key.opacity as f32);
|
||||
let (x0, y0) = (l.max(0.0) as usize, t.max(0.0) as usize);
|
||||
let (x1, y1) = ((r.ceil().max(0.0) as usize).min(self.w), (b.ceil().max(0.0) as usize).min(self.h));
|
||||
let at = |x: usize, y: usize, c: usize| rgba[(y.min(mh - 1) * mw + x.min(mw - 1)) * 4 + c] as f32 / 255.0;
|
||||
for y in y0..y1 {
|
||||
for x in x0..x1 {
|
||||
let (u, v) = ((x as f64 + 0.5 - ox) / sx - 0.5, (y as f64 + 0.5 - oy) / sy - 0.5);
|
||||
if u < -0.5 || v < -0.5 || u > mw as f64 - 0.5 || v > mh as f64 - 0.5 {
|
||||
continue;
|
||||
}
|
||||
let (u, v) = (u.max(0.0), v.max(0.0));
|
||||
let (iu, iv, fu, fv) = (u as usize, v as usize, (u.fract()) as f32, (v.fract()) as f32);
|
||||
let p = &mut self.px[y * self.w + x];
|
||||
for (c, ch) in p.iter_mut().enumerate() {
|
||||
let s = at(iu, iv, c) * (1.0 - fu) * (1.0 - fv) + at(iu + 1, iv, c) * fu * (1.0 - fv) + at(iu, iv + 1, c) * (1.0 - fu) * fv + at(iu + 1, iv + 1, c) * fu * fv;
|
||||
*ch = *ch * (1.0 - opacity) + s * opacity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Peak signal-to-noise ratio against `rgba`, in dB (infinite when they're the same).
|
||||
fn psnr(&self, rgba: &[u8]) -> f64 {
|
||||
let mut se = 0.0f64;
|
||||
for (k, p) in self.px.iter().enumerate() {
|
||||
for c in 0..3 {
|
||||
let d = p[c] as f64 - rgba[k * 4 + c] as f64 / 255.0;
|
||||
se += d * d;
|
||||
}
|
||||
}
|
||||
let mse = se / (self.px.len() * 3) as f64;
|
||||
if mse == 0.0 { f64::INFINITY } else { 10.0 * (1.0 / mse).log10() }
|
||||
}
|
||||
}
|
||||
|
||||
/// A movie's frame at `secs`, as RGBA, with its size.
|
||||
fn frame(path: &Path, secs: f64) -> Result<(Vec<u8>, usize, usize), String> {
|
||||
let mut d = raea_io_media::preferred().into_iter().find_map(|b| b.open_video(path).ok()).ok_or_else(|| format!("{}: no backend opens it", path.display()))?;
|
||||
let f = d.frame_at(secs).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
Ok((f.rgba.to_vec(), f.width as usize, f.height as usize))
|
||||
}
|
||||
|
||||
/// Frame `f` of the export in `dir` composited from its layers, bottom to top.
|
||||
fn composite(dir: &Path, l: &Layers, f: i64) -> Result<Picture, String> {
|
||||
let mut pic = Picture::black(l.width as usize, l.height as usize);
|
||||
let on = |c: &&Clip| c.start <= f && f < c.end();
|
||||
for t in l.tracks.iter().rev() {
|
||||
for c in t.clips.iter().filter(on) {
|
||||
match t.layer {
|
||||
Layer::Sound => {}
|
||||
Layer::Footage => {
|
||||
let file = &l.files[c.file];
|
||||
// the source frame at or before the time, as raea shows it (a take faster than the edit has one
|
||||
// between two of its frames): only a hair past the time, for the manifest's whole milliseconds
|
||||
let secs = c.source_in + (f - c.start) as f64 / l.fps * c.speed + 1e-4;
|
||||
let (rgba, w, h) = frame(Path::new(&file.path), secs)?;
|
||||
let first = Key { frame: 0, r#box: c.r#box.unwrap_or([0.0, 0.0, l.width as f64, l.height as f64]), clip: c.clip, position: c.position, opacity: c.opacity };
|
||||
let key = key_at(&c.keys, f - c.start).unwrap_or(first);
|
||||
pic.draw(&rgba, w, h, &key, c.fit.as_deref().unwrap_or("fill"));
|
||||
}
|
||||
_ => {
|
||||
// a layer's movie is NAME.CODEC.mov, its frames NAME.frames
|
||||
let name = l.files[c.file].path.split('.').next().unwrap_or_default().to_string();
|
||||
let png = dir.join(format!("{name}.frames/frame-{f:05}.png"));
|
||||
let (rgba, _, _) = raea_io_alpha::read_png(&png)?;
|
||||
pic.over(&rgba, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(pic)
|
||||
}
|
||||
|
||||
/// Each fixture exported by `bin` into its own folder under `work`: its layers.json and the folder.
|
||||
fn export(bin: &Path, fixture: &Path, work: &Path) -> Result<(Layers, PathBuf), String> {
|
||||
let name = fixture.file_stem().unwrap().to_string_lossy().into_owned();
|
||||
let src = work.join(&name);
|
||||
let _ = std::fs::remove_dir_all(&src);
|
||||
std::fs::create_dir_all(src.join("media")).map_err(|e| e.to_string())?;
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
|
||||
// a project of its own is exported where it is; a fixture is copied with the test clip beside it
|
||||
let (src, edit) = if fixture.parent() == Some(&Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures")) {
|
||||
std::fs::copy(fixture, src.join("edit.tsx")).map_err(|e| e.to_string())?;
|
||||
std::fs::copy(root.join("engine/rune/media/tests/fixtures/clip.mp4"), src.join("media/clip.mp4")).map_err(|e| e.to_string())?;
|
||||
(src, "edit.tsx".to_string())
|
||||
} else {
|
||||
(fixture.parent().unwrap().to_path_buf(), fixture.file_name().unwrap().to_string_lossy().into_owned())
|
||||
};
|
||||
let out = work.join(&name).join("layers");
|
||||
let comp: Vec<String> = std::env::var("RAEA_LAYERS_COMPOSITION").map(|c| vec!["--composition".to_string(), c]).unwrap_or_default();
|
||||
let run = Command::new(bin)
|
||||
.args(["export", "layers", edit.as_str()])
|
||||
.args(&comp)
|
||||
.arg("-o")
|
||||
.arg(&out)
|
||||
.current_dir(&src)
|
||||
.env("RAEA_LAYERS_KEEP_FRAMES", "1")
|
||||
.env("RAEA_EXPORT_CACHE", "0")
|
||||
.output()
|
||||
.map_err(|e| format!("{}: {e}", bin.display()))?;
|
||||
if !run.status.success() {
|
||||
return Err(format!("{name}: {}{}", String::from_utf8_lossy(&run.stdout), String::from_utf8_lossy(&run.stderr)));
|
||||
}
|
||||
println!("{name}: {}", String::from_utf8_lossy(&run.stdout).trim());
|
||||
let l: Layers = serde_json::from_str(&std::fs::read_to_string(out.join("layers.json")).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?;
|
||||
Ok((l, out))
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn composite_the_layers_back_and_they_are_the_render() {
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
|
||||
let bin = std::env::var_os("RAEA_BIN").map_or_else(|| root.join("target/release/raea"), PathBuf::from);
|
||||
let work = std::env::temp_dir().join(format!("raea-layers-la3a-{}", std::process::id()));
|
||||
let mut fixtures: Vec<PathBuf> = match std::env::var_os("RAEA_LAYERS_PROJECT") {
|
||||
Some(p) => vec![PathBuf::from(p)],
|
||||
None => std::fs::read_dir(Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures")).unwrap().flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x == "tsx")).collect(),
|
||||
};
|
||||
fixtures.sort();
|
||||
let mut failed = Vec::new();
|
||||
for fx in &fixtures {
|
||||
let name = fx.file_stem().unwrap().to_string_lossy().into_owned();
|
||||
let (l, dir) = match export(&bin, fx, &work) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
failed.push(e);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
// each clip's first, middle and last frame
|
||||
let mut at: Vec<i64> = l.tracks.iter().filter(|t| t.layer != Layer::Sound).flat_map(|t| t.clips.iter()).flat_map(|c| [c.start, c.start + c.frames / 2, c.end() - 1]).filter(|f| (0..l.frames).contains(f)).collect();
|
||||
at.sort();
|
||||
at.dedup();
|
||||
for f in at {
|
||||
let got = composite(&dir, &l, f).and_then(|pic| frame(&dir.join(&l.reference), (f as f64 + 0.25) / l.fps).map(|r| (pic, r)));
|
||||
match got {
|
||||
Ok((pic, (reference, w, h))) if (w, h) == (pic.w, pic.h) => {
|
||||
let db = pic.psnr(&reference);
|
||||
println!(" {name} frame {f}: {db:.1} dB");
|
||||
if db < MIN_PSNR {
|
||||
failed.push(format!("{name} frame {f}: the layers composited are {db:.1} dB from the reference (at least {MIN_PSNR})"));
|
||||
}
|
||||
}
|
||||
Ok((pic, (_, w, h))) => failed.push(format!("{name} frame {f}: the reference is {w}x{h}, the layers {}x{}", pic.w, pic.h)),
|
||||
Err(e) => failed.push(format!("{name} frame {f}: {e}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(&work);
|
||||
assert!(failed.is_empty(), "{}", failed.join("\n"));
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
//! `raea export layers EDIT.tsx` (docs/layers.feature LA4a): a composition as its layers and layers.json, the timeline
|
||||
//! that places them, which every editor's export is written from. Its renders, each by this same program:
|
||||
//! 1. as it is, with its manifest: the reference render, and what shows when (each file's runs, each sound clip, the
|
||||
//! words a caption says);
|
||||
//! 2. RAEA_LAYER=graphics: what the page draws over the footage, less the captions, transparent;
|
||||
//! 3. RAEA_LAYER=under, when there is footage or 3D: what's drawn under the page's footage and graphics (the
|
||||
//! backgrounds holding footage, and the 3D), opaque, kept unless it's black;
|
||||
//! 4. RAEA_LAYER=captions, when a frame shows a caption: the captions alone, and the words as SubRip;
|
||||
//! 5. RAEA_LAYER=behind:FILE, for each file shown as a picture in picture: what's drawn behind it (its card), kept
|
||||
//! only where it's a picture in picture, on a track between it and the footage under it.
|
||||
//!
|
||||
//! The footage and sounds are clips of their own files where they are; each layer is clips of its movie, cut where it
|
||||
//! draws something. A render that isn't an export draws once, as it always has (LA2o).
|
||||
|
||||
pub mod model;
|
||||
pub mod plan;
|
||||
pub mod srt;
|
||||
pub mod xml;
|
||||
#[cfg(test)]
|
||||
mod composite;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use model::{Clip, File, FileKind, Layer, Layers, Track};
|
||||
use raea_runtime_bundle::flag;
|
||||
use serde_json::Value;
|
||||
|
||||
pub type R<T> = Result<T, String>;
|
||||
|
||||
pub const USAGE: &str = "raea export layers EDIT.tsx [--composition ID] [-o DIR] [--name NAME] [--alpha-codec prores|hevc|rle|png] (the composition as its layers and the timeline that places them, layers.json: the captions and the graphics as transparent movies, what's under the footage (and any 3D) as an opaque one, the footage and sounds as clips of their own files where they are, the captions also as SubRip, and the reference render; into out/layers/NAME, or DIR)";
|
||||
|
||||
pub const USAGE_XML: &str = "raea export xml EDIT.tsx [--composition ID] [-o DIR] [--name NAME] [--alpha-codec prores|hevc|rle|png] (the composition as an FCP7 XML project for Premiere Pro (File, Import) and DaVinci Resolve (File, Import, Timeline): its layers as raea export layers writes them, NAME.premiere.xml and NAME.resolve.xml beside them placing them on a timeline, each as that editor writes it, the footage and sounds as clips of their own files where they are, each clip's own sound linked to it; into out/xml/NAME, or DIR)";
|
||||
|
||||
/// `export layers ...` and `export xml ...`; None for anything else.
|
||||
pub fn cli(args: &[String]) -> Option<R<String>> {
|
||||
if args.first().map(String::as_str) != Some("export") {
|
||||
return None;
|
||||
}
|
||||
match args.get(1).map(String::as_str) {
|
||||
Some("layers") => Some(export(&args[2..]).map(|(_, said)| said)),
|
||||
Some("xml") => Some(export_xml(&args[2..])),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// `raea export xml`: the layers into DIR (out/xml/NAME unless -o says), then NAME.xml beside them (LA5a).
|
||||
fn export_xml(args: &[String]) -> R<String> {
|
||||
let tsx = args.first().filter(|a| !a.starts_with('-')).ok_or(USAGE_XML)?;
|
||||
let edit = dunce::canonicalize(PathBuf::from(tsx)).map_err(|e| format!("{tsx}: {e}"))?;
|
||||
let name = named(args, &edit);
|
||||
let dir = flag(args, "-o").map_or_else(|| edit.parent().unwrap().join("out/xml").join(&name), PathBuf::from);
|
||||
let mut layer_args = args.to_vec();
|
||||
if flag(args, "-o").is_none() {
|
||||
layer_args.extend(["-o".into(), dir.display().to_string()]);
|
||||
}
|
||||
let (layers, _) = export(&layer_args)?;
|
||||
let dir = dunce::canonicalize(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
// an XML an editor, the same but for what they read differently (xml::Editor)
|
||||
let mut notes: Vec<String> = Vec::new();
|
||||
for e in [xml::Editor::Premiere, xml::Editor::Resolve] {
|
||||
let (text, n) = xml::write(&layers, &dir, e);
|
||||
let out = dir.join(format!("{name}.{}.xml", e.name()));
|
||||
std::fs::write(&out, text).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
for n in n {
|
||||
if !notes.contains(&n) {
|
||||
notes.push(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
let _ = std::fs::remove_file(dir.join(format!("{name}.xml")));
|
||||
let count = |l: Layer| layers.tracks.iter().filter(|t| t.layer == l).count();
|
||||
let mut said = format!(
|
||||
"APPLIED FCP7 XML \"{name}\" at {}: {name}.premiere.xml for Premiere Pro (File, Import), {name}.resolve.xml for DaVinci Resolve (File, Import, Timeline); {} video tracks, {} audio tracks; the layers, layers.json{} and the reference render beside them",
|
||||
dir.display(),
|
||||
layers.tracks.len() - count(Layer::Sound),
|
||||
count(Layer::Sound),
|
||||
layers.srt.as_ref().map_or(String::new(), |s| format!(", {s} (captions to upload)")),
|
||||
);
|
||||
for n in layers.notes.iter().chain(¬es) {
|
||||
said.push_str(&format!("\n note {n}"));
|
||||
}
|
||||
Ok(said)
|
||||
}
|
||||
|
||||
/// `raea render ARGS` by this same program with only `env`'s layer settings: none of the person's own RAEA_LAYER or
|
||||
/// RAEA_HIDE_MEDIA reaches a render it didn't ask for. Its failure is the export's.
|
||||
pub fn render(args: &[String], env: &[(&str, &str)]) -> R<()> {
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let mut c = Command::new(exe);
|
||||
c.arg("render").args(args).env_remove("RAEA_LAYER").env_remove("RAEA_HIDE_MEDIA");
|
||||
for (k, v) in env {
|
||||
c.env(k, v);
|
||||
}
|
||||
let out = c.output().map_err(|e| e.to_string())?;
|
||||
if !out.status.success() {
|
||||
let said = format!("{}{}", String::from_utf8_lossy(&out.stdout), String::from_utf8_lossy(&out.stderr));
|
||||
return Err(format!("the render failed:\n{}", said.trim()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// What every layer's pass renders from: the edit, its composition flags, the export's folder, the movies' codec and
|
||||
/// the rate.
|
||||
struct Passes<'a> {
|
||||
tsx: &'a Path,
|
||||
comp: &'a [String],
|
||||
dir: &'a Path,
|
||||
codec: raea_io_alpha::Codec,
|
||||
fps: f64,
|
||||
}
|
||||
|
||||
impl Passes<'_> {
|
||||
/// A layer's movie, rendered with RAEA_LAYER=`layer` into DIR/NAME.CODEC.mov (`name` the layer's own, or one of
|
||||
/// many's), its frames in DIR/NAME.frames, removed unless `keep` (LA3a's test reads them); none when `also` says
|
||||
/// its frames aren't worth a movie.
|
||||
fn pass(&self, name: &str, layer: &str, keep: bool, also: impl FnOnce(&Path) -> bool) -> R<Option<(PathBuf, raea_io_alpha::Made)>> {
|
||||
// the layer under the page is the bottom one, so it's drawn opaque: over 3D the page's background is the 3D's
|
||||
// clear, which --alpha would clear to nothing
|
||||
let alpha: &[String] = if layer == "under" { &[] } else { &["--alpha".to_string()] };
|
||||
let frames = self.dir.join(format!("{name}.frames"));
|
||||
let _ = std::fs::remove_dir_all(&frames);
|
||||
let out = self.dir.join(format!("{name}.{}.mov", codec_ext(self.codec)));
|
||||
let done = render(&[[self.tsx.display().to_string(), "-o".into(), format!("{}/", frames.display())].as_slice(), alpha, self.comp].concat(), &[("RAEA_LAYER", layer)])
|
||||
.and_then(|_| if also(&frames) { raea_io_alpha::encode_dir(&frames, &out, self.codec, self.fps, 0.9).map(|m| Some((out, m))) } else { Ok(None) });
|
||||
// the frames' render leaves its manifest beside them: the reference's is the export's
|
||||
let _ = std::fs::remove_file(self.dir.join(format!("{name}.render.json")));
|
||||
if !keep {
|
||||
let _ = std::fs::remove_dir_all(&frames);
|
||||
}
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
/// The export's name: --name's, else the edit's file stem.
|
||||
fn named(args: &[String], edit: &Path) -> String {
|
||||
flag(args, "--name").unwrap_or_else(|| edit.file_stem().map_or_else(|| "edit".to_string(), |s| s.to_string_lossy().into_owned()))
|
||||
}
|
||||
|
||||
/// The export: the layers and layers.json in DIR, and what it says.
|
||||
pub fn export(args: &[String]) -> R<(Layers, String)> {
|
||||
let tsx = args.first().filter(|a| !a.starts_with('-')).ok_or(USAGE)?;
|
||||
let tsx = dunce::canonicalize(PathBuf::from(tsx)).map_err(|e| format!("{tsx}: {e}"))?;
|
||||
let edit_dir = tsx.parent().unwrap().to_path_buf();
|
||||
let codec = raea_io_alpha::Codec::chosen(flag(args, "--alpha-codec").as_deref())?;
|
||||
let name = named(args, &tsx);
|
||||
let dir = flag(args, "-o").map_or_else(|| edit_dir.join("out/layers").join(&name), PathBuf::from);
|
||||
std::fs::create_dir_all(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
let dir = dunce::canonicalize(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
let comp: Vec<String> = flag(args, "--composition").map(|c| vec!["--composition".into(), c]).unwrap_or_default();
|
||||
// LA3a's test keeps each pass's frames to composite them back
|
||||
let keep = std::env::var_os("RAEA_LAYERS_KEEP_FRAMES").is_some();
|
||||
|
||||
// 1. as it is: the reference render and its manifest
|
||||
let (reference, manifest_path) = (dir.join("reference.mp4"), dir.join("render.json"));
|
||||
render(&[[tsx.display().to_string(), "-o".into(), reference.display().to_string(), "--manifest".into(), manifest_path.display().to_string()].as_slice(), &comp].concat(), &[])?;
|
||||
let manifest: Value = serde_json::from_str(&std::fs::read_to_string(&manifest_path).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?;
|
||||
let (w, h, fps) = (manifest["width"].as_u64().unwrap_or(0) as u32, manifest["height"].as_u64().unwrap_or(0) as u32, manifest["fps"].as_f64().unwrap_or(30.0));
|
||||
let length = manifest["frames"].as_array().map_or(0, Vec::len) as i64;
|
||||
let runs = plan::runs(&manifest, fps);
|
||||
let said = srt::said(&manifest);
|
||||
|
||||
// 2-4. the layers' passes
|
||||
// (its frames kept until the footage it covers is found)
|
||||
let passes = Passes { tsx: &tsx, comp: &comp, dir: &dir, codec, fps };
|
||||
let graphics = passes.pass("graphics", "graphics", true, |_| true)?;
|
||||
// footage the graphics cover (opaque over most of its box at its middle frame) goes above them: the composition
|
||||
// draws it under something it draws in front of it
|
||||
let covered: Vec<bool> = runs.iter().map(|r| graphics.is_some() && opaque_over(&dir.join("graphics.frames"), r)).collect();
|
||||
if !keep {
|
||||
let _ = std::fs::remove_dir_all(dir.join("graphics.frames"));
|
||||
}
|
||||
// what's under the page: the backgrounds holding footage, and the 3D, which the whole page is drawn over
|
||||
let under = if runs.is_empty() && manifest["has3d"] != true { None } else { passes.pass("under", "under", keep, lit)? };
|
||||
let captions = if said.iter().any(|s| !s.is_empty()) { passes.pass("captions", "captions", keep, |_| true)? } else { None };
|
||||
// what's behind each file shown as a picture in picture (its card), between it and the footage under it (LA2c):
|
||||
// a pass for each such file, kept only where it's a picture in picture
|
||||
let full = |r: &plan::Run| plan::full(&plan::shown(&r.bx, &r.clip), w as f64, h as f64);
|
||||
let mut pips: Vec<String> = runs.iter().zip(&covered).filter(|(r, c)| !**c && !full(r)).map(|(r, _)| r.src.clone()).collect();
|
||||
pips.dedup();
|
||||
pips.sort();
|
||||
pips.dedup();
|
||||
let mut behind = Vec::new();
|
||||
for (k, src) in pips.iter().enumerate() {
|
||||
let made = passes.pass(&format!("behind-{}", k + 1), &format!("behind:{src}"), keep, |_| true)?;
|
||||
let shown: Vec<(i64, i64)> = runs.iter().zip(&covered).filter(|(r, c)| !**c && !full(r) && r.src == *src).map(|(r, _)| (r.start, r.end)).collect();
|
||||
behind.push((made, shown));
|
||||
}
|
||||
let srt_lines = srt::lines(&said);
|
||||
let srt_name = (!srt_lines.is_empty()).then(|| format!("{name}.srt"));
|
||||
if let Some(n) = &srt_name {
|
||||
std::fs::write(dir.join(n), srt::write(&srt_lines, fps)).map_err(|e| e.to_string())?;
|
||||
}
|
||||
|
||||
// the timeline, top to bottom
|
||||
let mut files: Vec<File> = Vec::new();
|
||||
let mut index: HashMap<PathBuf, usize> = HashMap::new();
|
||||
let mut notes: Vec<String> = Vec::new();
|
||||
let mut sounds = plan::sounds(&manifest);
|
||||
let mut ids = Ids::default();
|
||||
let (mut main, mut rest, mut over, mut linked) = (Vec::new(), Vec::new(), Vec::new(), Vec::new());
|
||||
for (r, cov) in runs.iter().zip(&covered) {
|
||||
let path = plan::resolve(&edit_dir, &r.src);
|
||||
let f = add(&mut files, &mut index, &path, video)?;
|
||||
let what = format!("{} (frames {}-{})", r.src, r.start, r.end - 1);
|
||||
if r.fit == "fill" && files[f].width > 0 && ((r.bx[2] / r.bx[3].max(1.0)) - (files[f].width as f64 / files[f].height.max(1) as f64)).abs() > 0.01 * (files[f].width as f64 / files[f].height.max(1) as f64) {
|
||||
notes.push(format!("{what}: stretched to its {:.0}x{:.0} box (object-fit: fill); an editor may fit it inside instead", r.bx[2], r.bx[3]));
|
||||
}
|
||||
if *cov {
|
||||
notes.push(format!("{what}: raea draws over all of it from outside what holds it (a layer before it in the page); placed above the graphics, so their drawing over it is hidden in an editor"));
|
||||
}
|
||||
let keys = r.keys.iter().map(|k| model::Key { frame: k.frame - r.start, ..k.clone() }).collect();
|
||||
let mut clip = Clip { r#box: Some(r.bx), fit: Some(r.fit.clone()), clip: r.clip, position: r.position, opacity: r.opacity, keys, speed: r.rate.unwrap_or(1.0).max(0.01), ..Clip::new(ids.next("v"), f, r.start, r.end - r.start, r.at) };
|
||||
// its own sound: the manifest's sound clip of the same file over the same frames from the same time
|
||||
if let Some(k) = sounds.iter().position(|c| plan::resolve(&edit_dir, &c.src) == path && (c.from - r.start).abs() <= 1 && (c.to - r.end).abs() <= 1 && (c.at - r.at).abs() <= 1.5 / fps) {
|
||||
let s = sounds.remove(k);
|
||||
let a = Clip { gain_db: s.gain_db, fade_in: s.fade_in, fade_out: s.fade_out, speed: s.rate, link: Some(clip.id.clone()), ..Clip::new(ids.next("a"), f, s.from, s.to - s.from, s.at) };
|
||||
clip.link = Some(a.id.clone());
|
||||
linked.push(a);
|
||||
}
|
||||
match (*cov, plan::full(&plan::shown(&r.bx, &r.clip), w as f64, h as f64)) {
|
||||
(true, _) => over.push(clip),
|
||||
(false, true) => main.push(clip),
|
||||
(false, false) => rest.push(clip),
|
||||
}
|
||||
}
|
||||
let mut tracks: Vec<Track> = Vec::new();
|
||||
let movie = |files: &mut Vec<File>, made: &Option<(PathBuf, raea_io_alpha::Made)>, layer: Layer, name: &str, ids: &mut Ids, within: Option<&[(i64, i64)]>| -> Vec<Track> {
|
||||
let Some((path, m)) = made else { return Vec::new() };
|
||||
// where it draws something, and (behind a picture in picture) only within the frames given
|
||||
let spans: Vec<(i64, i64)> = match within {
|
||||
None => plan::spans(&m.drawn),
|
||||
Some(w) => plan::spans(&m.drawn).into_iter().flat_map(|(a, b)| w.iter().map(move |&(c, d)| (a.max(c), b.min(d)))).filter(|(a, b)| a < b).collect(),
|
||||
};
|
||||
if spans.is_empty() {
|
||||
let _ = std::fs::remove_file(path);
|
||||
return Vec::new();
|
||||
}
|
||||
files.push(File { path: path.file_name().unwrap().to_string_lossy().into_owned(), kind: FileKind::Video, seconds: m.frames as f64 / fps, width: m.width, height: m.height, has_audio: false, channels: 2, sample_rate: 48_000, rotation: 0 });
|
||||
let k = files.len() - 1;
|
||||
let clips = spans.iter().map(|&(a, b)| Clip::new(ids.next(&name[..1]), k, a, b - a, a as f64 / fps)).collect();
|
||||
model::lay(layer, name, clips)
|
||||
};
|
||||
tracks.extend(movie(&mut files, &captions, Layer::Captions, "captions", &mut ids, None));
|
||||
tracks.extend(model::lay(Layer::Footage, "footage over", over));
|
||||
tracks.extend(movie(&mut files, &graphics, Layer::Graphics, "graphics", &mut ids, None));
|
||||
tracks.extend(model::lay(Layer::Footage, "picture in picture", rest));
|
||||
// every file's backing on as few tracks as hold them, under the pictures in picture
|
||||
let mut backing: Vec<Clip> = Vec::new();
|
||||
for (made, shown) in &behind {
|
||||
backing.extend(movie(&mut files, made, Layer::Backing, "behind picture in picture", &mut ids, Some(shown)).into_iter().flat_map(|t| t.clips));
|
||||
}
|
||||
backing.sort_by_key(|c| c.start);
|
||||
tracks.extend(model::lay(Layer::Backing, "behind picture in picture", backing));
|
||||
tracks.extend(model::lay(Layer::Footage, "footage", main));
|
||||
tracks.extend(movie(&mut files, &under, Layer::Under, "under", &mut ids, None));
|
||||
// a phone's take is stored turned and Resolve crops it mirrored (xml::Editor); ffprobe says how a file is turned
|
||||
if !runs.is_empty() && Command::new("ffprobe").arg("-version").output().is_err() {
|
||||
notes.push("ffprobe isn't installed, so how each take is turned wasn't read: all are taken as upright, and Resolve may crop a phone's take on the wrong side".to_string());
|
||||
}
|
||||
let mut audio = linked;
|
||||
for c in sounds {
|
||||
let f = add(&mut files, &mut index, &plan::resolve(&edit_dir, &c.src), sound)?;
|
||||
let frames = plan::heard_frames(&c, files[f].seconds, fps);
|
||||
if frames <= 0 {
|
||||
continue;
|
||||
}
|
||||
audio.push(Clip { gain_db: c.gain_db, fade_in: c.fade_in, fade_out: c.fade_out, speed: c.rate, ..Clip::new(ids.next("a"), f, c.from, frames, c.at) });
|
||||
}
|
||||
audio.sort_by_key(|c| c.start);
|
||||
// the first sound track is the top one, so later ones are listed after it (lay lists the last laid first)
|
||||
let mut sound_tracks = model::lay(Layer::Sound, "sound", audio);
|
||||
sound_tracks.reverse();
|
||||
tracks.extend(sound_tracks);
|
||||
let notes_made = manifest["sounds"]["notes"].as_array().map_or(0, Vec::len);
|
||||
if notes_made > 0 {
|
||||
notes.push(format!("the Tone graph's music ({notes_made} notes) has no file to place: it is in the reference render's sound"));
|
||||
}
|
||||
|
||||
let layers = Layers { version: model::VERSION, name: name.clone(), width: w, height: h, fps, frames: length, reference: "reference.mp4".into(), srt: srt_name.clone(), files, tracks, notes };
|
||||
let json = serde_json::to_string_pretty(&layers).map_err(|e| e.to_string())?;
|
||||
std::fs::write(dir.join("layers.json"), json + "\n").map_err(|e| e.to_string())?;
|
||||
|
||||
let count = |l: Layer| layers.tracks.iter().filter(|t| t.layer == l).map(|t| t.clips.len()).sum::<usize>();
|
||||
let mut said = format!(
|
||||
"APPLIED layers \"{name}\" at {}: {} tracks; {}, {}, {}{}, {}, {}{}; {:.2} s at {fps} fps, {w}x{h}",
|
||||
dir.display(),
|
||||
layers.tracks.len(),
|
||||
many(count(Layer::Captions), "captions clip"),
|
||||
many(count(Layer::Graphics), "graphics clip"),
|
||||
many(count(Layer::Footage), "footage clip"),
|
||||
Some(count(Layer::Backing)).filter(|&k| k > 0).map_or(String::new(), |k| format!(", {} behind a picture in picture", many(k, "clip"))),
|
||||
if count(Layer::Under) == 1 { "1 clip under the footage".to_string() } else { format!("{} clips under the footage", count(Layer::Under)) },
|
||||
many(count(Layer::Sound), "sound"),
|
||||
srt_name.as_ref().map_or(String::new(), |n| format!("; {} in {n}", many(srt_lines.len(), "caption line"))),
|
||||
length as f64 / fps,
|
||||
);
|
||||
for n in &layers.notes {
|
||||
said.push_str(&format!("\n note {n}"));
|
||||
}
|
||||
Ok((layers, said))
|
||||
}
|
||||
|
||||
/// Clip ids by kind: v1, v2... for footage, a1... for sounds, c1, g1, u1... for the captions', graphics' and under's.
|
||||
#[derive(Default)]
|
||||
struct Ids(HashMap<String, usize>);
|
||||
|
||||
impl Ids {
|
||||
fn next(&mut self, kind: &str) -> String {
|
||||
let n = self.0.entry(kind.to_string()).or_default();
|
||||
*n += 1;
|
||||
format!("{kind}{n}")
|
||||
}
|
||||
}
|
||||
|
||||
/// "1 clip", "4 clips"
|
||||
/// "1 clip", "3 clips".
|
||||
pub fn many(k: usize, what: &str) -> String {
|
||||
if k == 1 { format!("1 {what}") } else { format!("{k} {what}s") }
|
||||
}
|
||||
|
||||
/// A file's place in `files`, probed the first time it's named.
|
||||
fn add(files: &mut Vec<File>, index: &mut HashMap<PathBuf, usize>, p: &Path, probe: fn(&Path) -> R<File>) -> R<usize> {
|
||||
if let Some(i) = index.get(p) {
|
||||
return Ok(*i);
|
||||
}
|
||||
files.push(probe(p)?);
|
||||
index.insert(p.to_path_buf(), files.len() - 1);
|
||||
Ok(files.len() - 1)
|
||||
}
|
||||
|
||||
/// A video file: its upright size and length from the first of raea's media backends that opens it, and whether a short
|
||||
/// window of its sound decodes to samples.
|
||||
pub fn video(path: &Path) -> R<File> {
|
||||
let mut why = Vec::new();
|
||||
for b in raea_io_media::preferred() {
|
||||
match b.open_video(path) {
|
||||
Ok(d) => {
|
||||
let i = d.info();
|
||||
let (has_audio, channels, sample_rate) = heard(path);
|
||||
// one whose rotation can't be read is taken as upright (export notes it: only Resolve's crop turns on it)
|
||||
let rotation = rotation(path).unwrap_or(0);
|
||||
return Ok(File { path: path.display().to_string(), kind: FileKind::Video, seconds: i.duration, width: i.width, height: i.height, has_audio, channels, sample_rate, rotation });
|
||||
}
|
||||
Err(e) => why.push(format!("{}: {e}", b.name())),
|
||||
}
|
||||
}
|
||||
Err(format!("{} didn't open as video ({})", path.display(), why.join("; ")))
|
||||
}
|
||||
|
||||
/// A sound file: its length from its container.
|
||||
pub fn sound(path: &Path) -> R<File> {
|
||||
let seconds = raea_io_media::probe_seconds(path).ok_or_else(|| format!("{}: no sound length", path.display()))?;
|
||||
let (_, channels, sample_rate) = heard(path);
|
||||
Ok(File { path: path.display().to_string(), kind: FileKind::Audio, seconds, width: 0, height: 0, has_audio: true, channels, sample_rate, rotation: 0 })
|
||||
}
|
||||
|
||||
/// Whether a short window of a file's sound decodes to samples, and its channels and sample rate (stereo at 48 kHz
|
||||
/// when it has none to read).
|
||||
/// How far a video's pictures are turned to stand upright, from its container's display matrix (ffprobe's rotation,
|
||||
/// counter-clockwise), as 0, 90, 180 or 270 (to the nearest quarter turn); None when ffprobe can't say (it isn't there).
|
||||
fn rotation(path: &Path) -> Option<u32> {
|
||||
let out = Command::new("ffprobe").args(["-v", "error", "-select_streams", "v:0", "-show_entries", "stream_side_data=rotation", "-of", "csv=p=0"]).arg(path).output().ok().filter(|o| o.status.success())?;
|
||||
let deg = String::from_utf8_lossy(&out.stdout).lines().find_map(|l| l.trim().parse::<f64>().ok()).unwrap_or(0.0);
|
||||
Some(((deg / 90.0).round() as i64).rem_euclid(4) as u32 * 90)
|
||||
}
|
||||
|
||||
fn heard(path: &Path) -> (bool, u32, u32) {
|
||||
match raea_io_media::decode_audio_window(path, 0.0, 0.05) {
|
||||
Ok(a) if a.len() > 0 => (true, (a.channels.len() as u32).max(1), a.rate),
|
||||
_ => (false, 2, 48_000),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn codec_ext(c: raea_io_alpha::Codec) -> &'static str {
|
||||
match c {
|
||||
raea_io_alpha::Codec::ProRes => "prores",
|
||||
raea_io_alpha::Codec::Hevc => "hevc",
|
||||
raea_io_alpha::Codec::Rle => "rle",
|
||||
raea_io_alpha::Codec::Png => "png",
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the graphics are opaque over 90% of what shows of a run at its middle frame (a grid of points inside it).
|
||||
fn opaque_over(frames: &Path, r: &plan::Run) -> bool {
|
||||
let mid = (r.start + r.end - 1) / 2;
|
||||
let Ok((px, w, h)) = raea_io_alpha::read_png(&frames.join(format!("frame-{mid:05}.png"))) else { return false };
|
||||
let k = r.at(mid);
|
||||
let [bx, by, bw, bh] = plan::shown(&k.r#box, &k.clip);
|
||||
let (mut n, mut opaque) = (0, 0);
|
||||
for j in 0..16 {
|
||||
for i in 0..16 {
|
||||
let x = (bx + bw * (i as f64 + 0.5) / 16.0) as i64;
|
||||
let y = (by + bh * (j as f64 + 0.5) / 16.0) as i64;
|
||||
if x < 0 || y < 0 || x >= w as i64 || y >= h as i64 {
|
||||
continue;
|
||||
}
|
||||
n += 1;
|
||||
opaque += usize::from(px[((y as usize) * w as usize + x as usize) * 4 + 3] >= 250);
|
||||
}
|
||||
}
|
||||
n > 0 && opaque * 10 >= n * 9
|
||||
}
|
||||
|
||||
/// Whether any frame in `frames` draws anything but black, at any alpha (a grid of points on each).
|
||||
pub fn lit(frames: &Path) -> bool {
|
||||
raea_io_alpha::frames_in(frames).iter().any(|p| {
|
||||
let Ok((px, w, h)) = raea_io_alpha::read_png(p) else { return true };
|
||||
(0..32).any(|j| {
|
||||
(0..32).any(|i| {
|
||||
let (x, y) = ((w as usize * (2 * i + 1)) / 64, (h as usize * (2 * j + 1)) / 64);
|
||||
let k = (y * w as usize + x) * 4;
|
||||
px[k + 3] >= 8 && px[k..k + 3].iter().any(|&c| c >= 8)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
//! layers.json (docs/layers.feature LA4a): a composition's layers and the timeline that places them, in no editor's
|
||||
//! terms. Each editor's export (CapCut's draft, the FCP7 XML) is written from it. Tracks are listed top to bottom;
|
||||
//! frames are the composition's, whole; a clip's source time is in seconds.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The layers.json format's version, which a reader checks before it reads the rest.
|
||||
pub const VERSION: u32 = 1;
|
||||
|
||||
/// A composition's layers and their timeline.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Layers {
|
||||
pub version: u32,
|
||||
/// the export's name (the composition's file stem, unless --name says)
|
||||
pub name: String,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub fps: f64,
|
||||
/// the composition's length in frames
|
||||
pub frames: i64,
|
||||
/// the reference render, beside layers.json: the composition as raea draws it, on no track
|
||||
pub reference: String,
|
||||
/// the captions as SubRip, beside layers.json, when there are captions (LA2b); on no track
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub srt: Option<String>,
|
||||
/// every file a clip shows or plays: the footage and sounds where they are, the layers' movies beside layers.json
|
||||
pub files: Vec<File>,
|
||||
/// top to bottom
|
||||
pub tracks: Vec<Track>,
|
||||
/// what doesn't carry into an editor, said once each (CC2e)
|
||||
pub notes: Vec<String>,
|
||||
}
|
||||
|
||||
/// A file a clip shows or plays.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct File {
|
||||
/// absolute for the footage and sounds (never copied, LA5a); relative to layers.json for a layer's movie
|
||||
pub path: String,
|
||||
pub kind: FileKind,
|
||||
pub seconds: f64,
|
||||
/// a picture's upright size; 0 for a sound
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
/// whether it has sound of its own (footage)
|
||||
pub has_audio: bool,
|
||||
/// its sound's channels and sample rate, when it has sound (an editor places each channel; Premiere a track each)
|
||||
#[serde(default = "two")]
|
||||
pub channels: u32,
|
||||
#[serde(default = "rate_48k")]
|
||||
pub sample_rate: u32,
|
||||
/// how far its pictures are turned to stand upright, as its container says (a phone's take is stored on its side):
|
||||
/// counter-clockwise degrees, 0, 90, 180 or 270; its width and height are upright already. Resolve crops such a
|
||||
/// file mirrored (xml::Editor)
|
||||
#[serde(default, skip_serializing_if = "is_zero_u")]
|
||||
pub rotation: u32,
|
||||
}
|
||||
|
||||
fn is_zero_u(v: &u32) -> bool {
|
||||
*v == 0
|
||||
}
|
||||
|
||||
fn two() -> u32 {
|
||||
2
|
||||
}
|
||||
|
||||
fn rate_48k() -> u32 {
|
||||
48_000
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum FileKind {
|
||||
Video,
|
||||
Audio,
|
||||
}
|
||||
|
||||
/// Which layer a track holds (the layers table in docs/layers.feature).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Layer {
|
||||
Captions,
|
||||
Graphics,
|
||||
Footage,
|
||||
/// what's drawn behind a picture in picture, between it and the footage under it (its card, LA2c)
|
||||
Backing,
|
||||
Under,
|
||||
Sound,
|
||||
}
|
||||
|
||||
/// A track: clips of one layer that never overlap.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Track {
|
||||
pub layer: Layer,
|
||||
/// what an editor calls it: "captions", "graphics", "picture in picture", "behind picture in picture", "footage",
|
||||
/// "footage 2", "footage over", "under", "sound"
|
||||
pub name: String,
|
||||
pub clips: Vec<Clip>,
|
||||
}
|
||||
|
||||
/// A span of a file on a track.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Clip {
|
||||
/// its own id, unique in the timeline
|
||||
pub id: String,
|
||||
/// its file, an index into `files`
|
||||
pub file: usize,
|
||||
/// its first frame on the timeline, and how many it lasts
|
||||
pub start: i64,
|
||||
pub frames: i64,
|
||||
/// the source time it starts from, in seconds
|
||||
pub source_in: f64,
|
||||
/// how fast the source plays (1 as recorded)
|
||||
pub speed: f64,
|
||||
/// footage: its box on the canvas at its first frame [x, y, width, height] and how the picture fills it (CSS's
|
||||
/// object-fit); a layer's movie fills the canvas and has none
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub r#box: Option<[f64; 4]>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub fit: Option<String>,
|
||||
/// footage: what of its box shows at its first frame, when a box it's in cuts it (an `overflow: hidden` parent):
|
||||
/// [x, y, width, height] on the canvas, inside its box; none when all of the box shows
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub clip: Option<[f64; 4]>,
|
||||
/// footage: where the picture sits in what its box leaves free (CSS's object-position) when not centred, each axis
|
||||
/// as px plus a share of the free space: [x px, x share, y px, y share]
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub position: Option<[f64; 4]>,
|
||||
/// footage: its opacity at its first frame
|
||||
pub opacity: f64,
|
||||
/// footage that moves, scales, is cut, pans in its box or fades over its run: its box, clip, object-position and
|
||||
/// opacity at the frames where that
|
||||
/// changes, a straight line between two keys being what each frame between them shows (the first key is its first
|
||||
/// frame, the last its last); none when it holds as its first frame shows it
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub keys: Vec<Key>,
|
||||
/// a sound: its gain in decibels and its fades in seconds
|
||||
#[serde(default, skip_serializing_if = "is_zero")]
|
||||
pub gain_db: f64,
|
||||
#[serde(default, skip_serializing_if = "is_zero")]
|
||||
pub fade_in: f64,
|
||||
#[serde(default, skip_serializing_if = "is_zero")]
|
||||
pub fade_out: f64,
|
||||
/// footage and its own sound: the other's id, so an editor moves them together until it's told not to. Footage
|
||||
/// whose file has sound and no link plays silent: the composition doesn't play its sound there
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub link: Option<String>,
|
||||
}
|
||||
|
||||
/// Footage's box, clip, object-position and opacity at one frame of its clip.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Key {
|
||||
/// from the clip's first frame
|
||||
pub frame: i64,
|
||||
pub r#box: [f64; 4],
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub clip: Option<[f64; 4]>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub position: Option<[f64; 4]>,
|
||||
pub opacity: f64,
|
||||
}
|
||||
|
||||
/// The key at `frame` (keys' frames counted alike): the straight line between the keys either side of it, the first's
|
||||
/// before them and the last's after; none when there are no keys. A clip or object-position one key has and the other
|
||||
/// hasn't goes from the whole box, or the centre, to it.
|
||||
pub fn key_at(keys: &[Key], frame: i64) -> Option<Key> {
|
||||
let i = keys.iter().position(|k| k.frame >= frame).unwrap_or(keys.len().checked_sub(1)?);
|
||||
let b = &keys[i];
|
||||
if i == 0 || b.frame <= frame {
|
||||
return Some(Key { frame, ..b.clone() });
|
||||
}
|
||||
let a = &keys[i - 1];
|
||||
let t = (frame - a.frame) as f64 / (b.frame - a.frame) as f64;
|
||||
let clip = (a.clip.is_some() || b.clip.is_some()).then(|| toward(crate::plan::shown(&a.r#box, &a.clip), &crate::plan::shown(&b.r#box, &b.clip), t));
|
||||
let position = (a.position.is_some() || b.position.is_some()).then(|| toward(crate::plan::placed(&a.position), &crate::plan::placed(&b.position), t));
|
||||
Some(Key { frame, r#box: toward(a.r#box, &b.r#box, t), clip, position, opacity: a.opacity + (b.opacity - a.opacity) * t })
|
||||
}
|
||||
|
||||
/// `from` moved `t` of the way to `to`, each of its four alike.
|
||||
fn toward(mut from: [f64; 4], to: &[f64; 4], t: f64) -> [f64; 4] {
|
||||
for (v, end) in from.iter_mut().zip(to) {
|
||||
*v += (end - *v) * t;
|
||||
}
|
||||
from
|
||||
}
|
||||
|
||||
fn is_zero(v: &f64) -> bool {
|
||||
*v == 0.0
|
||||
}
|
||||
|
||||
impl Clip {
|
||||
/// A clip of `file` from `start` for `frames`, from its source's `source_in` at speed 1, fully opaque.
|
||||
pub fn new(id: String, file: usize, start: i64, frames: i64, source_in: f64) -> Clip {
|
||||
Clip { id, file, start, frames, source_in, speed: 1.0, r#box: None, fit: None, clip: None, position: None, opacity: 1.0, keys: Vec::new(), gain_db: 0.0, fade_in: 0.0, fade_out: 0.0, link: None }
|
||||
}
|
||||
|
||||
pub fn end(&self) -> i64 {
|
||||
self.start + self.frames
|
||||
}
|
||||
}
|
||||
|
||||
/// Clips laid on as few tracks as hold them without overlap, first come first: `layer` tracks named `name`,
|
||||
/// `name 2`... (the second and later are above the first, so they're listed before it: tracks go top to bottom).
|
||||
pub fn lay(layer: Layer, name: &str, clips: Vec<Clip>) -> Vec<Track> {
|
||||
let mut tracks: Vec<Track> = Vec::new();
|
||||
for c in clips {
|
||||
match tracks.iter_mut().find(|t| t.clips.last().map_or(i64::MIN, Clip::end) <= c.start) {
|
||||
Some(t) => t.clips.push(c),
|
||||
None => {
|
||||
let n = tracks.len();
|
||||
tracks.push(Track { layer, name: if n == 0 { name.to_string() } else { format!("{name} {}", n + 1) }, clips: vec![c] });
|
||||
}
|
||||
}
|
||||
}
|
||||
tracks.reverse();
|
||||
tracks
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
//! The render's manifest read as what an export places (docs/layers.feature LA4a, docs/capcut.feature CC2): each run of
|
||||
//! frames showing one file, each sound clip, the runs of frames a layer draws, and where a file the manifest names is.
|
||||
//! Pure: the export (lib.rs) renders and probes around it.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
pub use crate::model::{Key, key_at};
|
||||
|
||||
/// One file shown over a run of frames, as the manifest's frames say: its first source time and rate, its box, what of
|
||||
/// it a box it's in leaves showing (its clip), its fit and object-position at its first frame, its place in the page's
|
||||
/// order (lower draws first), and its keys when it moves, is cut differently or fades.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Run {
|
||||
pub src: String,
|
||||
pub key: String,
|
||||
pub start: i64,
|
||||
pub end: i64,
|
||||
pub at: f64,
|
||||
pub last_at: f64,
|
||||
pub rate: Option<f64>,
|
||||
pub bx: [f64; 4],
|
||||
pub clip: Option<[f64; 4]>,
|
||||
pub fit: String,
|
||||
/// object-position when not centred: [x px, x share of the free space, y px, y share]
|
||||
pub position: Option<[f64; 4]>,
|
||||
pub opacity: f64,
|
||||
pub z: usize,
|
||||
/// its box, clip, object-position and opacity where they change, frames from the timeline's start: each frame that
|
||||
/// differs from the one before and each that differs from the one after (where a hold ends), its first and its
|
||||
/// last, so a straight line between two keys is what each frame between them shows; none when nothing changes
|
||||
pub keys: Vec<Key>,
|
||||
}
|
||||
|
||||
/// Whether two keys show the footage alike: their boxes and clips to a twentieth of a pixel, their object-positions'
|
||||
/// px to the same and their shares of the free space to a hundred-thousandth (a 4K picture's free space is a few
|
||||
/// thousand px, a share's step a frame of a slow pan a few hundredths), and their opacity to half a percent.
|
||||
fn same(a: &Key, b: &Key) -> bool {
|
||||
let (p, q) = (placed(&a.position), placed(&b.position));
|
||||
let most = [apart(&a.r#box, &b.r#box), apart(&shown(&a.r#box, &a.clip), &shown(&b.r#box, &b.clip)), (p[0] - q[0]).abs(), (p[2] - q[2]).abs()];
|
||||
most.into_iter().fold(0.0, f64::max) <= 0.05 && (p[1] - q[1]).abs().max((p[3] - q[3]).abs()) <= 1e-5 && (a.opacity - b.opacity).abs() <= 0.005
|
||||
}
|
||||
|
||||
/// How far apart two fours are: their farthest pair.
|
||||
pub fn apart(p: &[f64; 4], q: &[f64; 4]) -> f64 {
|
||||
let mut most = 0.0f64;
|
||||
for (x, y) in p.iter().zip(q) {
|
||||
most = most.max((x - y).abs());
|
||||
}
|
||||
most
|
||||
}
|
||||
|
||||
impl Run {
|
||||
/// Its box, clip, object-position and opacity at `frame` (from the timeline's start): its keys' straight line
|
||||
/// there, or its first frame's when it has none.
|
||||
pub fn at(&self, frame: i64) -> Key {
|
||||
key_at(&self.keys, frame).unwrap_or(Key { frame, r#box: self.bx, clip: self.clip, position: self.position, opacity: self.opacity })
|
||||
}
|
||||
}
|
||||
|
||||
/// Only the keys where something changes: the first, the last, and those on either side of a change (none when nothing
|
||||
/// does).
|
||||
fn changes(all: Vec<Key>) -> Vec<Key> {
|
||||
if all.windows(2).all(|p| same(&p[0], &p[1])) {
|
||||
return Vec::new();
|
||||
}
|
||||
let n = all.len();
|
||||
(0..n).filter(|&i| i == 0 || i + 1 == n || !same(&all[i], &all[i - 1]) || !same(&all[i], &all[i + 1])).map(|i| all[i].clone()).collect()
|
||||
}
|
||||
|
||||
/// One sound clip of the manifest: its file, frames, source time, gain, rate and fades.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Sound {
|
||||
pub src: String,
|
||||
pub from: i64,
|
||||
pub to: i64,
|
||||
pub at: f64,
|
||||
pub gain_db: f64,
|
||||
pub rate: f64,
|
||||
pub fade_in: f64,
|
||||
pub fade_out: f64,
|
||||
}
|
||||
|
||||
/// The footage's runs, frame by frame: a run goes on while the same element shows the same file with its source time
|
||||
/// advancing at one rate; a jump in source time (a cut within one take) starts another.
|
||||
pub fn runs(manifest: &Value, fps: f64) -> Vec<Run> {
|
||||
let mut done: Vec<Run> = Vec::new();
|
||||
let mut open: Vec<Run> = Vec::new();
|
||||
let frames = manifest["frames"].as_array().cloned().unwrap_or_default();
|
||||
for (i, fr) in frames.iter().enumerate() {
|
||||
let f = fr["frame"].as_i64().unwrap_or(i as i64);
|
||||
let mut next = Vec::new();
|
||||
for (z, v) in fr["videos"].as_array().into_iter().flatten().enumerate() {
|
||||
let src = v["src"].as_str().unwrap_or_default().to_string();
|
||||
let id = format!("{src}|{}|{}|{}", v["loc"], v["use"], v["index"]);
|
||||
let at = v["at"].as_f64().unwrap_or(0.0);
|
||||
let bx: [f64; 4] = std::array::from_fn(|k| v["box"][k].as_f64().unwrap_or(0.0));
|
||||
let opacity = v["opacity"].as_f64().unwrap_or(1.0);
|
||||
let four = |field: &str| -> Option<[f64; 4]> { v[field].is_array().then(|| std::array::from_fn(|k| v[field][k].as_f64().unwrap_or(0.0))) };
|
||||
let (clip, position) = (four("clip"), four("position"));
|
||||
let key = Key { frame: f, r#box: bx, clip, position, opacity };
|
||||
let continues = |r: &Run| {
|
||||
let step = at - r.last_at;
|
||||
r.key == id && r.end == f && step > 0.0 && match r.rate {
|
||||
Some(rate) => (step - rate / fps).abs() <= 0.6 / fps,
|
||||
None => step * fps <= 8.0,
|
||||
}
|
||||
};
|
||||
if let Some(k) = open.iter().position(continues) {
|
||||
let mut r = open.remove(k);
|
||||
r.rate.get_or_insert((at - r.last_at) * fps);
|
||||
r.keys.push(key);
|
||||
(r.end, r.last_at) = (f + 1, at);
|
||||
next.push(r);
|
||||
} else {
|
||||
let fit = v["fit"].as_str().unwrap_or("fill").to_string();
|
||||
next.push(Run { src, key: id, start: f, end: f + 1, at, last_at: at, rate: None, bx, clip, fit, position, opacity, z, keys: vec![key] });
|
||||
}
|
||||
}
|
||||
done.append(&mut open);
|
||||
open = next;
|
||||
}
|
||||
done.append(&mut open);
|
||||
// the rate over the whole run (source times are whole milliseconds, so one step's can be 1% off), to hundredths
|
||||
for r in &mut done {
|
||||
r.keys = changes(std::mem::take(&mut r.keys));
|
||||
if r.end - r.start > 1 {
|
||||
r.rate = Some(((r.last_at - r.at) * fps / (r.end - r.start - 1) as f64 * 100.0).round() / 100.0);
|
||||
}
|
||||
}
|
||||
done.sort_by_key(|r| (r.start, r.z));
|
||||
done
|
||||
}
|
||||
|
||||
/// The manifest's sound clips.
|
||||
pub fn sounds(manifest: &Value) -> Vec<Sound> {
|
||||
let s = &manifest["sounds"]["clips"];
|
||||
s.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|c| Sound {
|
||||
src: c["src"].as_str().unwrap_or_default().to_string(),
|
||||
from: c["from"].as_i64().unwrap_or(0),
|
||||
to: c["to"].as_i64().unwrap_or(0),
|
||||
at: c["at"].as_f64().unwrap_or(0.0),
|
||||
gain_db: c["gainDb"].as_f64().unwrap_or(0.0),
|
||||
rate: c["rate"].as_f64().unwrap_or(1.0),
|
||||
fade_in: c["fadeIn"].as_f64().unwrap_or(0.0),
|
||||
fade_out: c["fadeOut"].as_f64().unwrap_or(0.0),
|
||||
})
|
||||
.filter(|c| c.to > c.from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// How many of a sound's frames it's heard for: its span on the timeline, or fewer when its file ends first (raea's
|
||||
/// <Audio> stops at its file's end, so a one-second tick in a longer <Sequence> is a one-second clip, not one that
|
||||
/// runs past its media in an editor).
|
||||
pub fn heard_frames(s: &Sound, seconds: f64, fps: f64) -> i64 {
|
||||
let left = ((seconds - s.at) / s.rate.max(0.01) * fps + 1e-6).floor() as i64;
|
||||
(s.to - s.from).min(left.max(0))
|
||||
}
|
||||
|
||||
/// Runs of frames that draw something.
|
||||
pub fn spans(drawn: &[bool]) -> Vec<(i64, i64)> {
|
||||
let mut out = Vec::new();
|
||||
let mut f = 0;
|
||||
while f < drawn.len() {
|
||||
if !drawn[f] {
|
||||
f += 1;
|
||||
continue;
|
||||
}
|
||||
let a = f;
|
||||
while f < drawn.len() && drawn[f] {
|
||||
f += 1;
|
||||
}
|
||||
out.push((a as i64, f as i64));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The keyframes a straight line between their neighbours can't stand for: each (when, values) whose values lie off
|
||||
/// the line from the last kept to the next by more than `tol` (each value's own), kept with the first and the last. A
|
||||
/// steady move or push-in is its two ends; a raea easing keeps a key a frame.
|
||||
pub fn thin<const N: usize>(all: &[(i64, [f64; N])], tol: &[f64; N]) -> Vec<(i64, [f64; N])> {
|
||||
let mut kept = vec![all[0]];
|
||||
let mut from = 0;
|
||||
for to in 2..all.len() {
|
||||
let (a, b) = (&all[from], &all[to]);
|
||||
let off = (from + 1..to).any(|i| {
|
||||
let t = (all[i].0 - a.0) as f64 / (b.0 - a.0).max(1) as f64;
|
||||
(0..N).any(|k| (a.1[k] + (b.1[k] - a.1[k]) * t - all[i].1[k]).abs() > tol[k])
|
||||
});
|
||||
if off {
|
||||
from = to - 1;
|
||||
kept.push(all[from]);
|
||||
}
|
||||
}
|
||||
if all.len() > 1 {
|
||||
kept.push(all[all.len() - 1]);
|
||||
}
|
||||
kept
|
||||
}
|
||||
|
||||
/// What of a box shows: its clip, else all of it.
|
||||
pub fn shown(bx: &[f64; 4], clip: &Option<[f64; 4]>) -> [f64; 4] {
|
||||
clip.unwrap_or(*bx)
|
||||
}
|
||||
|
||||
/// An object-position as [x px, x share, y px, y share]: its own, or centred (CSS's default) when none.
|
||||
pub fn placed(position: &Option<[f64; 4]>) -> [f64; 4] {
|
||||
position.unwrap_or([0.0, 0.5, 0.0, 0.5])
|
||||
}
|
||||
|
||||
/// A picture as raea draws it: where the whole of it is on the canvas, and what of it is kept.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Picture {
|
||||
/// the whole picture, [x, y, width, height] on the canvas (it can run past its box and the canvas)
|
||||
pub drawn: [f64; 4],
|
||||
/// what of it is kept, as shares of it: [left, top, right, bottom] edges, [0, 0, 1, 1] all of it
|
||||
pub kept: [f64; 4],
|
||||
}
|
||||
|
||||
/// Where a picture of `mw` x `mh` (upright) is drawn in `bx` on a `w` x `h` canvas, as blitz-paint draws it: sized by
|
||||
/// CSS's object-fit `fit`, placed by `position` (object-position; centred when none), and cut where its box or `clip`
|
||||
/// (what a box it's in leaves showing) cut it inside the canvas. The canvas's own edges cut nothing: an editor shows no
|
||||
/// more than its frame anyway, and someone reframing the clip there finds the rest of the picture, not a crop. A note
|
||||
/// when an editor can't show it so (object-fit: fill stretches it; an editor fits it inside its box instead).
|
||||
pub fn picture(bx: &[f64; 4], clip: &Option<[f64; 4]>, fit: &str, position: &Option<[f64; 4]>, (mw, mh): (f64, f64), (w, h): (f64, f64)) -> (Picture, Option<String>) {
|
||||
let [x, y, bw, bh] = *bx;
|
||||
let (sx, sy) = (bw / mw, bh / mh);
|
||||
let mut note = None;
|
||||
let s = match fit {
|
||||
"cover" => sx.max(sy),
|
||||
"none" => 1.0,
|
||||
"scale-down" => sx.min(sy).min(1.0),
|
||||
"contain" => sx.min(sy),
|
||||
_ => {
|
||||
if (sx - sy).abs() > 0.01 * sx.max(sy) {
|
||||
note = Some(format!("stretched to its {bw:.0}x{bh:.0} box (object-fit: fill); fitted inside it"));
|
||||
}
|
||||
sx.min(sy)
|
||||
}
|
||||
};
|
||||
let (dw, dh) = (mw * s, mh * s);
|
||||
let [xp, xs, yp, ys] = placed(position);
|
||||
let (dx, dy) = (x + xp + xs * (bw - dw), y + yp + ys * (bh - dh));
|
||||
// the edges that cut it: its box's and its clip's, those inside the canvas
|
||||
let [kx, ky, kw, kh] = shown(bx, clip);
|
||||
let near = |e: f64| e > 0.5;
|
||||
let far = |e: f64, side: f64| e < side - 0.5;
|
||||
let left = [x, kx].into_iter().filter(|&e| near(e)).fold(f64::NEG_INFINITY, f64::max);
|
||||
let top = [y, ky].into_iter().filter(|&e| near(e)).fold(f64::NEG_INFINITY, f64::max);
|
||||
let right = [x + bw, kx + kw].into_iter().filter(|&e| far(e, w)).fold(f64::INFINITY, f64::min);
|
||||
let bottom = [y + bh, ky + kh].into_iter().filter(|&e| far(e, h)).fold(f64::INFINITY, f64::min);
|
||||
// those edges on the picture (none past it), as shares of it
|
||||
let (l, r) = (left.max(dx).min(dx + dw), right.min(dx + dw).max(dx));
|
||||
let (t, b) = (top.max(dy).min(dy + dh), bottom.min(dy + dh).max(dy));
|
||||
let kept = [(l - dx) / dw, (t - dy) / dh, (r - dx) / dw, (b - dy) / dh];
|
||||
(Picture { drawn: [dx, dy, dw, dh], kept }, note)
|
||||
}
|
||||
|
||||
/// Whether a box covers the whole canvas.
|
||||
pub fn full(bx: &[f64; 4], w: f64, h: f64) -> bool {
|
||||
bx[0] <= 1.0 && bx[1] <= 1.0 && bx[0] + bx[2] >= w - 1.0 && bx[1] + bx[3] >= h - 1.0
|
||||
}
|
||||
|
||||
/// A file the manifest names, as a path, found as the renderer finds it: a staticFile path (/media/x) in the edit's
|
||||
/// media/, then the project's media/ and assets/; else absolute; else relative to the composition's folder.
|
||||
pub fn resolve(dir: &Path, src: &str) -> PathBuf {
|
||||
let p = raea_core_scene::media_path(dir, src);
|
||||
dunce::canonicalize(&p).unwrap_or(p)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
//! Captions as SubRip (docs/layers.feature LA2b): each run of frames a caption shows one line of words, from the
|
||||
//! render manifest's text marked `caption` (engine/page manifest.rs).
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
/// One SubRip entry: its words, its first frame and the frame after its last.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Line {
|
||||
pub text: String,
|
||||
pub from: i64,
|
||||
pub to: i64,
|
||||
}
|
||||
|
||||
/// The words the captions show on each frame, joined in the page's order; empty where none shows.
|
||||
pub fn said(manifest: &Value) -> Vec<String> {
|
||||
manifest["frames"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(caption_words)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// A frame's caption words (text marked `caption` and shown), each run's spacing made single, joined in order.
|
||||
fn caption_words(frame: &Value) -> String {
|
||||
let mut out = String::new();
|
||||
for t in frame["text"].as_array().into_iter().flatten() {
|
||||
if t["caption"] != true || t["opacity"].as_f64().unwrap_or(1.0) <= 0.01 {
|
||||
continue;
|
||||
}
|
||||
for word in t["text"].as_str().unwrap_or_default().split_whitespace() {
|
||||
if !out.is_empty() {
|
||||
out.push(' ');
|
||||
}
|
||||
out.push_str(word);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The lines: a run of frames showing the same words is one, and so is a line whose words come in one by one (each
|
||||
/// frame's words starting with the last's) or go one by one, shown whole for the run. A word's colour changing (a
|
||||
/// highlight as it's said) isn't in the words, so it never starts a line.
|
||||
pub fn lines(said: &[String]) -> Vec<Line> {
|
||||
let mut out: Vec<Line> = Vec::new();
|
||||
for (f, words) in said.iter().enumerate() {
|
||||
let f = f as i64;
|
||||
if words.is_empty() {
|
||||
continue;
|
||||
}
|
||||
match out.last_mut() {
|
||||
Some(l) if l.to == f && (words.starts_with(l.text.as_str()) || l.text.starts_with(words.as_str())) => {
|
||||
if words.len() > l.text.len() {
|
||||
l.text = words.clone();
|
||||
}
|
||||
l.to = f + 1;
|
||||
}
|
||||
_ => out.push(Line { text: words.clone(), from: f, to: f + 1 }),
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// SubRip's text: each line numbered from 1, its times as HH:MM:SS,mmm at `fps`.
|
||||
pub fn write(lines: &[Line], fps: f64) -> String {
|
||||
let t = |f: i64| {
|
||||
let ms = (f as f64 * 1000.0 / fps).round() as i64;
|
||||
format!("{:02}:{:02}:{:02},{:03}", ms / 3_600_000, ms / 60_000 % 60, ms / 1000 % 60, ms % 1000)
|
||||
};
|
||||
lines.iter().enumerate().map(|(k, l)| format!("{}\n{} --> {}\n{}\n", k + 1, t(l.from), t(l.to), l.text)).collect::<Vec<_>>().join("\n")
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
use serde_json::json;
|
||||
|
||||
use crate::model::{self, Clip, Layer, Layers};
|
||||
use crate::plan::*;
|
||||
use crate::srt;
|
||||
|
||||
fn said(frames: &[&[(&str, bool)]]) -> serde_json::Value {
|
||||
let frames: Vec<_> = frames.iter().enumerate().map(|(i, t)| json!({"frame": i, "videos": [], "text": t.iter().map(|(w, cap)| if *cap { json!({"text": w, "caption": true, "opacity": 1.0}) } else { json!({"text": w, "opacity": 1.0}) }).collect::<Vec<_>>()})).collect();
|
||||
json!({"frames": frames})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_frames_captions_are_its_caption_words_alone() {
|
||||
// docs/layers.feature LA2b: words marked caption, in the page's order; a title's words aren't
|
||||
let m = said(&[&[("Jane Doe", false), ("Hello", true), (" there ", true)], &[], &[("Jane Doe", false)]]);
|
||||
assert_eq!(srt::said(&m), ["Hello there", "", ""]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_line_lasts_while_its_words_do_and_a_highlight_starts_none() {
|
||||
let s = |v: &[&str]| v.iter().map(|w| w.to_string()).collect::<Vec<_>>();
|
||||
// the same words over frames 0-2 (a word's colour changing isn't in the words), a gap, then a line said word by word
|
||||
let lines = srt::lines(&s(&["Hello there", "Hello there", "Hello there", "", "This", "This is", "This is raea", "Next"]));
|
||||
assert_eq!(lines, [srt::Line { text: "Hello there".into(), from: 0, to: 3 }, srt::Line { text: "This is raea".into(), from: 4, to: 7 }, srt::Line { text: "Next".into(), from: 7, to: 8 }]);
|
||||
assert_eq!(srt::write(&lines[..2], 30.0), "1\n00:00:00,000 --> 00:00:00,100\nHello there\n\n2\n00:00:00,133 --> 00:00:00,233\nThis is raea\n");
|
||||
// timecodes past a minute and an hour
|
||||
assert_eq!(srt::write(&[srt::Line { text: "x".into(), from: 108_000, to: 108_015 }], 30.0), "1\n01:00:00,000 --> 01:00:00,500\nx\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clips_go_on_as_few_tracks_as_hold_them_listed_top_down() {
|
||||
let c = |id: &str, start, frames| Clip::new(id.into(), 0, start, frames, 0.0);
|
||||
let t = model::lay(Layer::Footage, "footage", vec![c("v1", 0, 30), c("v2", 10, 30), c("v3", 30, 10), c("v4", 41, 5)]);
|
||||
// v2 overlaps v1, so it goes on a second track, above the first
|
||||
assert_eq!(t.iter().map(|t| (t.name.as_str(), t.clips.iter().map(|c| c.id.as_str()).collect::<Vec<_>>())).collect::<Vec<_>>(), [("footage 2", vec!["v2"]), ("footage", vec!["v1", "v3", "v4"])]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layers_json_reads_back_as_it_was_written() {
|
||||
let mut v = Clip { r#box: Some([140.0, 160.0, 800.0, 470.0]), fit: Some("cover".into()), link: Some("a1".into()), ..Clip::new("v1".into(), 0, 0, 90, 1.5) };
|
||||
v.speed = 2.0;
|
||||
let a = Clip { gain_db: -6.0, fade_in: 0.5, link: Some("v1".into()), ..Clip::new("a1".into(), 0, 0, 90, 1.5) };
|
||||
let l = Layers {
|
||||
version: model::VERSION,
|
||||
name: "edit".into(),
|
||||
width: 1080,
|
||||
height: 1920,
|
||||
fps: 30.0,
|
||||
frames: 90,
|
||||
reference: "reference.mp4".into(),
|
||||
srt: Some("edit.srt".into()),
|
||||
files: vec![model::File { path: "/m/clip.mp4".into(), kind: model::FileKind::Video, seconds: 3.0, width: 640, height: 360, has_audio: true, channels: 2, sample_rate: 48_000, rotation: 0 }],
|
||||
tracks: vec![model::Track { layer: Layer::Footage, name: "footage".into(), clips: vec![v] }, model::Track { layer: Layer::Sound, name: "sound".into(), clips: vec![a] }],
|
||||
notes: vec![],
|
||||
};
|
||||
let text = serde_json::to_string(&l).unwrap();
|
||||
assert_eq!(serde_json::from_str::<Layers>(&text).unwrap(), l);
|
||||
// what a clip doesn't have isn't written: a sound has no box, footage no gain
|
||||
let j: serde_json::Value = serde_json::from_str(&text).unwrap();
|
||||
assert_eq!(j["tracks"][0]["layer"], "footage");
|
||||
assert!(j["tracks"][0]["clips"][0].get("gain_db").is_none() && j["tracks"][1]["clips"][0].get("box").is_none(), "{j}");
|
||||
}
|
||||
|
||||
// the manifest read as runs, sounds and spans (moved from apps/capcut, docs/capcut.feature CC2a-c)
|
||||
|
||||
/// 90 frames at 30 fps: one take cut into two pieces (a jump in its source time at frame 45), another file in a
|
||||
/// corner from frame 60, moving one pixel at frame 70. Source times in whole milliseconds, as the manifest has them.
|
||||
fn manifest() -> serde_json::Value {
|
||||
let ms = |t: f64| (t * 1000.0).round() / 1000.0;
|
||||
let frames: Vec<_> = (0..90)
|
||||
.map(|f| {
|
||||
let mut v = vec![json!({"src": "media/a.mp4", "at": ms(if f < 45 { 0.5 + f as f64 / 30.0 } else { 3.0 + (f - 45) as f64 / 30.0 }), "box": [0.0, 0.0, 1080.0, 1920.0], "fit": "cover", "opacity": 1.0})];
|
||||
if f >= 60 {
|
||||
v.push(json!({"src": "media/pip.mp4", "at": ms((f - 60) as f64 / 15.0), "box": [if f >= 70 { 662.0 } else { 660.0 }, 200.0, 360.0, 360.0], "opacity": 1.0}));
|
||||
}
|
||||
json!({"frame": f, "videos": v})
|
||||
})
|
||||
.collect();
|
||||
json!({"width": 1080, "height": 1920, "fps": 30.0, "frames": frames, "sounds": {"clips": [{"src": "/m/music.wav", "from": 0, "to": 90, "at": 0.0, "gainDb": -6.0, "fadeOut": 0.5}]}})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn footage_runs_break_where_the_source_jumps() {
|
||||
let r = runs(&manifest(), 30.0);
|
||||
assert_eq!(r.iter().map(|r| (r.src.as_str(), r.start, r.end)).collect::<Vec<_>>(), [("media/a.mp4", 0, 45), ("media/a.mp4", 45, 90), ("media/pip.mp4", 60, 90)]);
|
||||
assert!((r[1].at - 3.0).abs() < 1e-9);
|
||||
assert_eq!((r[0].rate, r[1].rate), (Some(1.0), Some(1.0)), "a take at its own speed, though each step is 33 or 34 ms");
|
||||
assert!((r[2].rate.unwrap() - 2.0).abs() < 1e-6, "the corner plays at twice its speed");
|
||||
assert!(!r[2].keys.is_empty() && r[0].keys.is_empty(), "the corner moves; the take holds");
|
||||
assert_eq!(r[2].fit, "fill");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sounds_keep_gain_and_fades() {
|
||||
let s = sounds(&manifest());
|
||||
assert_eq!(s.len(), 1);
|
||||
assert_eq!((s[0].from, s[0].to, s[0].gain_db, s[0].fade_out), (0, 90, -6.0, 0.5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overlay_spans_are_runs_of_drawn_frames() {
|
||||
assert_eq!(spans(&[false, true, true, false, false, true]), [(1, 3), (5, 6)]);
|
||||
assert!(spans(&[false; 4]).is_empty());
|
||||
}
|
||||
|
||||
/// staticFile("x.mp4") is "/media/x.mp4" in the manifest: the export finds it where the render did, in media/ beside
|
||||
/// the edit, as it finds a relative path; an absolute path stays as it is
|
||||
#[test]
|
||||
fn a_static_file_is_found_in_the_edits_media_folder() {
|
||||
let dir = std::env::temp_dir().join(format!("raea-layers-resolve-{}", std::process::id()));
|
||||
std::fs::create_dir_all(dir.join("media")).unwrap();
|
||||
std::fs::write(dir.join("media/a.mp4"), "").unwrap();
|
||||
let want = dunce::canonicalize(dir.join("media/a.mp4")).unwrap();
|
||||
assert_eq!(resolve(&dir, "/media/a.mp4"), want);
|
||||
assert_eq!(resolve(&dir, "media/a.mp4"), want);
|
||||
assert_eq!(resolve(&dir, want.to_str().unwrap()), want);
|
||||
std::fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
// the FCP7 XML (docs/layers.feature LA5a)
|
||||
|
||||
/// motion's (scale, centre, crop) for a picture in `bx` on a `w` x `h` frame, in `editor`'s terms
|
||||
fn placed(editor: crate::xml::Editor, bx: [f64; 4], clip: Option<[f64; 4]>, fit: &str, position: Option<[f64; 4]>, media: (f64, f64), frame: (f64, f64)) -> (f64, [f64; 2], [f64; 4]) {
|
||||
crate::xml::motion(editor, &picture(&bx, &clip, fit, &position, media, frame).0, media, false, frame)
|
||||
}
|
||||
|
||||
fn near(a: f64, b: f64) -> bool {
|
||||
(a - b).abs() < 1e-6
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_picture_in_picture_sits_as_raea_drew_it_in_basic_motions_terms() {
|
||||
use crate::xml::Editor::*;
|
||||
// C (1280x720) contained in a 380x225 box at (850, 50) on a 1280x720 sequence: scaled to 380/1280, its centre
|
||||
// right of and above the frame's, nothing cut; the media the frame's size, so both editors alike
|
||||
for e in [Premiere, Resolve] {
|
||||
let (scale, centre, crop) = placed(e, [850.0, 50.0, 380.0, 225.0], None, "contain", None, (1280.0, 720.0), (1280.0, 720.0));
|
||||
assert!(near(scale, 380.0 / 1280.0 * 100.0) && near(centre[0], (1040.0 - 640.0) / 1280.0) && near(centre[1], (162.5 - 360.0) / 720.0));
|
||||
assert_eq!(crop, [0.0; 4]);
|
||||
}
|
||||
// stretched in raea: fitted inside, and said
|
||||
assert!(picture(&[0.0, 0.0, 500.0, 100.0], &None, "fill", &None, (640.0, 640.0), (1080.0, 1920.0)).1.is_some());
|
||||
}
|
||||
|
||||
/// a horizontal (landscape) take covering a vertical frame: scaled to fill its height, uncut (the frame cuts its
|
||||
/// sides, so an editor reframing it finds the rest); Premiere's Scale of its pixels, Resolve's of it fitted (whole) to
|
||||
/// the frame
|
||||
#[test]
|
||||
fn a_horizontal_take_covers_a_vertical_frame_uncut() {
|
||||
use crate::xml::Editor::*;
|
||||
let (scale, centre, crop) = placed(Premiere, [0.0, 0.0, 1080.0, 1920.0], None, "cover", None, (3840.0, 2160.0), (1080.0, 1920.0));
|
||||
assert!(near(scale, 1920.0 / 2160.0 * 100.0) && centre == [0.0, 0.0] && crop == [0.0; 4]);
|
||||
let (scale, _, _) = placed(Resolve, [0.0, 0.0, 1080.0, 1920.0], None, "cover", None, (3840.0, 2160.0), (1080.0, 1920.0));
|
||||
assert!(near(scale, (1920.0 / 2160.0) / (1080.0 / 3840.0) * 100.0));
|
||||
// framed on its left third (object-position: 0% 50%): the picture's left edge on the frame's, its centre right of
|
||||
// the frame's by half its overhang, in each editor's units
|
||||
let dw = 3840.0 * 1920.0 / 2160.0;
|
||||
let (_, centre, crop) = placed(Premiere, [0.0, 0.0, 1080.0, 1920.0], None, "cover", Some([0.0, 0.0, 0.0, 0.5]), (3840.0, 2160.0), (1080.0, 1920.0));
|
||||
assert!(near(centre[0], (dw / 2.0 - 540.0) / 3840.0) && centre[1] == 0.0 && crop == [0.0; 4]);
|
||||
let (_, centre, _) = placed(Resolve, [0.0, 0.0, 1080.0, 1920.0], None, "cover", Some([0.0, 0.0, 0.0, 0.5]), (3840.0, 2160.0), (1080.0, 1920.0));
|
||||
assert!(near(centre[0], (dw / 2.0 - 540.0) / 1080.0));
|
||||
// contained in a picture in picture above the frame's middle: Premiere's Center in the take's own pixels, Resolve's in
|
||||
// the take fitted to the frame (1080 x 607.5), across and down alike (Resolve drew 1080's units 238 px low, 11-17)
|
||||
let (_, centre, _) = placed(Premiere, [80.0, 300.0, 620.0, 620.0], None, "contain", None, (3840.0, 2160.0), (1080.0, 1920.0));
|
||||
assert!(near(centre[0], -150.0 / 3840.0) && near(centre[1], -350.0 / 2160.0), "{centre:?}");
|
||||
let (_, centre, _) = placed(Resolve, [80.0, 300.0, 620.0, 620.0], None, "contain", None, (3840.0, 2160.0), (1080.0, 1920.0));
|
||||
assert!(near(centre[0], -150.0 / 1080.0) && near(centre[1], -350.0 / 607.5), "{centre:?}");
|
||||
// in a box inside the frame it's cut to the box, each side by what overhangs it
|
||||
let (_, _, crop) = placed(Premiere, [100.0, 300.0, 880.0, 880.0], None, "cover", None, (3840.0, 2160.0), (1080.0, 1920.0));
|
||||
let over = (3840.0 * 880.0 / 2160.0 - 880.0) / 2.0 / (3840.0 * 880.0 / 2160.0) * 100.0;
|
||||
assert!(near(crop[0], over) && near(crop[1], over) && crop[2] == 0.0 && crop[3] == 0.0, "{crop:?}");
|
||||
}
|
||||
|
||||
/// composed at the footage's own size (a 4K edit of 4K takes): 100 in both editors, wherever it's placed; a 1080 edit of
|
||||
/// the same takes is Premiere's 50 and Resolve's 100, its centre in each one's units
|
||||
#[test]
|
||||
fn footage_at_the_frames_size_is_at_100_in_both_editors() {
|
||||
use crate::xml::Editor::*;
|
||||
for e in [Premiere, Resolve] {
|
||||
let (scale, centre, crop) = placed(e, [0.0, 0.0, 2160.0, 3840.0], None, "cover", None, (2160.0, 3840.0), (2160.0, 3840.0));
|
||||
assert!(near(scale, 100.0) && centre == [0.0, 0.0] && crop == [0.0; 4], "{e:?}");
|
||||
// risen 520 px (the 1080 edit's 260): Premiere's 520 / 3840 of the take, Resolve's 520 / 3840 of the frame
|
||||
let (_, centre, _) = placed(e, [0.0, -520.0, 2160.0, 3840.0], None, "cover", None, (2160.0, 3840.0), (2160.0, 3840.0));
|
||||
assert!(near(centre[1], -520.0 / 3840.0));
|
||||
}
|
||||
let (scale, centre, _) = placed(Premiere, [0.0, -260.0, 1080.0, 1920.0], None, "cover", None, (2160.0, 3840.0), (1080.0, 1920.0));
|
||||
assert!(near(scale, 50.0) && near(centre[1], -260.0 / 3840.0));
|
||||
let (scale, centre, _) = placed(Resolve, [0.0, -260.0, 1080.0, 1920.0], None, "cover", None, (2160.0, 3840.0), (1080.0, 1920.0));
|
||||
assert!(near(scale, 100.0) && near(centre[1], -260.0 / 1920.0));
|
||||
// across, in each one's units: a picture in picture 300 px right of centre
|
||||
let (_, centre, _) = placed(Premiere, [690.0, 760.0, 300.0, 400.0], None, "cover", None, (2160.0, 3840.0), (1080.0, 1920.0));
|
||||
assert!(near(centre[0], 300.0 / 2160.0));
|
||||
let (_, centre, _) = placed(Resolve, [690.0, 760.0, 300.0, 400.0], None, "cover", None, (2160.0, 3840.0), (1080.0, 1920.0));
|
||||
assert!(near(centre[0], 300.0 / 1080.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_xml_has_the_tracks_bottom_first_and_footage_linked_to_its_sound() {
|
||||
use crate::model::{File, FileKind, Track};
|
||||
let file = |path: &str, kind, w, h, a| File { path: path.into(), kind, seconds: 10.0, width: w, height: h, has_audio: a, channels: 2, sample_rate: 48_000, rotation: 0 };
|
||||
let c = |id: &str, f, start, frames, at| Clip::new(id.into(), f, start, frames, at);
|
||||
let v1 = Clip { r#box: Some([0.0, 0.0, 1280.0, 720.0]), fit: Some("cover".into()), link: Some("a1".into()), ..c("v1", 0, 0, 90, 1.0) };
|
||||
let v2 = Clip { r#box: Some([0.0, 0.0, 1280.0, 720.0]), fit: Some("cover".into()), ..c("v2", 0, 90, 30, 5.0) };
|
||||
let a1 = Clip { link: Some("v1".into()), ..c("a1", 0, 0, 90, 1.0) };
|
||||
let l = Layers {
|
||||
version: model::VERSION,
|
||||
name: "edit & co".into(),
|
||||
width: 1280,
|
||||
height: 720,
|
||||
fps: 29.97,
|
||||
frames: 120,
|
||||
reference: "reference.mp4".into(),
|
||||
srt: None,
|
||||
files: vec![file("/m/my clip.mp4", FileKind::Video, 1280, 720, true), file("graphics.prores.mov", FileKind::Video, 1280, 720, false), file("/m/music.wav", FileKind::Audio, 0, 0, true)],
|
||||
tracks: vec![
|
||||
Track { layer: Layer::Graphics, name: "graphics".into(), clips: vec![c("g1", 1, 30, 60, 1.0)] },
|
||||
Track { layer: Layer::Footage, name: "footage".into(), clips: vec![v1, v2] },
|
||||
Track { layer: Layer::Sound, name: "sound".into(), clips: vec![a1, Clip { gain_db: -12.0, ..c("a2", 2, 0, 120, 0.0) }] },
|
||||
],
|
||||
notes: vec![],
|
||||
};
|
||||
let (x, notes) = crate::xml::write(&l, std::path::Path::new("/out/xml/edit"), crate::xml::Editor::Premiere);
|
||||
assert!(notes.is_empty(), "{notes:?}");
|
||||
// 29.97 is a timebase of 30, NTSC; the name escaped
|
||||
assert!(x.contains("<name>edit & co</name><duration>120</duration><rate><timebase>30</timebase><ntsc>TRUE</ntsc></rate>"), "{x}");
|
||||
// video tracks bottom first: the footage (v1 from 30 source frames in, v2 from 150), then the graphics
|
||||
let footage = x.find("<clipitem id=\"v1\"").unwrap();
|
||||
assert!(footage < x.find("<clipitem id=\"g1\"").unwrap());
|
||||
assert!(x.contains("<start>0</start><end>90</end><in>30</in><out>120</out>") && x.contains("<start>90</start><end>120</end><in>150</in><out>180</out>"), "{x}");
|
||||
// a file in full once (its path percent-encoded), by id after
|
||||
assert_eq!(x.matches("<pathurl>file://localhost/m/my%20clip.mp4</pathurl>").count(), 1);
|
||||
assert!(x.contains("<file id=\"file-1\"/>"));
|
||||
// the graphics' movie found beside the XML, its alpha straight
|
||||
assert!(x.contains("<pathurl>file://localhost/out/xml/edit/graphics.prores.mov</pathurl>") && x.contains("<alphatype>straight</alphatype>"));
|
||||
// v1 and its sound's two channels (each a mono clipitem on a track of its own, as Premiere writes a stereo clip)
|
||||
// linked together, in each of the three; v2 has no sound placed
|
||||
let link = "<link><linkclipref>v1</linkclipref><mediatype>video</mediatype><trackindex>1</trackindex><clipindex>1</clipindex></link><link><linkclipref>a1</linkclipref><mediatype>audio</mediatype><trackindex>1</trackindex><clipindex>1</clipindex></link><link><linkclipref>a1-2</linkclipref><mediatype>audio</mediatype><trackindex>2</trackindex><clipindex>1</clipindex></link>";
|
||||
assert_eq!(x.matches(link).count(), 3, "{x}");
|
||||
assert!(x.contains("<clipitem id=\"a1-2\" premiereChannelType=\"mono\"><masterclipid>masterclip-1</masterclipid>"), "{x}");
|
||||
assert!(x.contains("<sourcetrack><mediatype>audio</mediatype><trackindex>2</trackindex></sourcetrack>"));
|
||||
// the file's sound as its two channels, left and right; the two tracks to output channels 1 and 2
|
||||
assert!(x.contains("<channelcount>1</channelcount><layout>stereo</layout><audiochannel><sourcechannel>2</sourcechannel><channellabel>right</channellabel></audiochannel>"));
|
||||
assert!(x.contains("<outputchannelindex>1</outputchannelindex></track>") && x.contains("<outputchannelindex>2</outputchannelindex></track>"));
|
||||
// each channel panned to its own side by an Audio Pan on the clip, as Resolve writes it; nothing on the track
|
||||
assert!(!x.contains("PannerCurrentValue"), "{x}");
|
||||
assert!(x.contains("<effectid>audiopan</effectid><effectcategory>audiopan</effectcategory><effecttype>audiopan</effecttype><mediatype>audio</mediatype><parameter><parameterid>pan</parameterid><name>Pan</name><valuemin>-1</valuemin><valuemax>1</valuemax><value>-1</value>"), "{x}");
|
||||
assert_eq!(x.matches("<parameterid>pan</parameterid>").count(), 4, "two stereo clips, two channels each");
|
||||
// the music at -12 dB as Audio Levels' linear gain
|
||||
assert!(x.contains("<parameterid>level</parameterid><name>Level</name><valuemin>0.00003162</valuemin><valuemax>31.6228</valuemax><value>0.251189</value>"), "{x}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_sound_is_a_clip_as_long_as_its_file_plays() {
|
||||
let s = |from, to, at, rate| Sound { src: "tick.wav".into(), from, to, at, gain_db: 0.0, rate, fade_in: 0.0, fade_out: 0.0 };
|
||||
// a one-second tick in a 2.5 s Sequence at 24 fps: 24 frames, not 60
|
||||
assert_eq!(heard_frames(&s(100, 160, 0.0, 1.0), 1.0, 24.0), 24);
|
||||
// a long file in a short Sequence keeps the Sequence's length
|
||||
assert_eq!(heard_frames(&s(0, 48, 0.0, 1.0), 84.0, 24.0), 48);
|
||||
// from 0.5 s in, at double speed: 0.25 s left, 6 frames
|
||||
assert_eq!(heard_frames(&s(0, 60, 0.5, 2.0), 1.0, 24.0), 6);
|
||||
// started past its end: nothing heard
|
||||
assert_eq!(heard_frames(&s(0, 60, 2.0, 1.0), 1.0, 24.0), 0);
|
||||
}
|
||||
|
||||
/// footage that rises in a box that shrinks over it (a split screen): keys where it holds and on either side of the
|
||||
/// move, a clip from its box's cut; a run that holds still has none
|
||||
#[test]
|
||||
fn footage_that_moves_keeps_keys_where_it_changes() {
|
||||
let frame = |f: i64, top: f64, clip_h: Option<f64>| {
|
||||
let mut v = json!({"src": "a.mp4", "at": 1.0 + f as f64 / 24.0, "box": [0.0, top, 1080.0, 1920.0], "opacity": 1.0, "fit": "cover"});
|
||||
if let Some(h) = clip_h {
|
||||
v["clip"] = json!([0.0, 0.0, 1080.0, h]);
|
||||
}
|
||||
json!({"frame": f, "videos": [v]})
|
||||
};
|
||||
// frames 0-2 full, 3-5 rising and cut, 6-8 held split
|
||||
let tops = [0.0, 0.0, 0.0, -100.0, -200.0, -260.0, -260.0, -260.0, -260.0];
|
||||
let clips = [None, None, None, Some(1400.0), Some(1000.0), Some(860.0), Some(860.0), Some(860.0), Some(860.0)];
|
||||
let m = json!({"frames": (0..9).map(|f| frame(f, tops[f as usize], clips[f as usize])).collect::<Vec<_>>()});
|
||||
let r = &runs(&m, 24.0)[0];
|
||||
assert!(r.clip.is_none());
|
||||
assert_eq!(r.keys.iter().map(|k| k.frame).collect::<Vec<_>>(), [0, 2, 3, 4, 5, 8]);
|
||||
assert_eq!(r.keys[3].clip, Some([0.0, 0.0, 1080.0, 1000.0]));
|
||||
let still = json!({"frames": (0..9).map(|f| frame(f, 0.0, Some(860.0))).collect::<Vec<_>>()});
|
||||
let r = &runs(&still, 24.0)[0];
|
||||
assert!(r.keys.is_empty() && r.clip == Some([0.0, 0.0, 1080.0, 860.0]));
|
||||
// between two keys, a straight line: halfway from frame 3 (risen 100, cut at 1400) to 4 has none, but 3.. 5 does
|
||||
let moving = runs(&m, 24.0).remove(0);
|
||||
let k = moving.at(4);
|
||||
assert_eq!((k.r#box[1], k.clip), (-200.0, Some([0.0, 0.0, 1080.0, 1000.0])));
|
||||
assert_eq!(moving.at(7).r#box[1], -260.0);
|
||||
assert_eq!((moving.at(-5).r#box[1], moving.at(20).r#box[1]), (0.0, -260.0), "before its first key and after its last");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_clip_cuts_the_picture_as_crop() {
|
||||
use crate::xml::Editor::Premiere;
|
||||
// a 1080x1920 take filling a portrait frame, risen 260 px, its box cut at 860: placed by its box, all below 860
|
||||
// cut; its top (past the frame, which cuts it) not
|
||||
let (scale, centre, crop) = placed(Premiere, [0.0, -260.0, 1080.0, 1920.0], Some([0.0, 0.0, 1080.0, 860.0]), "cover", None, (1080.0, 1920.0), (1080.0, 1920.0));
|
||||
assert!(near(scale, 100.0) && near(centre[1], -260.0 / 1920.0));
|
||||
assert!(crop[0] == 0.0 && crop[1] == 0.0 && crop[2] == 0.0 && near(crop[3], (1920.0 - 1120.0) / 1920.0 * 100.0), "{crop:?}");
|
||||
// a picture in picture cut by a card's edges inside the frame: cut where the card cuts it
|
||||
let (_, _, crop) = placed(Premiere, [100.0, 100.0, 400.0, 400.0], Some([150.0, 100.0, 300.0, 400.0]), "cover", None, (400.0, 400.0), (1080.0, 1920.0));
|
||||
assert!(near(crop[0], 12.5) && near(crop[1], 12.5) && crop[2] == 0.0 && crop[3] == 0.0, "{crop:?}");
|
||||
}
|
||||
|
||||
/// a steady move is its two ends in the XML, an eased one a key a frame; a clip at another speed is placed at its own
|
||||
/// speed, as many source frames as it lasts, and said
|
||||
#[test]
|
||||
fn steady_moves_are_two_keys_and_other_speeds_are_said() {
|
||||
use crate::model::{File, FileKind, Key, Track};
|
||||
let k = |frame: i64, x: f64| Key { frame, r#box: [x, 500.0, 400.0, 400.0], clip: None, position: None, opacity: 1.0 };
|
||||
let steady = Clip { r#box: Some([100.0, 500.0, 400.0, 400.0]), fit: Some("cover".into()), keys: (0..24).map(|f| k(f, 100.0 + 10.0 * f as f64)).collect(), ..Clip::new("v1".into(), 0, 0, 24, 0.0) };
|
||||
let eased = Clip { r#box: Some([100.0, 500.0, 400.0, 400.0]), fit: Some("cover".into()), keys: (0..24).map(|f| k(f, 100.0 + (f * f) as f64)).collect(), speed: 2.0, ..Clip::new("v2".into(), 0, 24, 24, 0.0) };
|
||||
let l = Layers {
|
||||
version: model::VERSION,
|
||||
name: "e".into(),
|
||||
width: 1080,
|
||||
height: 1920,
|
||||
fps: 24.0,
|
||||
frames: 48,
|
||||
reference: "reference.mp4".into(),
|
||||
srt: None,
|
||||
files: vec![File { path: "/m/a.mov".into(), kind: FileKind::Video, seconds: 10.0, width: 400, height: 400, has_audio: false, channels: 2, sample_rate: 48_000, rotation: 0 }],
|
||||
tracks: vec![Track { layer: Layer::Footage, name: "footage".into(), clips: vec![steady, eased] }],
|
||||
notes: vec![],
|
||||
};
|
||||
let (x, notes) = crate::xml::write(&l, std::path::Path::new("/out"), crate::xml::Editor::Premiere);
|
||||
let v1 = &x[x.find("<clipitem id=\"v1\"").unwrap()..x.find("<clipitem id=\"v2\"").unwrap()];
|
||||
assert_eq!(v1.matches("<keyframe>").count(), 2, "{v1}");
|
||||
let v2 = &x[x.find("<clipitem id=\"v2\"").unwrap()..];
|
||||
assert!(v2.matches("<keyframe>").count() > 20 && v2.contains("<start>24</start><end>48</end><in>0</in><out>24</out>"), "{v2}");
|
||||
assert!(notes.iter().any(|n| n.contains("plays at 2.00x in raea")), "{notes:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keyed_footage_is_keyframed_in_the_xml() {
|
||||
use crate::model::{File, FileKind, Key, Track};
|
||||
let k = |frame, top: f64, h: f64, opacity| Key { frame, r#box: [0.0, top, 1080.0, 1920.0], clip: (h < 1920.0).then_some([0.0, 0.0, 1080.0, h]), position: None, opacity };
|
||||
let v = Clip { r#box: Some([0.0, 0.0, 1080.0, 1920.0]), fit: Some("cover".into()), keys: vec![k(0, 0.0, 1920.0, 1.0), k(12, -260.0, 860.0, 1.0), k(40, -260.0, 860.0, 0.5)], ..Clip::new("v1".into(), 0, 100, 41, 2.0) };
|
||||
let l = Layers {
|
||||
version: model::VERSION,
|
||||
name: "e".into(),
|
||||
width: 1080,
|
||||
height: 1920,
|
||||
fps: 24.0,
|
||||
frames: 141,
|
||||
reference: "reference.mp4".into(),
|
||||
srt: None,
|
||||
files: vec![File { path: "/m/a.mov".into(), kind: FileKind::Video, seconds: 10.0, width: 1080, height: 1920, has_audio: false, channels: 2, sample_rate: 48_000, rotation: 0 }],
|
||||
tracks: vec![Track { layer: Layer::Footage, name: "footage".into(), clips: vec![v] }],
|
||||
notes: vec![],
|
||||
};
|
||||
use crate::xml::Editor;
|
||||
let (x, _) = crate::xml::write(&l, std::path::Path::new("/out"), Editor::Premiere);
|
||||
// scale holds: a value, no keyframes; the centre, crop and opacity keyed, each key in the source's frames (from 48)
|
||||
assert!(x.contains("<parameterid>scale</parameterid><name>Scale</name><valuemin>0</valuemin><valuemax>1000</valuemax><value>100.0000</value></parameter>"), "{x}");
|
||||
assert!(x.contains("<parameterid>center</parameterid><name>Center</name><value><horiz>0.000000</horiz><vert>0.000000</vert></value><keyframe><when>48</when><value><horiz>0.000000</horiz><vert>0.000000</vert></value></keyframe><keyframe><when>60</when><value><horiz>0.000000</horiz><vert>-0.135417</vert></value></keyframe>"), "{x}");
|
||||
// Premiere's crop is Basic Motion's, as Premiere writes it: the bottom 41.7% cut at the split
|
||||
assert!(x.contains("<parameterid>bottomcrop</parameterid><name>Bottom</name><valuemin>0</valuemin><valuemax>100</valuemax><value>0.0000</value><keyframe><when>48</when><value>0.0000</value></keyframe><keyframe><when>60</when><value>41.6667</value></keyframe>"), "{x}");
|
||||
assert!(!x.contains("<effectid>crop</effectid>"), "{x}");
|
||||
assert!(x.contains("<parameterid>opacity</parameterid><name>opacity</name>") && x.contains("<keyframe><when>88</when><value>50.00</value></keyframe>"), "{x}");
|
||||
// Resolve's is FCP7's Crop filter, as it is for a file stored upright: 41.7% off its bottom (its top past the frame,
|
||||
// which cuts it)
|
||||
let (x, _) = crate::xml::write(&l, std::path::Path::new("/out"), Editor::Resolve);
|
||||
assert!(!x.contains("bottomcrop") && x.contains("<effectid>crop</effectid>"), "{x}");
|
||||
// a take twice the timeline's size, stored on its side (a phone's): Premiere's is described as stored (3840 x 2160,
|
||||
// as Premiere's own XML describes it) and its Center in that, 260 px up 260 / 2160; Resolve's in the frame's
|
||||
let mut phone = l.clone();
|
||||
(phone.files[0].width, phone.files[0].height, phone.files[0].rotation) = (2160, 3840, 90);
|
||||
let premiere = crate::xml::write(&phone, std::path::Path::new("/out"), Editor::Premiere).0;
|
||||
assert!(premiere.contains("<width>3840</width><height>2160</height>") && premiere.contains("<keyframe><when>60</when><value><horiz>0.000000</horiz><vert>-0.120370</vert></value></keyframe>"), "{premiere}");
|
||||
assert!(crate::xml::write(&phone, std::path::Path::new("/out"), Editor::Resolve).0.contains("<width>2160</width><height>3840</height>"));
|
||||
assert!(crate::xml::write(&phone, std::path::Path::new("/out"), Editor::Resolve).0.contains("<keyframe><when>60</when><value><horiz>0.000000</horiz><vert>-0.135417</vert></value></keyframe>"));
|
||||
// a take twice the timeline's size: Premiere's 50 (of its pixels) is Resolve's 100 (fitted to the timeline)
|
||||
let mut big = l.clone();
|
||||
big.files[0].width = 2160;
|
||||
big.files[0].height = 3840;
|
||||
assert!(crate::xml::write(&big, std::path::Path::new("/out"), Editor::Premiere).0.contains("<parameterid>scale</parameterid><name>Scale</name><valuemin>0</valuemin><valuemax>1000</valuemax><value>50.0000</value>"));
|
||||
assert!(crate::xml::write(&big, std::path::Path::new("/out"), Editor::Resolve).0.contains("<parameterid>scale</parameterid><name>Scale</name><valuemin>0</valuemin><valuemax>1000</valuemax><value>100.0000</value>"));
|
||||
assert!(x.contains("<parameterid>bottom</parameterid><name>bottom</name><valuemin>0</valuemin><valuemax>100</valuemax><value>0.0000</value><keyframe><when>48</when><value>0.0000</value></keyframe><keyframe><when>60</when><value>41.6667</value></keyframe>"), "{x}");
|
||||
// a phone's take stored turned 90: Resolve cuts it mirrored top to bottom, so its sides go swapped (11-17's render),
|
||||
// Premiere's as they are
|
||||
let mut l = l;
|
||||
l.files[0].rotation = 90;
|
||||
assert!(crate::xml::write(&l, std::path::Path::new("/out"), Editor::Premiere).0.contains("<parameterid>bottomcrop</parameterid><name>Bottom</name><valuemin>0</valuemin><valuemax>100</valuemax><value>0.0000</value><keyframe><when>48</when><value>0.0000</value></keyframe><keyframe><when>60</when><value>41.6667</value>"));
|
||||
let (x, _) = crate::xml::write(&l, std::path::Path::new("/out"), Editor::Resolve);
|
||||
assert!(x.contains("<parameterid>top</parameterid><name>top</name><valuemin>0</valuemin><valuemax>100</valuemax><value>0.0000</value><keyframe><when>48</when><value>0.0000</value></keyframe><keyframe><when>60</when><value>41.6667</value></keyframe>"), "{x}");
|
||||
assert!(x.contains("<parameterid>bottom</parameterid><name>bottom</name><valuemin>0</valuemin><valuemax>100</valuemax><value>0.0000</value></parameter>"), "{x}");
|
||||
}
|
||||
|
||||
/// a pan inside a still box (object-position animated, a Ken Burns across a horizontal take): keyed like a move, the
|
||||
/// picture's centre crossing the frame in the XML
|
||||
#[test]
|
||||
fn a_pan_inside_its_box_is_keyed() {
|
||||
let frame = |f: i64| json!({"frame": f, "videos": [{"src": "land.mov", "at": f as f64 / 24.0, "box": [0.0, 0.0, 1080.0, 1920.0], "opacity": 1.0, "fit": "cover", "position": [0.0, f as f64 / 10.0, 0.0, 0.5]}]});
|
||||
let r = &runs(&json!({"frames": (0..11).map(frame).collect::<Vec<_>>()}), 24.0)[0];
|
||||
assert!(!r.keys.is_empty() && r.at(5).position == Some([0.0, 0.5, 0.0, 0.5]));
|
||||
let (from, to) = (r.at(0), r.at(10));
|
||||
let centre = |k: &Key| crate::xml::motion(crate::xml::Editor::Resolve, &picture(&k.r#box, &k.clip, "cover", &k.position, (3840.0, 2160.0), (1080.0, 1920.0)).0, (3840.0, 2160.0), false, (1080.0, 1920.0)).1[0];
|
||||
let dw = 3840.0 * 1920.0 / 2160.0;
|
||||
assert!(near(centre(&from), (dw / 2.0 - 540.0) / 1080.0) && near(centre(&to), -(dw / 2.0 - 540.0) / 1080.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_windows_path_is_a_file_url_an_editor_opens() {
|
||||
// #195: 0.1.8-rc8 wrote file://localhostD%3A%5CWork%5C... for D:\Work\...; Resolve imported the same XML at once with
|
||||
// file:///D:/Work/...
|
||||
use crate::xml::pathurl;
|
||||
use std::path::Path;
|
||||
assert_eq!(pathurl(Path::new(r"D:\Work\_research\raea\xmltest\public\clip.mp4")), "file:///D:/Work/_research/raea/xmltest/public/clip.mp4");
|
||||
assert_eq!(pathurl(Path::new(r"\\?\C:\Users\Jürgen\my clip.mp4")), "file:///C:/Users/J%C3%BCrgen/my%20clip.mp4");
|
||||
assert_eq!(pathurl(Path::new("C:/Users/me/out/xml/edit/graphics.rle.mov")), "file:///C:/Users/me/out/xml/edit/graphics.rle.mov");
|
||||
assert_eq!(pathurl(Path::new(r"\\nas\clips\a.mp4")), "file://nas/clips/a.mp4");
|
||||
assert_eq!(pathurl(Path::new(r"\\?\UNC\nas\clips\a.mp4")), "file://nas/clips/a.mp4");
|
||||
// a Mac's or Linux's as before, a backslash there being part of a name
|
||||
assert_eq!(pathurl(Path::new("/Users/me/my clip.mp4")), "file://localhost/Users/me/my%20clip.mp4");
|
||||
assert_eq!(pathurl(Path::new(r"/tmp/a\b.mp4")), "file://localhost/tmp/a%5Cb.mp4");
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
//! layers.json as an FCP7 XML project (xmeml version 5, docs/layers.feature LA5a), which Premiere Pro (File, Import)
|
||||
//! and DaVinci Resolve (File, Import, Timeline) both read: one sequence at the composition's rate and size, its video
|
||||
//! tracks bottom first (under, the footage, what's behind a picture in picture, the pictures in picture, graphics,
|
||||
//! captions), its audio tracks below. Footage points at its file where it is, placed as raea drew it (Basic Motion's
|
||||
//! scale and centre, its crop where object-fit: cover or a box it's in cuts it, its Opacity, each keyframed where it
|
||||
//! changes over the clip; the crop as each editor writes it, so an XML for each: see Editor); a footage clip and its own sound are linked
|
||||
//! clipitems, which Premiere's Unlink and Resolve's Link Clips separate. Sound is laid out as Premiere writes it (read
|
||||
//! from an XML Premiere Pro 2026 exported): a stereo file's channels each a mono clipitem on a track of its own, each
|
||||
//! panned to its side by an Audio Pan on the clip, as Resolve and FCP7 write it (both editors import a channel centred
|
||||
//! without it; Premiere's own track pan, PannerCurrentValue, was tried and neither read it). A layer's movie fills the frame, its alpha
|
||||
//! straight. Pure: the export (lib.rs) makes the layers and writes this beside them.
|
||||
|
||||
use std::fmt::Write as _;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::model::{Clip, FileKind, Key, Layer, Layers};
|
||||
use crate::plan::{self, Picture};
|
||||
|
||||
/// xmeml's rate: a whole timebase and whether it runs at 1000/1001 of it (29.97 is 30 NTSC).
|
||||
fn rate(fps: f64) -> (u32, bool) {
|
||||
let base = fps.round().max(1.0);
|
||||
(base as u32, (fps - base).abs() > 0.001 && (fps * 1001.0 / 1000.0 - base).abs() < 0.01)
|
||||
}
|
||||
|
||||
fn rate_xml(fps: f64) -> String {
|
||||
let (tb, ntsc) = rate(fps);
|
||||
format!("<rate><timebase>{tb}</timebase><ntsc>{}</ntsc></rate>", if ntsc { "TRUE" } else { "FALSE" })
|
||||
}
|
||||
|
||||
/// A timecode from 0, as Premiere gives a sequence and every file.
|
||||
fn timecode(fps: f64) -> String {
|
||||
let drop = rate(fps).1;
|
||||
format!("<timecode>{}<string>{}</string><frame>0</frame><displayformat>{}</displayformat></timecode>", rate_xml(fps), if drop { "00;00;00;00" } else { "00:00:00:00" }, if drop { "DF" } else { "NDF" })
|
||||
}
|
||||
|
||||
/// A UUID-shaped id for the sequence, the same for the same name (FNV-1a over it, twice).
|
||||
fn uuid(name: &str) -> String {
|
||||
let h = |seed: u64| name.bytes().fold(seed, |k, b| (k ^ b as u64).wrapping_mul(0x100_0000_01b3));
|
||||
let (a, b) = (h(0xcbf2_9ce4_8422_2325), h(0x8422_2325_cbf2_9ce4));
|
||||
format!("{:08x}-{:04x}-4{:03x}-8{:03x}-{:012x}", a >> 32, (a >> 16) & 0xffff, a & 0xfff, (b >> 52) & 0xfff, b & 0xffff_ffff_ffff)
|
||||
}
|
||||
|
||||
/// Text as XML: its five reserved characters as entities.
|
||||
fn esc(s: &str) -> String {
|
||||
let mut out = String::with_capacity(s.len());
|
||||
for ch in s.chars() {
|
||||
match ch {
|
||||
'&' => out.push_str("&"),
|
||||
'<' => out.push_str("<"),
|
||||
'>' => out.push_str(">"),
|
||||
'"' => out.push_str("""),
|
||||
'\'' => out.push_str("'"),
|
||||
_ => out.push(ch),
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A file's path as xmeml's pathurl: file://localhost and the absolute path, each byte outside the unreserved set
|
||||
/// percent-encoded. A Windows path is made a URL as a path, not as text (#195: 0.1.8-rc8 wrote
|
||||
/// file://localhostD%3A%5CWork%5C..., which Resolve refused): a drive's is file:///D:/Work/clip.mp4, the form Resolve
|
||||
/// opened, and a share's file://nas/clips/clip.mp4, each with its separators as slashes and Windows' \\?\ prefix off.
|
||||
pub(crate) fn pathurl(p: &Path) -> String {
|
||||
let s = p.to_string_lossy();
|
||||
let s = match (s.strip_prefix(r"\\?\UNC\"), s.strip_prefix(r"\\?\")) {
|
||||
(Some(share), _) => format!(r"\\{share}"),
|
||||
(None, Some(local)) => local.to_string(),
|
||||
_ => s.into_owned(),
|
||||
};
|
||||
let b = s.as_bytes();
|
||||
let drive = b.len() >= 3 && b[0].is_ascii_alphabetic() && b[1] == b':' && matches!(b[2], b'\\' | b'/');
|
||||
let (mut out, rest, windows) = if drive {
|
||||
(format!("file:///{}:", b[0] as char), &b[2..], true)
|
||||
} else if let Some(share) = s.strip_prefix(r"\\") {
|
||||
(String::from("file://"), share.as_bytes(), true)
|
||||
} else {
|
||||
(String::from("file://localhost"), b, false)
|
||||
};
|
||||
for &c in rest {
|
||||
if windows && c == b'\\' {
|
||||
out.push('/');
|
||||
} else if c.is_ascii_alphanumeric() || b"/-_.~".contains(&c) {
|
||||
out.push(c as char);
|
||||
} else {
|
||||
let _ = write!(out, "%{c:02X}");
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Basic Motion's scale and centre and the crop's sides ([left, right, top, bottom], percent of the picture) for a
|
||||
/// picture drawn as `p` (plan::picture) from media of `mw` x `mh` (upright; `turned` when it's stored a quarter turn
|
||||
/// from that, a phone's take) on a `w` x `h` sequence, in `editor`'s terms (see units).
|
||||
pub fn motion(editor: Editor, p: &Picture, media: (f64, f64), turned: bool, frame: (f64, f64)) -> (f64, [f64; 2], [f64; 4]) {
|
||||
let [dx, dy, dw, dh] = p.drawn;
|
||||
let (cx, cy) = (dx + dw / 2.0 - frame.0 / 2.0, dy + dh / 2.0 - frame.1 / 2.0);
|
||||
let (whole, unit) = units(editor, media, turned, frame);
|
||||
let [l, t, r, b] = p.kept;
|
||||
(dw / whole * 100.0, [cx / unit.0, cy / unit.1], [l * 100.0, (1.0 - r) * 100.0, t * 100.0, (1.0 - b) * 100.0])
|
||||
}
|
||||
|
||||
/// An editor's units on the canvas, in px: the picture's width at Scale 100, and Center's 1 across and down, each the
|
||||
/// clip's own size at Scale 100 as that editor has it, read from what it did with what it was given (11-17).
|
||||
/// Premiere: the media's own pixels, Center in its width and height as the XML describes it, which is as stored
|
||||
/// (Premiere's own XML describes a phone's take 3840 x 2160 and wrote a 68 px move of it 68 / 2160; told 2160 x 3840 it
|
||||
/// placed -0.120370 at 462.2 px, 0.120370 of 3840). Resolve: the media fitted to the frame (its default Input Scaling,
|
||||
/// "scale entire image to fit": its own XML gave a 4K take on a smaller timeline Scale 100), Center in that fitted
|
||||
/// size too (a horizontal take fitted to a 1080 x 1920 frame is 1080 x 607.5: it placed Center vert -0.182 at 110 px).
|
||||
fn units(editor: Editor, (mw, mh): (f64, f64), turned: bool, (w, h): (f64, f64)) -> (f64, (f64, f64)) {
|
||||
match editor {
|
||||
Editor::Premiere if turned => (mw, (mh, mw)),
|
||||
Editor::Premiere => (mw, (mw, mh)),
|
||||
Editor::Resolve => {
|
||||
let fit = (w / mw).min(h / mh);
|
||||
(mw * fit, (mw * fit, mh * fit))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// An FCP7 parameter: its id and name, its range (none for Center's), its value and its keyframes (none when it holds).
|
||||
fn parameter(id: &str, name: &str, range: Option<(f64, f64)>, value: &str, keyframes: &str) -> String {
|
||||
let range = range.map_or(String::new(), |(a, b)| format!("<valuemin>{a}</valuemin><valuemax>{b}</valuemax>"));
|
||||
format!("<parameter><parameterid>{id}</parameterid><name>{name}</name>{range}<value>{value}</value>{keyframes}</parameter>")
|
||||
}
|
||||
|
||||
/// A parameter that holds one value, or (its values differing) is keyframed: its first value, then a keyframe at each
|
||||
/// of `at`'s whens, each value written by `value`. `range` is its (min, max), none for Center's.
|
||||
fn keyed<const N: usize>(id: &str, name: &str, range: Option<(f64, f64)>, at: &[(i64, [f64; N])], value: impl Fn(&[f64; N]) -> String) -> String {
|
||||
let values: Vec<String> = at.iter().map(|(_, p)| value(p)).collect();
|
||||
let first = &values[0];
|
||||
let keys: String = if values.iter().all(|v| v == first) {
|
||||
String::new()
|
||||
} else {
|
||||
at.iter().zip(&values).map(|((when, _), v)| format!("<keyframe><when>{when}</when><value>{v}</value></keyframe>")).collect()
|
||||
};
|
||||
parameter(id, name, range, first, &keys)
|
||||
}
|
||||
|
||||
/// A clip's filter of one FCP7 effect and its parameters (each effect here is its category's own type: motion, audio
|
||||
/// levels, audio pan).
|
||||
fn effect(name: &str, id: &str, category: &str, media: &str, params: &[String]) -> String {
|
||||
let mut out = format!("<filter><effect><name>{name}</name><effectid>{id}</effectid><effectcategory>{category}</effectcategory><effecttype>{category}</effecttype><mediatype>{media}</mediatype>");
|
||||
params.iter().for_each(|p| out.push_str(p));
|
||||
out.push_str("</effect></filter>");
|
||||
out
|
||||
}
|
||||
|
||||
/// Which editor an XML is for: they read xmeml alike but for crop (read from an XML each exported of a clip it
|
||||
/// keyframed, and from each one's render of a timeline cropping one picture stored four ways, 11-17). Premiere's crop
|
||||
/// is four parameters of Basic Motion (leftcrop, topcrop, rightcrop, bottomcrop), cutting the upright picture whatever
|
||||
/// its file's rotation. Resolve's is FCP7's Crop filter, which cuts the upright picture of a file stored upright, but
|
||||
/// one stored turned (a phone's take) mirrored: its top and bottom swapped at 90, its left and right at 270, both at
|
||||
/// 180 (Resolve 21.2.0's Cropping does the same in its Inspector). One file can't be both: an editor reading the other's
|
||||
/// crop too cuts twice.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Editor {
|
||||
Premiere,
|
||||
Resolve,
|
||||
}
|
||||
|
||||
impl Editor {
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
Editor::Premiere => "premiere",
|
||||
Editor::Resolve => "resolve",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The XML for `editor`, and what it can't carry. `dir` is where layers.json is: its movies' paths are relative to it.
|
||||
pub fn write(l: &Layers, dir: &Path, editor: Editor) -> (String, Vec<String>) {
|
||||
let mut notes = Vec::new();
|
||||
let fps = l.fps;
|
||||
let frames = |secs: f64| f64::round(secs * fps) as i64;
|
||||
let path = |k: usize| {
|
||||
let p = Path::new(&l.files[k].path);
|
||||
if p.is_absolute() { p.to_path_buf() } else { dir.join(p) }
|
||||
};
|
||||
let name_of = |k: usize| path(k).file_name().map_or_else(String::new, |n| n.to_string_lossy().into_owned());
|
||||
|
||||
// the tracks bottom first, xmeml's order; sounds apart, each sound track as one mono track a channel, as Premiere
|
||||
// writes a stereo clip: its left channel on one track, its right on the next, two clipitems linked
|
||||
let video: Vec<_> = l.tracks.iter().rev().filter(|t| t.layer != Layer::Sound).collect();
|
||||
let audio: Vec<_> = l.tracks.iter().filter(|t| t.layer == Layer::Sound).collect();
|
||||
let channels = |c: &Clip| l.files[c.file].channels.clamp(1, 2) as usize;
|
||||
let mut mono: Vec<Vec<(String, &Clip, usize)>> = Vec::new();
|
||||
for t in &audio {
|
||||
let base = mono.len();
|
||||
mono.resize_with(base + t.clips.iter().map(channels).max().unwrap_or(1), Vec::new);
|
||||
for c in &t.clips {
|
||||
for ch in 1..=channels(c) {
|
||||
mono[base + ch - 1].push((if ch == 1 { c.id.clone() } else { format!("{}-{ch}", c.id) }, c, ch));
|
||||
}
|
||||
}
|
||||
}
|
||||
// each clipitem's place: (video?, track index from 1, clip index from 1), for links
|
||||
let mut at: std::collections::HashMap<String, (bool, usize, usize)> = std::collections::HashMap::new();
|
||||
for (ti, t) in video.iter().enumerate() {
|
||||
for (ci, c) in t.clips.iter().enumerate() {
|
||||
at.insert(c.id.clone(), (true, ti + 1, ci + 1));
|
||||
}
|
||||
}
|
||||
for (ti, m) in mono.iter().enumerate() {
|
||||
for (ci, (id, _, _)) in m.iter().enumerate() {
|
||||
at.insert(id.clone(), (false, ti + 1, ci + 1));
|
||||
}
|
||||
}
|
||||
let by_id: std::collections::HashMap<&str, &Clip> = l.tracks.iter().flat_map(|t| t.clips.iter()).map(|c| (c.id.as_str(), c)).collect();
|
||||
// a clip's clipitems: footage's one, a sound's one a channel
|
||||
let items = |c: &Clip| -> Vec<String> { std::iter::once(c.id.clone()).chain((2..=2).map(|ch| format!("{}-{ch}", c.id))).filter(|id| at.contains_key(id)).collect() };
|
||||
// every clipitem of a clip and of the clip it's linked to, linked together (the video first), as Premiere links them
|
||||
let links = |c: &Clip| -> String {
|
||||
let mut all = items(c);
|
||||
if let Some(other) = c.link.as_deref().and_then(|o| by_id.get(o)) {
|
||||
all.extend(items(other));
|
||||
}
|
||||
if all.len() < 2 {
|
||||
return String::new();
|
||||
}
|
||||
all.sort_by_key(|id| (!at[id].0, at[id].1));
|
||||
all.iter()
|
||||
.map(|id| {
|
||||
let (v, ti, ci) = at[id];
|
||||
format!("<link><linkclipref>{id}</linkclipref><mediatype>{}</mediatype><trackindex>{ti}</trackindex><clipindex>{ci}</clipindex></link>", if v { "video" } else { "audio" })
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
// a file is described in full the first time a clip names it, by its id after; its sound a channel at a time
|
||||
let mut described = std::collections::HashSet::new();
|
||||
let mut file = |k: usize| -> String {
|
||||
let id = format!("file-{}", k + 1);
|
||||
if !described.insert(k) {
|
||||
return format!("<file id=\"{id}\"/>");
|
||||
}
|
||||
let f = &l.files[k];
|
||||
let mut media = String::new();
|
||||
if f.kind == FileKind::Video {
|
||||
// its size as stored for Premiere (a phone's take on its side, as Premiere's own XML describes it), upright
|
||||
// for Resolve, as each editor's Center is read in (see units)
|
||||
let (w, h) = if editor == Editor::Premiere && f.rotation % 180 == 90 { (f.height, f.width) } else { (f.width, f.height) };
|
||||
let _ = write!(media, "<video><samplecharacteristics>{}<width>{w}</width><height>{h}</height></samplecharacteristics></video>", rate_xml(fps));
|
||||
}
|
||||
if f.has_audio {
|
||||
let n = f.channels.clamp(1, 2);
|
||||
for ch in 1..=n {
|
||||
let label = match (n, ch) {
|
||||
(1, _) => "mono",
|
||||
(_, 1) => "left",
|
||||
_ => "right",
|
||||
};
|
||||
let _ = write!(media, "<audio><samplecharacteristics><depth>16</depth><samplerate>{}</samplerate></samplecharacteristics><channelcount>1</channelcount><layout>{}</layout><audiochannel><sourcechannel>{ch}</sourcechannel><channellabel>{label}</channellabel></audiochannel></audio>", f.sample_rate, if n == 1 { "mono" } else { "stereo" });
|
||||
}
|
||||
}
|
||||
format!("<file id=\"{id}\"><name>{}</name><pathurl>{}</pathurl>{}<duration>{}</duration>{}<media>{media}</media></file>", esc(&name_of(k)), pathurl(&path(k)), rate_xml(fps), frames(f.seconds), timecode(fps))
|
||||
};
|
||||
let clipitem = |id: &str, attrs: &str, c: &Clip, body: &str, file: String| -> String {
|
||||
let src_in = frames(c.source_in);
|
||||
format!(
|
||||
"<clipitem id=\"{id}\"{attrs}><masterclipid>masterclip-{}</masterclipid><name>{}</name><enabled>TRUE</enabled><duration>{}</duration>{}<start>{}</start><end>{}</end><in>{src_in}</in><out>{}</out>{file}{body}{}</clipitem>",
|
||||
c.file + 1,
|
||||
esc(&name_of(c.file)),
|
||||
frames(l.files[c.file].seconds),
|
||||
rate_xml(fps),
|
||||
c.start,
|
||||
c.end(),
|
||||
// its own speed (raea's isn't carried, said below): as many source frames as it lasts
|
||||
src_in + c.frames,
|
||||
links(c)
|
||||
)
|
||||
};
|
||||
|
||||
// Resolve fits footage of another size to the timeline by its project's Input Scaling before its Scale applies
|
||||
let other_size = |f: &crate::model::File| f.kind == FileKind::Video && (f.width, f.height) != (l.width, l.height);
|
||||
if editor == Editor::Resolve && l.tracks.iter().any(|t| t.layer == Layer::Footage && t.clips.iter().any(|c| other_size(&l.files[c.file]))) {
|
||||
notes.push("Resolve: footage not the timeline's size is placed for its default Input Scaling, \"Scale entire image to fit\" (Project Settings, Image Scaling); with another, set it back or re-place that footage".to_string());
|
||||
}
|
||||
let mut v = String::new();
|
||||
for t in &video {
|
||||
let _ = write!(v, "<track>");
|
||||
for c in &t.clips {
|
||||
let mut body = String::new();
|
||||
if (c.speed - 1.0).abs() > 0.001 {
|
||||
notes.push(format!("{} (frames {}-{}): plays at {:.2}x in raea; placed at its own speed", name_of(c.file), c.start, c.end() - 1, c.speed));
|
||||
}
|
||||
match (t.layer, c.r#box) {
|
||||
(Layer::Footage, Some(bx)) => {
|
||||
let f = &l.files[c.file];
|
||||
let fit = c.fit.as_deref().unwrap_or("fill");
|
||||
let turned = f.rotation % 180 == 90;
|
||||
let (media, frame) = ((f.width.max(1) as f64, f.height.max(1) as f64), (l.width as f64, l.height as f64));
|
||||
// its place at its first frame, or at each of its keys, each key's when in the source's frames (FCP7
|
||||
// times a clip's filters from its media: its in point is its first frame)
|
||||
let first = [Key { frame: 0, r#box: bx, clip: c.clip, position: c.position, opacity: c.opacity }];
|
||||
let at = if c.keys.is_empty() { &first[..] } else { &c.keys[..] };
|
||||
let src_in = frames(c.source_in);
|
||||
let mut placed: Vec<(i64, [f64; 8])> = Vec::with_capacity(at.len());
|
||||
let mut widest = [1.0f64, 1.0];
|
||||
for k in at {
|
||||
// (a picture object-fit: fill stretches is said with the layers: fitted inside its box here)
|
||||
let (p, _) = plan::picture(&k.r#box, &k.clip, fit, &k.position, media, frame);
|
||||
(widest[0], widest[1]) = (widest[0].max(p.drawn[2]), widest[1].max(p.drawn[3]));
|
||||
let (scale, centre, crop) = motion(editor, &p, media, turned, frame);
|
||||
placed.push((src_in + k.frame, [scale, centre[0], centre[1], crop[0], crop[1], crop[2], crop[3], k.opacity * 100.0]));
|
||||
}
|
||||
// a key a straight line between its neighbours gives to within a seventh of a pixel on the canvas
|
||||
// (the manifest's boxes are to a tenth) and half a percent of opacity (its to a whole percent), in
|
||||
// each value's own units
|
||||
let (whole, unit) = units(editor, media, turned, frame);
|
||||
let px = 0.15;
|
||||
let (cx, cy) = (px / widest[0] * 100.0, px / widest[1] * 100.0);
|
||||
let placed = plan::thin(&placed, &[px / whole * 100.0, px / unit.0, px / unit.1, cx, cx, cy, cy, 0.5]);
|
||||
let scale = keyed("scale", "Scale", Some((0.0, 1000.0)), &placed, |p| format!("{:.4}", p[0]));
|
||||
let centre = keyed("center", "Center", None, &placed, |p| format!("<horiz>{:.6}</horiz><vert>{:.6}</vert>", p[1], p[2]));
|
||||
// the crop's sides as each editor writes them, from motion's [left, right, top, bottom]
|
||||
let cut = placed.iter().any(|(_, p)| p[3..7].iter().any(|&k| k > 0.001));
|
||||
let side = |id: &str, name: &str, i: usize| keyed(id, name, Some((0.0, 100.0)), &placed, |p| format!("{:.4}", p[3 + i]));
|
||||
let mut motion = vec![scale, centre];
|
||||
if editor == Editor::Premiere && cut {
|
||||
motion.extend([("leftcrop", "Left", 0), ("topcrop", "Top", 2), ("rightcrop", "Right", 1), ("bottomcrop", "Bottom", 3)].iter().map(|&(id, n, i)| side(id, n, i)));
|
||||
}
|
||||
body.push_str(&effect("Basic Motion", "basic", "motion", "video", &motion));
|
||||
if editor == Editor::Resolve && cut {
|
||||
// Resolve's sides, mirrored as it mirrors a file stored turned (see Editor)
|
||||
let (lr, tb) = (matches!(f.rotation, 180 | 270), matches!(f.rotation, 90 | 180));
|
||||
let (l, r) = if lr { (1, 0) } else { (0, 1) };
|
||||
let (t, b) = if tb { (3, 2) } else { (2, 3) };
|
||||
let sides: Vec<String> = [("left", l), ("right", r), ("top", t), ("bottom", b)].iter().map(|&(n, i)| side(n, n, i)).collect();
|
||||
body.push_str(&effect("Crop", "crop", "motion", "video", &sides));
|
||||
}
|
||||
if placed.iter().any(|(_, p)| p[7] < 99.9) {
|
||||
body.push_str(&effect("Opacity", "opacity", "motion", "video", &[keyed("opacity", "opacity", Some((0.0, 100.0)), &placed, |p| format!("{:.2}", p[7]))]));
|
||||
}
|
||||
}
|
||||
// a layer's movie fills the frame, its alpha straight
|
||||
_ => body.push_str("<alphatype>straight</alphatype>"),
|
||||
}
|
||||
let _ = write!(v, "{}", clipitem(&c.id, "", c, &body, file(c.file)));
|
||||
}
|
||||
let _ = write!(v, "<enabled>TRUE</enabled><locked>FALSE</locked></track>");
|
||||
}
|
||||
let mut a = String::new();
|
||||
for (ti, m) in mono.iter().enumerate() {
|
||||
// a stereo pair's left track goes to output channel 1, its right to 2
|
||||
// which side of a stereo pair the track is: 1 left, 2 right; none for a mono file's own track
|
||||
let side = if m.iter().any(|(_, _, ch)| *ch == 2) { Some(2) } else if mono.get(ti + 1).is_some_and(|n| n.iter().any(|(_, _, ch)| *ch == 2)) { Some(1) } else { None };
|
||||
let out = side.map_or(String::new(), |k| format!("<outputchannelindex>{k}</outputchannelindex>"));
|
||||
let _ = write!(a, "<track currentExplodedTrackIndex=\"0\" totalExplodedTrackCount=\"1\" premiereTrackType=\"Mono\">");
|
||||
for (id, c, ch) in m {
|
||||
let gain = 10f64.powf(c.gain_db / 20.0);
|
||||
let mut body = format!("<sourcetrack><mediatype>audio</mediatype><trackindex>{ch}</trackindex></sourcetrack>");
|
||||
if (gain - 1.0).abs() > 1e-6 {
|
||||
body.push_str(&effect("Audio Levels", "audiolevels", "audiolevels", "audio", &[parameter("level", "Level", Some((0.00003162, 31.6228)), &format!("{gain:.6}"), "")]));
|
||||
}
|
||||
// a stereo file's channel panned to its own side, as FCP7's Audio Pan on the clip (-1 left, 1 right): Premiere
|
||||
// and Resolve both import each channel centred without it, and both read it (heard 11-16); a mono file's
|
||||
// stays centred
|
||||
if channels(c) == 2 {
|
||||
body.push_str(&effect("Audio Pan", "audiopan", "audiopan", "audio", &[parameter("pan", "Pan", Some((-1.0, 1.0)), if *ch == 1 { "-1" } else { "1" }, "")]));
|
||||
}
|
||||
if *ch == 1 && (c.speed - 1.0).abs() > 0.001 {
|
||||
notes.push(format!("{} (frames {}-{}): plays at {:.2}x in raea; placed at its own speed", name_of(c.file), c.start, c.end() - 1, c.speed));
|
||||
}
|
||||
if *ch == 1 && (c.fade_in > 0.0 || c.fade_out > 0.0) {
|
||||
notes.push(format!("{} (frames {}-{}): its fades ({:.2} s in, {:.2} s out) aren't carried; set them in the editor", name_of(c.file), c.start, c.end() - 1, c.fade_in, c.fade_out));
|
||||
}
|
||||
let _ = write!(a, "{}", clipitem(id, " premiereChannelType=\"mono\"", c, &body, file(c.file)));
|
||||
}
|
||||
let _ = write!(a, "<enabled>TRUE</enabled><locked>FALSE</locked>{out}</track>");
|
||||
}
|
||||
let format = format!("<format><samplecharacteristics>{}<width>{}</width><height>{}</height><pixelaspectratio>square</pixelaspectratio><anamorphic>FALSE</anamorphic><fielddominance>none</fielddominance></samplecharacteristics></format>", rate_xml(fps), l.width, l.height);
|
||||
let xml = format!(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE xmeml>\n<xmeml version=\"5\"><sequence id=\"sequence-1\" explodedTracks=\"true\"><uuid>{}</uuid><name>{}</name><duration>{}</duration>{}{}<media><video>{format}{v}</video><audio><numOutputChannels>2</numOutputChannels><format><samplecharacteristics><depth>16</depth><samplerate>48000</samplerate></samplecharacteristics></format><outputs><group><index>1</index><numchannels>1</numchannels><downmix>0</downmix><channel><index>1</index></channel></group><group><index>2</index><numchannels>1</numchannels><downmix>0</downmix><channel><index>2</index></channel></group></outputs>{a}</audio></media></sequence></xmeml>\n",
|
||||
uuid(&l.name),
|
||||
esc(&l.name),
|
||||
l.frames,
|
||||
rate_xml(fps),
|
||||
timecode(fps),
|
||||
);
|
||||
(xml, notes)
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
use super::*;
|
||||
|
||||
/// The decoder's own planes (NV12: luma, then Cb Cr interleaved at half size), as ffmpeg's filters see a 4:2:0 frame.
|
||||
pub(crate) fn yuv(f: Frame) -> (Vec<u8>, Vec<u8>, Vec<u8>) {
|
||||
pub fn yuv(f: Frame) -> (Vec<u8>, Vec<u8>, Vec<u8>) {
|
||||
let n = (f.width * f.height) as usize;
|
||||
let mut buf = f.rgba;
|
||||
let uv = buf.split_off(n.min(buf.len()));
|
||||
@@ -18,20 +18,20 @@ pub(crate) fn sad(a: &[u8], b: &[u8]) -> u64 {
|
||||
/// Samples from `from` to `to` at `fps` (the source's frames when `fps` is its rate): each tick's time, and the time
|
||||
/// to read, the last frame before the middle of the tick, as ffmpeg's fps filter picks it (at 6 fps from 30, tick 0 is
|
||||
/// source frame 2 and tick 1 frame 7).
|
||||
pub(crate) fn times(duration: f64, from: Option<f64>, to: Option<f64>, fps: f64) -> Vec<(f64, f64)> {
|
||||
pub fn times(duration: f64, from: Option<f64>, to: Option<f64>, fps: f64) -> Vec<(f64, f64)> {
|
||||
let (a, b) = (from.unwrap_or(0.0).max(0.0), to.unwrap_or(duration).min(duration));
|
||||
let n = ((b - a) * fps).round().max(0.0) as usize;
|
||||
(0..n).map(|i| (a + i as f64 / fps, a + (i as f64 + 0.5) / fps - 1e-6)).collect()
|
||||
}
|
||||
|
||||
/// The video's own duration: its track's (what ffmpeg's filters run to), else the decoder's.
|
||||
pub(crate) fn video_span(path: &Path, info: &Info) -> f64 {
|
||||
pub fn video_span(path: &Path, info: &Info) -> f64 {
|
||||
video_track(path).map(|t| t.duration).unwrap_or(info.duration)
|
||||
}
|
||||
|
||||
/// How much the picture changes: the mean absolute luma difference between samples `fps` apart (signalstats YDIF).
|
||||
pub fn motion(path: &Path, from: Option<f64>, to: Option<f64>, fps: f64) -> R<(Value, Vec<(f64, f64)>)> {
|
||||
let mut d = backend()?.open_video(path)?;
|
||||
let mut d = open_video(path)?;
|
||||
let ts = times(video_span(path, d.info()), from, to, fps);
|
||||
let mut prev: Option<Vec<u8>> = None;
|
||||
let mut out = Vec::new();
|
||||
@@ -48,7 +48,7 @@ pub fn motion(path: &Path, from: Option<f64>, to: Option<f64>, fps: f64) -> R<(V
|
||||
/// Shot changes: ffmpeg's scene score (select's get_scene_score: the mean absolute luma difference from the frame before,
|
||||
/// against the change in it since the frame before that, over 100) above `threshold`, frame by frame.
|
||||
pub fn cuts(path: &Path, threshold: f64, from: Option<f64>, to: Option<f64>) -> R<(Value, Vec<(usize, f64, f64)>)> {
|
||||
let mut d = backend()?.open_video(path)?;
|
||||
let mut d = open_video(path)?;
|
||||
let info = d.info().clone();
|
||||
// every frame the file holds, at its own time (a variable-rate take has no fixed step)
|
||||
let ts = frames_of(path, &info, from, to);
|
||||
@@ -75,7 +75,7 @@ pub fn cuts(path: &Path, threshold: f64, from: Option<f64>, to: Option<f64>) ->
|
||||
}
|
||||
|
||||
/// Every frame the file holds as (tick, time to read): its own times when the file states them, else a fixed step.
|
||||
pub(crate) fn frames_of(path: &Path, info: &Info, from: Option<f64>, to: Option<f64>) -> Vec<(f64, f64)> {
|
||||
pub fn frames_of(path: &Path, info: &Info, from: Option<f64>, to: Option<f64>) -> Vec<(f64, f64)> {
|
||||
match video_track(path) {
|
||||
Some(t) => t.pts.iter().filter(|p| from.is_none_or(|a| **p >= a - 1e-6) && to.is_none_or(|b| **p < b)).map(|p| (*p, *p + 1e-4)).collect(),
|
||||
None => times(info.duration, from, to, info.fps),
|
||||
@@ -86,7 +86,7 @@ pub(crate) fn frames_of(path: &Path, info: &Info, from: Option<f64>, to: Option<
|
||||
/// over every plane, as a fraction of full scale); a stretch at or under `noise` lasting `min` seconds or more is a
|
||||
/// freeze, reported as (start, Some((duration, end))) when it ends, or (start, None) when the file ends frozen.
|
||||
pub fn freezes(path: &Path, noise: f64, min: f64) -> R<Vec<(f64, Option<(f64, f64)>)>> {
|
||||
let mut d = backend()?.open_video(path)?;
|
||||
let mut d = open_video(path)?;
|
||||
let info = d.info().clone();
|
||||
let mut reference: Option<(f64, Vec<u8>, Vec<u8>, Vec<u8>)> = None;
|
||||
let mut frozen_now = false;
|
||||
|
||||
@@ -53,7 +53,7 @@ fn run(args: Vec<String>) {
|
||||
"render" => {
|
||||
let out = PathBuf::from(flag("-o").unwrap_or_else(|| fail("render needs -o OUT.mp4|DIR")));
|
||||
let frames = flag("--at").map(|at| at.split(',').map(|f| f.trim().parse().unwrap_or_else(|_| fail(format!("bad frame {f}")))).collect());
|
||||
let opts = raea_runtime_encode::RenderOpts { frames, codec: flag("--codec"), kbps: flag("--kbps").and_then(|k| k.parse().ok()), quality: flag("--quality").map(|q| raea_io_media::parse_quality(&q).unwrap_or_else(|e| fail(e))), ssim: flag_on("--ssim"), sound: None, ten_bit: flag_on("--10bit"), alpha: flag_on("--alpha") };
|
||||
let opts = raea_runtime_encode::RenderOpts { frames, codec: flag("--codec"), kbps: flag("--kbps").and_then(|k| k.parse().ok()), quality: flag("--quality").map(|q| raea_io_media::parse_quality(&q).unwrap_or_else(|e| fail(e))), ssim: flag_on("--ssim"), sound: None, ten_bit: flag_on("--10bit"), alpha: flag_on("--alpha"), ..Default::default() };
|
||||
if opts.alpha && out.extension().is_some_and(|x| x != "png") {
|
||||
fail("--alpha writes PNGs (OUT.png or a folder): video here is H.264 or HEVC, which hold no alpha");
|
||||
}
|
||||
|
||||
+20
-2
@@ -3,7 +3,8 @@
|
||||
//!
|
||||
//! raea media probe FILE duration, size, fps, codec, audio (JSON)
|
||||
//! raea media still FILE --at S [--width W] -o OUT.png|.jpg the frame showing at S (an image: itself), W px wide at most
|
||||
//! raea media sheet FILE... [--n 12] [--width 240] -o OUT a contact sheet (n frames of one file, or each file's middle)
|
||||
//! raea media sheet FILE... [--n 12] [--width 240] -o OUT a contact sheet (n frames of one file, or each file's middle),
|
||||
//! and OUT.labels.json: each cell's time or file, for raea show
|
||||
//! raea media audio FILE [--rate 16000] [--mono] [--from S --to S] -o OUT.wav|- (- is f32le on stdout)
|
||||
//! raea media loudness FILE [--from S --to S] integrated LUFS, mean and peak dB, true peak
|
||||
//! raea media motion FILE [--from S --to S] [--fps 6] how much the picture changes (mean luma difference, YDIF)
|
||||
@@ -44,10 +45,12 @@ use encode::*;
|
||||
mod ff;
|
||||
use ff::*;
|
||||
mod frames;
|
||||
/// what `raea check` reads natively where there's no FFmpeg (apps/check read.rs)
|
||||
pub use {change::{frames_of, freezes, times, video_span, yuv}, probe::{probe_of, standard_fps}, sound::audio_folded};
|
||||
|
||||
type R<T> = Result<T, String>;
|
||||
|
||||
fn backend() -> R<Box<dyn Backend>> {
|
||||
pub fn backend() -> R<Box<dyn Backend>> {
|
||||
raea_io_media::backend(&raea_sys_frame::media_backend())
|
||||
}
|
||||
|
||||
@@ -55,6 +58,21 @@ fn soft() -> R<Box<dyn Backend>> {
|
||||
raea_io_media::backend("soft")
|
||||
}
|
||||
|
||||
/// A video's decoder from the first backend that reads it (raea_io_media::preferred: RAEA_MEDIA's, the platform's, the
|
||||
/// portable one, then FFmpeg), so a video the platform's decoder can't read is read through FFmpeg: off a Mac, H.264
|
||||
/// with B-frames, HEVC and VP9 (on Windows raea fetches its own FFmpeg the first time). Each backend's refusal is kept
|
||||
/// for the error.
|
||||
pub fn open_video(path: &Path) -> R<Box<dyn raea_io_media::VideoDecoder>> {
|
||||
let mut why = Vec::new();
|
||||
for b in raea_io_media::preferred() {
|
||||
match b.open_video(path) {
|
||||
Ok(d) => return Ok(d),
|
||||
Err(e) => why.push(format!("{}: {e}", b.name())),
|
||||
}
|
||||
}
|
||||
Err(format!("{}: no backend reads it ({})", path.display(), why.join("; ")))
|
||||
}
|
||||
|
||||
const IMAGE_EXTS: &[&str] = &["png", "jpg", "jpeg", "webp", "gif", "bmp", "tif", "tiff"];
|
||||
const SWITCHES: &[&str] = &["mono"];
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ pub(crate) fn save(img: &image::RgbaImage, out: &Path) -> R<()> {
|
||||
|
||||
/// The frame showing at `t` (the last frame when `t` is past the end).
|
||||
pub(crate) fn frame(path: &Path, t: f64) -> R<image::RgbaImage> {
|
||||
let mut d = backend()?.open_video(path)?;
|
||||
let mut d = open_video(path)?;
|
||||
let dur = d.info().duration;
|
||||
let t = t.clamp(0.0, (dur - 0.5 / d.info().fps.max(1.0)).max(0.0));
|
||||
to_image(d.frame_at(t)?)
|
||||
@@ -68,7 +68,51 @@ pub fn sheet(files: &[PathBuf], n: usize, w: u32, out: &Path) -> R<Value> {
|
||||
image::imageops::overlay(&mut sheet, &small, ((k as u32 % cols) * w) as i64, ((k as u32 / cols) * th) as i64);
|
||||
}
|
||||
save(&sheet, out)?;
|
||||
Ok(json!({"wrote": out, "tiles": tiles.len(), "at": tiles.iter().map(|(t, _)| round3(*t)).collect::<Vec<_>>(), "width": sheet.width(), "height": sheet.height()}))
|
||||
// OUT.labels.json beside it (docs/callouts.feature CO2c): each cell says what it is, so raea show OUT.png labels them
|
||||
let heights: Vec<u32> = tiles.iter().map(|(_, i)| (i.height() as f64 * w as f64 / i.width() as f64).round().max(1.0) as u32).collect();
|
||||
let texts: Vec<String> = if files.len() == 1 { tiles.iter().map(|(t, _)| clock(*t)).collect() } else { files.iter().map(|f| f.file_name().unwrap_or_default().to_string_lossy().into_owned()).collect() };
|
||||
let labels = out.with_extension("labels.json");
|
||||
std::fs::write(&labels, serde_json::to_string_pretty(&json!({"labels": cell_labels(&texts, &heights, w, th, cols, rows)})).unwrap_or_default()).map_err(|e| format!("{}: {e}", labels.display()))?;
|
||||
Ok(json!({"wrote": out, "labels": labels, "tiles": tiles.len(), "at": tiles.iter().map(|(t, _)| round3(*t)).collect::<Vec<_>>(), "width": sheet.width(), "height": sheet.height()}))
|
||||
}
|
||||
|
||||
/// Each cell's label: its text and its box in the sheet's own 0-1 (a cell `w` wide, its picture `heights[k]` tall in a row
|
||||
/// `th` tall), in the sheet's order, left to right then down.
|
||||
fn cell_labels(texts: &[String], heights: &[u32], w: u32, th: u32, cols: u32, rows: u32) -> Vec<Value> {
|
||||
let (sw, sh) = ((cols * w) as f64, (rows * th) as f64);
|
||||
let r4 = |v: f64| (v * 1e4).round() / 1e4;
|
||||
texts.iter().zip(heights).enumerate().map(|(k, (text, h))| {
|
||||
let (x, y) = (((k as u32 % cols) * w) as f64, ((k as u32 / cols) * th) as f64);
|
||||
json!({"text": text, "box": [r4(x / sw), r4(y / sh), r4((x + w as f64) / sw), r4((y + *h as f64) / sh)]})
|
||||
}).collect()
|
||||
}
|
||||
|
||||
/// A moment as a cell's tag: 0:03.2, 1:05.0
|
||||
fn clock(t: f64) -> String {
|
||||
let d = (t.max(0.0) * 10.0).round() as u64;
|
||||
format!("{}:{:04.1}", d / 600, (d % 600) as f64 / 10.0)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod sheet_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_sheets_cells_are_labelled_by_their_boxes() {
|
||||
// five cells, four across: the second row's one cell, a shorter picture than its row
|
||||
let texts: Vec<String> = ["a", "b", "c", "d", "e"].map(String::from).to_vec();
|
||||
let l = cell_labels(&texts, &[135, 135, 135, 135, 90], 240, 135, 4, 2);
|
||||
assert_eq!(l[0], json!({"text": "a", "box": [0.0, 0.0, 0.25, 0.5]}));
|
||||
assert_eq!(l[3], json!({"text": "d", "box": [0.75, 0.0, 1.0, 0.5]}));
|
||||
assert_eq!(l[4], json!({"text": "e", "box": [0.0, 0.5, 0.25, 0.8333]}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_moment_reads_as_a_clock() {
|
||||
assert_eq!(clock(3.24), "0:03.2");
|
||||
assert_eq!(clock(59.96), "1:00.0");
|
||||
assert_eq!(clock(65.0), "1:05.0");
|
||||
}
|
||||
}
|
||||
|
||||
// ---- sound
|
||||
@@ -27,7 +27,9 @@ pub fn probe_of(path: &Path) -> R<Probe> {
|
||||
return Ok(Probe { kind: "image", video: None, audio: None, image: Some((w, h)), duration: 0.0, bytes, track: None });
|
||||
}
|
||||
let track = video_track(path);
|
||||
let video = backend()?.open_video(path).ok().map(|d| d.info().clone()).filter(|i| i.width > 0 && i.frames > 0).map(|mut i| {
|
||||
let opened = open_video(path);
|
||||
let why = opened.as_ref().err().cloned();
|
||||
let video = opened.ok().map(|d| d.info().clone()).filter(|i| i.width > 0 && i.frames > 0).map(|mut i| {
|
||||
// the file's own timing over what the decoder counted
|
||||
if let Some(t) = &track {
|
||||
i.duration = t.duration;
|
||||
@@ -38,7 +40,9 @@ pub fn probe_of(path: &Path) -> R<Probe> {
|
||||
});
|
||||
let audio = soft()?.decode_audio(path).ok().filter(|a| a.len() > 0).map(|a| (a.rate, a.channels.len(), a.duration()));
|
||||
if video.is_none() && audio.is_none() {
|
||||
return Err(format!("{}: no picture or sound raea can read", path.display()));
|
||||
// what each backend said about the picture: a missing FFmpeg, a codec none of them reads
|
||||
let why = why.map(|w| format!(" ({})", w.split_once(": no backend reads it (").map_or(w.as_str(), |(_, r)| r.trim_end_matches(')')).to_string())).unwrap_or_default();
|
||||
return Err(format!("{}: no picture or sound raea can read{why}", path.display()));
|
||||
}
|
||||
// the container's own duration when it says one (ffprobe's format duration), else the longest stream
|
||||
let duration = container_duration(path).unwrap_or_else(|| video.as_ref().map(|v| v.duration).unwrap_or(0.0).max(audio.map(|a| a.2).unwrap_or(0.0)));
|
||||
@@ -270,7 +274,7 @@ pub fn probe(path: &Path) -> R<Value> {
|
||||
|
||||
/// A measured frame rate (frames over duration) snapped to the standard rate it is within 1% of: a phone's variable-rate
|
||||
/// take that averages 23.92 is 24 (ffprobe's avg_frame_rate says 24/1).
|
||||
pub(crate) fn standard_fps(fps: f64) -> f64 {
|
||||
pub fn standard_fps(fps: f64) -> f64 {
|
||||
let rates = [24000.0 / 1001.0, 24.0, 25.0, 30000.0 / 1001.0, 30.0, 48.0, 50.0, 60000.0 / 1001.0, 60.0, 120.0];
|
||||
// the nearest, within 1% (30 is 30, not 29.97)
|
||||
rates.into_iter().filter(|r| (fps - r).abs() / r < 0.01).min_by(|a, b| (fps - a).abs().total_cmp(&(fps - b).abs())).unwrap_or(fps)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "raea-app-motion"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "`raea motion` and `raea setup motion`: body motion made by Kimodo on this machine, on MLX on a Mac, on PyTorch elsewhere"
|
||||
|
||||
[dependencies]
|
||||
# raea's models folder, where the models and the PyTorch environment go
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
serde_json = "1"
|
||||
# the verbs' flags read as a render reads its own
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
# Kimodo on MLX on a Mac, on PyTorch elsewhere (raea-sys-kimodo's torch.rs, plain Rust that runs the environment it makes)
|
||||
raea-sys-kimodo = { path = "../../systems/kimodo" }
|
||||
@@ -0,0 +1,268 @@
|
||||
//! `raea motion "LINE" [--keys KEYS.json] ...`: body motion made on this machine by Kimodo (raea-sys-kimodo): a SOMA clip
|
||||
//! from a line of words and, with --keys, Kimodo constraints (full-body keyframes, hand or foot targets, a root path:
|
||||
//! what sdk/body/tools/between.ts writes). The clip is the file sdk/body/tools/fromkimodo.ts reads, the same one the
|
||||
//! cloud runner wrote (docs/character.feature CH15b, CH15c).
|
||||
//!
|
||||
//! Which backend makes it is the machine's: MLX on a Mac (Apple silicon), PyTorch elsewhere (Linux, Windows), in the
|
||||
//! environment `raea setup motion` makes (raea-sys-kimodo torch.rs). Both hand decode.rs the sampler's features, so
|
||||
//! both write one file; their noise differs, so a seed is a different take on each.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use raea_runtime_bundle::flag;
|
||||
|
||||
type R<T> = Result<T, String>;
|
||||
|
||||
pub const USAGE: &str = "raea motion \"LINE\" [--keys KEYS.json] [--seconds 5 | --frames N] [--seed 1] [--steps 100] [-o CLIP.json]";
|
||||
pub const ABOUT: &str = "body motion made on this machine by Kimodo (NVIDIA): a SOMA clip from a line of words and, with --keys, Kimodo constraints (full-body keyframes, hand or foot targets, a root path, as sdk/body/tools/between.ts writes them), as the clip sdk/body/tools/fromkimodo.ts reads. On a Mac it runs on MLX (Apple silicon's GPU): the first use fetches the motion model (1.1 GB) into raea's models folder, and the first new line its text encoder (8.8 GB: Llama 3 8B in 8 bits with LLM2Vec's adapters). On Linux and Windows it runs upstream Kimodo on PyTorch, set up once by raea setup motion: on an NVIDIA GPU with CUDA (the text encoder, 16 GB in bf16, on the CPU unless the card has 18 GB or more), else on the CPU alone; reading a new line on the CPU takes about 18 GB of memory. A line's words are read once and kept. Licences: Kimodo's weights NVIDIA's Open Model License, Meta Llama 3 the Meta Llama 3 Community License, LLM2Vec's adapters MIT, Kimodo's code Apache-2.0";
|
||||
|
||||
pub const SETUP_USAGE: &str = "raea setup motion [--check]";
|
||||
pub const SETUP_ABOUT: &str = "what raea motion runs on, made where missing (--check only says): on a Mac the MLX models in raea's models folder (the motion model 1.1 GB, the text encoder 8.8 GB); on Linux and Windows, in raea's models folder's kimodo-torch, a Python 3.11 environment made by uv (which it needs on PATH: https://docs.astral.sh/uv) with PyTorch (its CUDA build where there is an NVIDIA driver, about 8 GB, else CPU only, about 2 GB) and upstream Kimodo (nv-tlabs/kimodo at e1c219c, Apache-2.0), then the weights: Kimodo-SOMA-RP-v1 (1.1 GB, NVIDIA Open Model License), LLM2Vec's two adapters (0.3 GB, MIT) and Meta Llama 3 8B Instruct in bf16 (16 GB, Meta Llama 3 Community License, from NousResearch's ungated copy, checked file by file against Meta's SHA-256); about 26 GB in all. It says what this machine has and where each network runs: the denoiser on CUDA when there is an NVIDIA GPU, else the CPU; the text encoder beside it on a GPU of 18 GB or more, else the CPU";
|
||||
|
||||
fn number(args: &[String], name: &str, default: f64) -> R<f64> {
|
||||
match flag(args, name) {
|
||||
None => Ok(default),
|
||||
Some(v) => v.parse::<f64>().ok().filter(|n| n.is_finite() && *n >= 0.0).ok_or(format!("{name} takes a number, got `{v}`")),
|
||||
}
|
||||
}
|
||||
|
||||
fn line(args: &[String]) -> String {
|
||||
const WITH_VALUE: [&str; 6] = ["--keys", "--seconds", "--frames", "--seed", "--steps", "-o"];
|
||||
let mut out = Vec::new();
|
||||
let mut i = 1;
|
||||
while i < args.len() {
|
||||
if WITH_VALUE.contains(&args[i].as_str()) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
if !args[i].starts_with("--") {
|
||||
out.push(args[i].as_str());
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
out.join(" ")
|
||||
}
|
||||
|
||||
/// what a call asks for, read from its words and flags
|
||||
struct Ask {
|
||||
words: String,
|
||||
keys: Option<String>,
|
||||
constraints: Option<serde_json::Value>,
|
||||
frames: usize,
|
||||
seed: u64,
|
||||
steps: usize,
|
||||
out: Option<String>,
|
||||
}
|
||||
|
||||
pub fn motion(args: &[String]) -> R<String> {
|
||||
let words = line(args);
|
||||
let keys = flag(args, "--keys");
|
||||
if words.trim().is_empty() && keys.is_none() {
|
||||
return Err(format!("{USAGE}\n ({ABOUT})"));
|
||||
}
|
||||
let frames = match flag(args, "--frames") {
|
||||
Some(_) => number(args, "--frames", 150.0)? as usize,
|
||||
None => (number(args, "--seconds", 5.0)? * 30.0).round() as usize,
|
||||
};
|
||||
if !(2..=600).contains(&frames) {
|
||||
return Err(format!("a clip is 2 to 600 frames (20 s at 30 a second), asked {frames}"));
|
||||
}
|
||||
let constraints = match &keys {
|
||||
Some(p) => Some(serde_json::from_str::<serde_json::Value>(&std::fs::read_to_string(p).map_err(|e| format!("{p}: {e}"))?).map_err(|e| format!("{p}: {e}"))?),
|
||||
None => None,
|
||||
};
|
||||
let (seed, steps) = (number(args, "--seed", 1.0)? as u64, (number(args, "--steps", 100.0)? as usize).max(2));
|
||||
make(Ask { words, keys, constraints, frames, seed, steps, out: flag(args, "-o") })
|
||||
}
|
||||
|
||||
/// -o, else a file named by the line's words in the working folder
|
||||
fn out_path(out: Option<String>, clean: &str) -> PathBuf {
|
||||
PathBuf::from(out.unwrap_or_else(|| {
|
||||
let slug = clean.split(|c: char| !c.is_ascii_alphanumeric()).filter(|w| !w.is_empty()).map(str::to_lowercase).collect::<Vec<_>>().join("-");
|
||||
format!("{}.clip.json", if slug.is_empty() { "keys".to_string() } else { slug.chars().take(60).collect() })
|
||||
}))
|
||||
}
|
||||
|
||||
/// how far the hips end from where they start, on the ground
|
||||
fn travel(m: &raea_sys_kimodo::decode::Motion) -> f32 {
|
||||
let r = &m.root;
|
||||
let (a, b) = (r[0], r[r.len() - 1]);
|
||||
((b[0] - a[0]).powi(2) + (b[2] - a[2]).powi(2)).sqrt()
|
||||
}
|
||||
|
||||
/// Kimodo's PyTorch environment: raea's models folder's kimodo-torch
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn torch_env() -> raea_sys_kimodo::torch::Torch {
|
||||
raea_sys_kimodo::torch::Torch::at(raea_io_home::models().join("kimodo-torch"))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn make(ask: Ask) -> R<String> {
|
||||
use raea_sys_kimodo::{decode, skeleton::Skeleton, stats::Stats, torch};
|
||||
let t = torch_env();
|
||||
let missing = t.missing();
|
||||
if !missing.is_empty() {
|
||||
return Err(format!(
|
||||
"raea motion runs Kimodo on PyTorch on this machine (MLX is Apple silicon's), and its {} isn't set up in {} yet: raea setup motion makes it (uv, then about 26 GB: PyTorch, Kimodo's code and weights, Llama 3 8B Instruct for the text encoder)",
|
||||
missing.join(", the "),
|
||||
t.dir.display()
|
||||
));
|
||||
}
|
||||
let keys = ask.keys.as_ref().map(std::path::Path::new);
|
||||
let job = torch::Job { line: &ask.words, frames: ask.frames, seed: ask.seed, steps: ask.steps, keys, cfg: (2.0, 2.0) };
|
||||
let made = t.make(&job).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let (stats, sk) = (Stats::load(&t.checkpoint).map_err(|e| format!("raea motion: {e}"))?, Skeleton::soma().map_err(|e| format!("raea motion: {e}"))?);
|
||||
let motion = decode::decode(&made.features, &stats, &sk);
|
||||
let info = &made.info;
|
||||
let clean = info["line"].as_str().unwrap_or(&ask.words).to_string();
|
||||
let (dev, text_dev) = (info["motion"].as_str().unwrap_or("?"), info["text"].as_str().unwrap_or("?"));
|
||||
let on = match info["gpu"].as_str().filter(|_| dev == "cuda") {
|
||||
Some(g) => format!("on PyTorch {} with CUDA ({g}; the text encoder on {text_dev}), upstream nv-tlabs/kimodo {}", info["torch"].as_str().unwrap_or("?"), &torch::KIMODO[..7]),
|
||||
None => format!("on PyTorch {} on the CPU, upstream nv-tlabs/kimodo {}", info["torch"].as_str().unwrap_or("?"), &torch::KIMODO[..7]),
|
||||
};
|
||||
let clip = decode::clip_json_on(&motion, &sk, ask.seed, ask.steps, &clean, ask.constraints.is_some(), &on);
|
||||
let out = out_path(ask.out, &clean);
|
||||
std::fs::write(&out, serde_json::to_string(&clip).unwrap_or_default()).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
// the hips as PyTorch decoded them against decode.rs's: the features were read as Kimodo wrote them
|
||||
let ours: Vec<[f32; 3]> = motion.joints77.iter().map(|f| f[0]).collect();
|
||||
let gap = torch::root_gap(&info["root"], &ours).map(|g| format!(", decoded here within {:.3} mm of PyTorch's own", g * 1000.0)).unwrap_or_default();
|
||||
let f = |k: &str| info[k].as_f64().unwrap_or(0.0);
|
||||
let read = if f("read_s") > 0.0 { format!(", reading the line {:.1} s after {:.1} s loading its encoder", f("read_s"), f("text_load_s")) } else { String::new() };
|
||||
Ok(format!(
|
||||
"APPLIED motion {:?}{}, {} frames ({:.1} s), seed {}, {} steps -> {} (made {on} in {:.1} s after {:.1} s loading{read}; the hips end {:.2} m from where they start{gap})",
|
||||
clean,
|
||||
if ask.keys.is_some() { " with keys" } else { "" },
|
||||
ask.frames,
|
||||
ask.frames as f64 / 30.0,
|
||||
ask.seed,
|
||||
ask.steps,
|
||||
out.display(),
|
||||
f("gen_s"),
|
||||
f("load_s"),
|
||||
travel(&motion),
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn make(ask: Ask) -> R<String> {
|
||||
// float32 as checked against PyTorch: MLX's TF32 matmuls off, before the first one
|
||||
if std::env::var_os("MLX_ENABLE_TF32").is_none() {
|
||||
unsafe { std::env::set_var("MLX_ENABLE_TF32", "0") };
|
||||
}
|
||||
let t0 = std::time::Instant::now();
|
||||
let mut progress = fetching();
|
||||
let mut k = raea_sys_kimodo::Kimodo::fetch(&mut progress).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let (clean, emb) = k.encode(&ask.words).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let load_s = t0.elapsed().as_secs_f64();
|
||||
let made_from = raea_sys_kimodo::Ask { line: &ask.words, frames: ask.frames, seed: ask.seed, steps: ask.steps, constraints: ask.constraints.as_ref(), cfg: (2.0, 2.0) };
|
||||
let t1 = std::time::Instant::now();
|
||||
let made = k.make(&made_from, emb.as_deref(), None).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let gen_s = t1.elapsed().as_secs_f64();
|
||||
let clip = raea_sys_kimodo::decode::clip_json(&made.motion, &k.skeleton, ask.seed, ask.steps, &clean, ask.constraints.is_some());
|
||||
let out = out_path(ask.out, &clean);
|
||||
std::fs::write(&out, serde_json::to_string(&clip).unwrap_or_default()).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
Ok(format!(
|
||||
"APPLIED motion {:?}{}, {} frames ({:.1} s), seed {}, {} steps -> {} (made on this Mac in {gen_s:.1} s after {load_s:.1} s loading and reading the line; the hips end {:.2} m from where they start)",
|
||||
clean,
|
||||
if ask.keys.is_some() { " with keys" } else { "" },
|
||||
ask.frames,
|
||||
ask.frames as f64 / 30.0,
|
||||
ask.seed,
|
||||
ask.steps,
|
||||
out.display(),
|
||||
travel(&made.motion)
|
||||
))
|
||||
}
|
||||
|
||||
/// a line every 512 MB of each file fetched
|
||||
#[cfg(target_os = "macos")]
|
||||
fn fetching() -> impl FnMut(&str, u64) {
|
||||
let mut shown = std::collections::HashMap::<String, u64>::new();
|
||||
move |file: &str, n: u64| {
|
||||
if shown.insert(file.to_string(), n >> 29) != Some(n >> 29) {
|
||||
eprintln!("raea motion: fetching {file}: {} MB", n >> 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What a folder takes on disk, through a link (the Mac's model folders can be links to their files).
|
||||
fn disk(dir: &std::path::Path) -> String {
|
||||
raea_io_home::disk_use(dir, true)
|
||||
}
|
||||
|
||||
/// `raea setup motion [--check]`: what raea motion runs on here, made where missing (--check only says), and where it is.
|
||||
pub fn setup(args: &[String]) -> R<String> {
|
||||
let check = args.iter().any(|a| a == "--check");
|
||||
if let Some(a) = args.iter().find(|a| *a != "--check") {
|
||||
return Err(format!("{SETUP_USAGE}: no `{a}`"));
|
||||
}
|
||||
setup_here(check)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn setup_here(check: bool) -> R<String> {
|
||||
let was = raea_sys_kimodo::installed();
|
||||
if !check && was.iter().any(|m| !m.2) {
|
||||
raea_io_home::offline("raea setup motion's models").map_err(|e| format!("raea setup motion: {e}"))?;
|
||||
let mut progress = fetching();
|
||||
raea_sys_kimodo::fetch_all(&mut progress).map_err(|e| format!("raea setup motion: {e}"))?;
|
||||
}
|
||||
let now = raea_sys_kimodo::installed();
|
||||
let mut lines = vec![" backend MLX, on this Mac's GPU (raea-sys-kimodo, no Python)".to_string()];
|
||||
for ((name, dir, had), (_, _, has)) in was.iter().zip(&now) {
|
||||
let what = if *name == "kimodo" { "the motion model: Kimodo-SOMA-RP-v1, 1.1 GB, NVIDIA Open Model License" } else { "the text encoder: Llama 3 8B Instruct in 8 bits (Meta Llama 3 Community License) with LLM2Vec's adapters (MIT), 8.8 GB" };
|
||||
let state = match (had, has) {
|
||||
(true, _) => "installed",
|
||||
(false, true) => "installed now",
|
||||
(false, false) => "not installed: raea setup motion fetches it (raea motion does too, the first time it needs it)",
|
||||
};
|
||||
lines.push(format!(" {name:<12} {state}; {what}\n {} ({})", dir.display(), if *has { disk(dir) } else { "-".into() }));
|
||||
}
|
||||
let ready = now.iter().all(|m| m.2);
|
||||
let head = match (check, ready) {
|
||||
(true, true) => "CHECKED raea motion's models",
|
||||
(true, false) => "CHECKED raea motion's models (some missing)",
|
||||
_ => "APPLIED raea motion's models ready",
|
||||
};
|
||||
Ok(format!("{head}\n{}", lines.join("\n")))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn setup_here(check: bool) -> R<String> {
|
||||
let t = torch_env();
|
||||
let was = t.missing();
|
||||
let mut made = Vec::new();
|
||||
if !check && !was.is_empty() {
|
||||
raea_io_home::offline("raea setup motion's environment and weights").map_err(|e| format!("raea setup motion: {e}"))?;
|
||||
made = t.setup(&mut |s| eprintln!("raea setup motion: {s}")).map_err(|e| format!("raea setup motion: {e}"))?;
|
||||
}
|
||||
let now = t.missing();
|
||||
let mut lines: Vec<String> = made.iter().map(|m| format!(" {m}")).collect();
|
||||
lines.push(format!(" folder {} ({})", t.dir.display(), if t.dir.exists() { disk(&t.dir) } else { "-".into() }));
|
||||
if now.is_empty() {
|
||||
match t.probe() {
|
||||
Ok(p) => {
|
||||
let gb = |k: &str| p[k].as_f64().map(|v| format!("{v:.0} GB")).unwrap_or_else(|| "?".into());
|
||||
let gpu = match p["gpu"].as_str() {
|
||||
Some(g) => format!("{g}, {} (CUDA {})", gb("vram_gb"), p["cuda"].as_str().unwrap_or("?")),
|
||||
None => "none that PyTorch sees (no NVIDIA GPU, or its driver)".into(),
|
||||
};
|
||||
lines.push(format!(" backend PyTorch {}, upstream Kimodo {}", p["torch"].as_str().unwrap_or("?"), &raea_sys_kimodo::torch::KIMODO[..7]));
|
||||
lines.push(format!(" machine GPU: {gpu}; memory {}; {} CPU threads", gb("ram_gb"), p["threads"]));
|
||||
lines.push(format!(" runs on the denoiser: {}; the text encoder (a new line only): {}", p["motion"].as_str().unwrap_or("?"), p["text"].as_str().unwrap_or("?")));
|
||||
if p["text"] == "cpu" && p["ram_gb"].as_f64().is_some_and(|r| r < 18.0) {
|
||||
lines.push(format!(" warning a new line's encoder needs about 18 GB of memory on the CPU, and this machine has {}: lines already read still work", gb("ram_gb")));
|
||||
}
|
||||
}
|
||||
Err(e) => lines.push(format!(" backend the environment didn't answer: {e}")),
|
||||
}
|
||||
} else {
|
||||
lines.push(format!(" missing the {}: raea setup motion makes it (needs uv: https://docs.astral.sh/uv)", now.join(", the ")));
|
||||
}
|
||||
let head = match (check, now.is_empty()) {
|
||||
(true, true) => "CHECKED raea motion's PyTorch environment",
|
||||
(true, false) => "CHECKED raea motion's PyTorch environment (not set up)",
|
||||
_ => "APPLIED raea motion's PyTorch environment ready",
|
||||
};
|
||||
Ok(format!("{head}\n{}", lines.join("\n")))
|
||||
}
|
||||
@@ -10,6 +10,8 @@ description = "A person's notes on a project as files the work is held to (docs/
|
||||
# Note and Ask, the project found by its .raea/project, and the world a note is an entity in
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# the H.264 encoder this machine's ffmpeg has, for a clip a person plays (raea_io_ffmpeg::h264)
|
||||
raea-io-ffmpeg = { path = "../../io/ffmpeg" }
|
||||
# when a run of an ask's check was (UTC), as raea check stamps its record
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
# what each ask has been through, kept as JSON (state.rs)
|
||||
|
||||
@@ -131,7 +131,8 @@ fn cut(out: &Path, [a, b]: [i64; 2], fps: f64, to: &Path) -> R<()> {
|
||||
}
|
||||
let (from, len) = (format!("{:.4}", a as f64 / fps), format!("{:.4}", (b - a) as f64 / fps));
|
||||
let args = ["-hide_banner", "-loglevel", "error", "-y", "-ss", &from, "-i"];
|
||||
let o = std::process::Command::new("ffmpeg").args(args).arg(out).args(["-t", &len, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac"]).arg(to).output().map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
let h264 = raea_io_ffmpeg::h264().ok_or("ffmpeg here has no H.264 encoder (libx264, Windows' h264_mf or VideoToolbox's) to cut the clip with")?;
|
||||
let o = std::process::Command::new("ffmpeg").args(args).arg(out).args(["-t", &len]).args(h264).args(["-c:a", "aac"]).arg(to).output().map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
if !o.status.success() {
|
||||
return Err(format!("ffmpeg: {}", String::from_utf8_lossy(&o.stderr).trim()));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,5 @@ serde_json = "1"
|
||||
# the verbs' flags read as a render reads its own
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
raea-runtime-export = { path = "../../runtime/export" }
|
||||
|
||||
# `raea motion`: Kimodo on MLX, Apple silicon's
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
raea-sys-kimodo = { path = "../../systems/kimodo" }
|
||||
# `raea motion` and `raea setup motion` (apps/motion), still reached as tools::motion
|
||||
raea-app-motion = { path = "../motion" }
|
||||
@@ -4,8 +4,8 @@
|
||||
//! made.app, fal, Replicate, OpenRouter, Modal and ComfyUI, with sao as the local model: apps/tools/src/generate.rs).
|
||||
|
||||
pub mod generate;
|
||||
/// `raea motion`: body motion made on this Mac by Kimodo on MLX (raea-sys-kimodo)
|
||||
pub mod motion;
|
||||
/// `raea motion` and `raea setup motion`: body motion made by Kimodo, on MLX on a Mac, on PyTorch elsewhere (apps/motion)
|
||||
pub use raea_app_motion as motion;
|
||||
pub mod song;
|
||||
pub mod sound;
|
||||
pub mod splat;
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
//! `raea motion "LINE" [--keys KEYS.json] ...`: body motion made on this Mac by Kimodo (raea-sys-kimodo, on MLX): a
|
||||
//! SOMA clip from a line of words and, with --keys, Kimodo constraints (full-body keyframes, hand or foot targets, a
|
||||
//! root path: what sdk/body/tools/between.ts writes). The clip is the file sdk/body/tools/fromkimodo.ts reads, the
|
||||
//! same one the cloud runner wrote (docs/character.feature CH15b, CH15c).
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use raea_runtime_bundle::flag;
|
||||
|
||||
type R<T> = Result<T, String>;
|
||||
|
||||
pub const USAGE: &str = "raea motion \"LINE\" [--keys KEYS.json] [--seconds 5 | --frames N] [--seed 1] [--steps 100] [-o CLIP.json]";
|
||||
pub const ABOUT: &str = "body motion made on this Mac by Kimodo (NVIDIA, on MLX): a SOMA clip from a line of words and, with --keys, Kimodo constraints (full-body keyframes, hand or foot targets, a root path, as sdk/body/tools/between.ts writes them), as the clip sdk/body/tools/fromkimodo.ts reads; the first use fetches the motion model (1.1 GB) into raea's models folder, and the first new line its text encoder (8.8 GB: Llama 3 8B in 8 bits with LLM2Vec's adapters); a line's words are read once and kept. Licences: Kimodo's weights NVIDIA's Open Model License, Meta Llama 3 the Meta Llama 3 Community License, LLM2Vec's adapters MIT";
|
||||
|
||||
fn number(args: &[String], name: &str, default: f64) -> R<f64> {
|
||||
match flag(args, name) {
|
||||
None => Ok(default),
|
||||
Some(v) => v.parse::<f64>().ok().filter(|n| n.is_finite() && *n >= 0.0).ok_or(format!("{name} takes a number, got `{v}`")),
|
||||
}
|
||||
}
|
||||
|
||||
fn line(args: &[String]) -> String {
|
||||
const WITH_VALUE: [&str; 6] = ["--keys", "--seconds", "--frames", "--seed", "--steps", "-o"];
|
||||
let mut out = Vec::new();
|
||||
let mut i = 1;
|
||||
while i < args.len() {
|
||||
if WITH_VALUE.contains(&args[i].as_str()) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
if !args[i].starts_with("--") {
|
||||
out.push(args[i].as_str());
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
out.join(" ")
|
||||
}
|
||||
|
||||
/// what a call asks for, read from its words and flags
|
||||
struct Ask {
|
||||
words: String,
|
||||
keys: Option<String>,
|
||||
constraints: Option<serde_json::Value>,
|
||||
frames: usize,
|
||||
seed: u64,
|
||||
steps: usize,
|
||||
out: Option<String>,
|
||||
}
|
||||
|
||||
pub fn motion(args: &[String]) -> R<String> {
|
||||
let words = line(args);
|
||||
let keys = flag(args, "--keys");
|
||||
if words.trim().is_empty() && keys.is_none() {
|
||||
return Err(format!("{USAGE}\n ({ABOUT})"));
|
||||
}
|
||||
let frames = match flag(args, "--frames") {
|
||||
Some(_) => number(args, "--frames", 150.0)? as usize,
|
||||
None => (number(args, "--seconds", 5.0)? * 30.0).round() as usize,
|
||||
};
|
||||
if !(2..=600).contains(&frames) {
|
||||
return Err(format!("a clip is 2 to 600 frames (20 s at 30 a second), asked {frames}"));
|
||||
}
|
||||
let constraints = match &keys {
|
||||
Some(p) => Some(serde_json::from_str::<serde_json::Value>(&std::fs::read_to_string(p).map_err(|e| format!("{p}: {e}"))?).map_err(|e| format!("{p}: {e}"))?),
|
||||
None => None,
|
||||
};
|
||||
let (seed, steps) = (number(args, "--seed", 1.0)? as u64, (number(args, "--steps", 100.0)? as usize).max(2));
|
||||
make(Ask { words, keys, constraints, frames, seed, steps, out: flag(args, "-o") })
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn make(ask: Ask) -> R<String> {
|
||||
Err(format!("raea motion runs Kimodo on MLX, on Apple silicon's GPU: {:?} can be made on a Mac", ask.words))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn make(ask: Ask) -> R<String> {
|
||||
// float32 as checked against PyTorch: MLX's TF32 matmuls off, before the first one
|
||||
if std::env::var_os("MLX_ENABLE_TF32").is_none() {
|
||||
unsafe { std::env::set_var("MLX_ENABLE_TF32", "0") };
|
||||
}
|
||||
let t0 = std::time::Instant::now();
|
||||
// a line every 512 MB of each file fetched
|
||||
let mut shown = std::collections::HashMap::<String, u64>::new();
|
||||
let mut progress = |file: &str, n: u64| {
|
||||
if shown.insert(file.to_string(), n >> 29) != Some(n >> 29) {
|
||||
eprintln!("raea motion: fetching {file}: {} MB", n >> 20);
|
||||
}
|
||||
};
|
||||
let mut k = raea_sys_kimodo::Kimodo::fetch(&mut progress).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let (clean, emb) = k.encode(&ask.words).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let load_s = t0.elapsed().as_secs_f64();
|
||||
let made_from = raea_sys_kimodo::Ask { line: &ask.words, frames: ask.frames, seed: ask.seed, steps: ask.steps, constraints: ask.constraints.as_ref(), cfg: (2.0, 2.0) };
|
||||
let t1 = std::time::Instant::now();
|
||||
let made = k.make(&made_from, emb.as_deref(), None).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let gen_s = t1.elapsed().as_secs_f64();
|
||||
let clip = raea_sys_kimodo::decode::clip_json(&made.motion, &k.skeleton, ask.seed, ask.steps, &clean, ask.constraints.is_some());
|
||||
// without -o, the line's words name the file
|
||||
let out = PathBuf::from(ask.out.unwrap_or_else(|| {
|
||||
let slug = clean.split(|c: char| !c.is_ascii_alphanumeric()).filter(|w| !w.is_empty()).map(str::to_lowercase).collect::<Vec<_>>().join("-");
|
||||
format!("{}.clip.json", if slug.is_empty() { "keys".to_string() } else { slug.chars().take(60).collect() })
|
||||
}));
|
||||
std::fs::write(&out, serde_json::to_string(&clip).unwrap_or_default()).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
let r = &made.motion.root;
|
||||
let (a, b) = (r[0], r[r.len() - 1]);
|
||||
let travel = ((b[0] - a[0]).powi(2) + (b[2] - a[2]).powi(2)).sqrt();
|
||||
Ok(format!(
|
||||
"APPLIED motion {:?}{}, {} frames ({:.1} s), seed {}, {} steps -> {} (made on this Mac in {gen_s:.1} s after {load_s:.1} s loading and reading the line; the hips end {travel:.2} m from where they start)",
|
||||
clean,
|
||||
if ask.keys.is_some() { " with keys" } else { "" },
|
||||
ask.frames,
|
||||
ask.frames as f64 / 30.0,
|
||||
ask.seed,
|
||||
ask.steps,
|
||||
out.display()
|
||||
))
|
||||
}
|
||||
+10
-11
@@ -186,11 +186,17 @@ pub fn tokensynth(args: &[String]) -> R<String> {
|
||||
if !raea_io_assets::TOKENSYNTH_PRECISIONS.contains(&precision.as_str()) {
|
||||
return Err(format!("--precision is one of {}", raea_io_assets::TOKENSYNTH_PRECISIONS.join(", ")));
|
||||
}
|
||||
// RAEA_TOKENSYNTH_DEVICE=cuda: an NVIDIA GPU (raea's cloud farm sets it); it's in the params, so a GPU's note is
|
||||
// its own sample in the store, never taken for the CPU's
|
||||
let device = std::env::var("RAEA_TOKENSYNTH_DEVICE").unwrap_or_else(|_| "cpu".into());
|
||||
if device != "cpu" && device != "cuda" {
|
||||
return Err(format!("RAEA_TOKENSYNTH_DEVICE is cpu or cuda, got {device}"));
|
||||
}
|
||||
let s = store(args);
|
||||
let out = flag(args, "-o").map(PathBuf::from);
|
||||
let mut lines = Vec::new();
|
||||
for (name, midi) in ¬es {
|
||||
let params = json!({"seconds": seconds, "midi": midi, "velocity": velocity, "seed": seed, "device": "cpu", "precision": precision});
|
||||
let params = json!({"seconds": seconds, "midi": midi, "velocity": velocity, "seed": seed, "device": device, "precision": precision});
|
||||
let cached = s.made("tokensynth", &timbre, seed, ¶ms)?.is_some_and(|a| s.path(&a).exists());
|
||||
let t0 = std::time::Instant::now();
|
||||
let a = s.make("tokensynth", &timbre, seed, ¶ms)?;
|
||||
@@ -247,25 +253,18 @@ pub fn setup_audio(args: &[String]) -> R<String> {
|
||||
}
|
||||
let now = raea_io_assets::installed(m, &dir);
|
||||
missing += !now as usize;
|
||||
let what = if m == "sao" { "foley (Stable Audio Open Small, Core ML)" } else { "music: an instrument's notes (TokenSynth)" };
|
||||
let what = if m == "sao" { "foley (Stable Audio Open Small: Core ML on a Mac, else ONNX)" } else { "music: an instrument's notes (TokenSynth)" };
|
||||
let state = match (was, now) {
|
||||
(true, _) => "installed".to_string(),
|
||||
(false, true) => "installed now".to_string(),
|
||||
(false, false) => format!("not installed: {} installs it", raea_io_assets::setup_script(m).display()),
|
||||
(false, false) => format!("not installed: `raea setup-audio` or {} installs it", raea_io_assets::setup_how(&raea_io_assets::setup_script(m))),
|
||||
};
|
||||
lines.push(format!(" {m:<10} {state}; {what}\n {} ({})", dir.display(), if now { disk(&dir) } else { "-".into() }));
|
||||
lines.push(format!(" {m:<10} {state}; {what}\n {} ({})", dir.display(), if now { raea_io_home::disk_use(&dir, false) } else { "-".into() }));
|
||||
}
|
||||
let head = if check { if missing > 0 { "CHECKED local audio models (some missing)" } else { "CHECKED local audio models" } } else { "APPLIED local audio models ready" };
|
||||
Ok(format!("{head}\n{}", lines.join("\n")))
|
||||
}
|
||||
|
||||
/// What a folder takes on disk, as du says it (clones of another install count in full here, as du counts them).
|
||||
fn disk(dir: &Path) -> String {
|
||||
std::process::Command::new("du").arg("-sh").arg(dir).output().ok()
|
||||
.and_then(|o| String::from_utf8_lossy(&o.stdout).split_whitespace().next().map(str::to_string))
|
||||
.unwrap_or_else(|| "?".into())
|
||||
}
|
||||
|
||||
// ---- the open sample libraries --------------------------------------------------------------------------------------
|
||||
|
||||
/// sdk/raea/library/sounds/catalog.json (tools/sounds/catalog.py writes it): the libraries, their licences and every
|
||||
|
||||
@@ -11,6 +11,8 @@ dunce = "1"
|
||||
# the controller schema (core/brief controller.rs): a controller file is checked and normalized against it
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# git, which a workspace is: the PATH's, else on Windows the app's or raea's own (raea_io_assets::git)
|
||||
raea-io-assets = { path = "../../io/assets" }
|
||||
serde_json = "1"
|
||||
# a project's compositions, components and controllers read from their source (docs/projects.feature PJ8)
|
||||
raea-app-registry = { path = "registry" }
|
||||
|
||||
@@ -62,10 +62,10 @@ pub(crate) fn overrides(from: &Path) -> Vec<(String, String)> {
|
||||
}
|
||||
|
||||
fn commit(ws: &Path, paths: &[&Path], what: &str, by: &str) -> R<()> {
|
||||
let mut add = Command::new("git");
|
||||
let mut add = Command::new(workspace::program());
|
||||
add.arg("-C").arg(ws).args(["add", "-A", "--"]).args(paths);
|
||||
add.status().map_err(|e| format!("git: {e}"))?;
|
||||
let ok = workspace::git_cmd().arg("-C").arg(ws).args(["-c", &format!("user.name={by}"), "commit", "-q", "-m", &format!("{by}: {what}"), "--"]).args(paths).status().map_err(|e| format!("git: {e}"))?;
|
||||
add.status().map_err(workspace::missing)?;
|
||||
let ok = workspace::git_cmd().arg("-C").arg(ws).args(["-c", &format!("user.name={by}"), "commit", "-q", "-m", &format!("{by}: {what}"), "--"]).args(paths).status().map_err(workspace::missing)?;
|
||||
if ok.success() { Ok(()) } else { Err(format!("couldn't commit {what}")) }
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const USAGE: &str = "usage: raea workspace [--json] | raea workspace init [NAME]
|
||||
/// full name (a CI runner's, a container's) has no name either ("empty ident name ... not allowed"), and git has no
|
||||
/// fallback below user.name to give it, so when no user.name is set the author and committer are named for the account.
|
||||
pub(crate) fn git_cmd() -> Command {
|
||||
let mut c = Command::new("git");
|
||||
let mut c = Command::new(program());
|
||||
let user = std::env::var("USER").unwrap_or_else(|_| "raea".into());
|
||||
if std::env::var_os("EMAIL").is_none() {
|
||||
c.env("EMAIL", format!("{user}@raea.local"));
|
||||
@@ -24,14 +24,33 @@ pub(crate) fn git_cmd() -> Command {
|
||||
c
|
||||
}
|
||||
|
||||
/// The git raea runs (raea_io_assets::git: the PATH's, else on Windows the app's or raea's own, fetched once), found
|
||||
/// once a process; "git" when there's none, its spawn then failing as `missing` says.
|
||||
fn found() -> &'static Result<std::path::PathBuf, String> {
|
||||
static GIT: std::sync::OnceLock<Result<std::path::PathBuf, String>> = std::sync::OnceLock::new();
|
||||
GIT.get_or_init(raea_io_assets::git)
|
||||
}
|
||||
|
||||
pub(crate) fn program() -> std::path::PathBuf {
|
||||
found().clone().unwrap_or_else(|_| "git".into())
|
||||
}
|
||||
|
||||
/// A git that didn't start, said as why: there's no git here (and how to get one), or what the system said
|
||||
pub(crate) fn missing(e: std::io::Error) -> String {
|
||||
match found() {
|
||||
Err(why) if e.kind() == std::io::ErrorKind::NotFound => why.clone(),
|
||||
_ => format!("git: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether git has a user.name to sign commits with (asked once a process).
|
||||
fn has_name() -> bool {
|
||||
static HAS: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
*HAS.get_or_init(|| Command::new("git").args(["config", "--get", "user.name"]).output().is_ok_and(|o| o.status.success() && !o.stdout.trim_ascii().is_empty()))
|
||||
*HAS.get_or_init(|| Command::new(program()).args(["config", "--get", "user.name"]).output().is_ok_and(|o| o.status.success() && !o.stdout.trim_ascii().is_empty()))
|
||||
}
|
||||
|
||||
pub(crate) fn git(dir: &Path, args: &[&str]) -> R<String> {
|
||||
let out = git_cmd().arg("-C").arg(dir).args(args).output().map_err(|e| format!("git: {e}"))?;
|
||||
let out = git_cmd().arg("-C").arg(dir).args(args).output().map_err(missing)?;
|
||||
if !out.status.success() {
|
||||
return Err(format!("git {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim()));
|
||||
}
|
||||
@@ -40,12 +59,12 @@ pub(crate) fn git(dir: &Path, args: &[&str]) -> R<String> {
|
||||
|
||||
/// `git config` on a file (or the global config when `file` is None), its output trimmed; Err when git says no.
|
||||
pub(crate) fn config(file: Option<&Path>, args: &[&str]) -> R<String> {
|
||||
let mut c = Command::new("git");
|
||||
let mut c = Command::new(program());
|
||||
c.arg("config");
|
||||
if let Some(f) = file {
|
||||
c.arg("-f").arg(f);
|
||||
}
|
||||
let out = c.args(args).output().map_err(|e| format!("git: {e}"))?;
|
||||
let out = c.args(args).output().map_err(missing)?;
|
||||
if !out.status.success() {
|
||||
return Err(format!("git config {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim()));
|
||||
}
|
||||
@@ -111,7 +130,8 @@ pub fn default_root(home: &Path) -> PathBuf {
|
||||
if home.join("Library/Mobile Documents/com~apple~CloudDocs/Documents").is_dir() {
|
||||
home.join("raea")
|
||||
} else {
|
||||
home.join("Documents/raea")
|
||||
// a folder at a time: on Windows "Documents/raea" printed as C:\Users\you\Documents/raea\...
|
||||
home.join("Documents").join("raea")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"about": "raea Light's reference scenes (docs/realism.feature LT1), for `raea light check bench/light/scenes.json -o DIR`",
|
||||
"scenes": [
|
||||
{
|
||||
"name": "gambit-street",
|
||||
"dir": "~/Studio/raea/projects/gambit",
|
||||
"file": "compositions/people-ingame.tsx",
|
||||
"composition": "people-ingame",
|
||||
"stills": [
|
||||
0,
|
||||
1,
|
||||
5,
|
||||
6,
|
||||
10,
|
||||
11,
|
||||
15,
|
||||
16
|
||||
],
|
||||
"reference": false,
|
||||
"why": "its city is drawn by shader hooks the path tracer can't run and its people aren't traced (M3, M5): after LT2, LT3 and LT5",
|
||||
"live": false,
|
||||
"live_why": "a contact sheet: every frame cuts to another view or sky, so its live frames are scene changes and its frames 0-4 are cuts, not a moving shot; gambit-walk measures both"
|
||||
},
|
||||
{
|
||||
"name": "gambit-walk",
|
||||
"dir": "~/Studio/raea/projects/gambit",
|
||||
"file": "compositions/light-walk.tsx",
|
||||
"composition": "light-walk-day",
|
||||
"stills": [
|
||||
0,
|
||||
96,
|
||||
191
|
||||
],
|
||||
"reference": false,
|
||||
"why": "as gambit-street: the city's shader hooks and the people (M3, M5), after LT2, LT3 and LT5",
|
||||
"live": true,
|
||||
"shot": [
|
||||
84,
|
||||
107
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "floor3-room",
|
||||
"dir": "~/Studio/raea/projects/floor3",
|
||||
"file": "compositions/floor3.tsx",
|
||||
"composition": "floor3",
|
||||
"stills": [
|
||||
1500,
|
||||
4000
|
||||
],
|
||||
"shot": [
|
||||
1500,
|
||||
1504
|
||||
],
|
||||
"live": true,
|
||||
"spp": 2048
|
||||
},
|
||||
{
|
||||
"name": "kitchen",
|
||||
"dir": "~/Studio/raea/projects/gambit",
|
||||
"file": "compositions/fp-lab-table.tsx",
|
||||
"composition": "fp-lab-table-coat-gloves-day",
|
||||
"stills": [
|
||||
48,
|
||||
200
|
||||
],
|
||||
"shot": [
|
||||
100,
|
||||
104
|
||||
],
|
||||
"live": true,
|
||||
"spp": 1024,
|
||||
"reference": false,
|
||||
"why": "its daylight is RectLight panels (the window, the court's sky, a bounce panel), which neither Solari nor the path tracer draws (M9), and its hands are skinned (M3): after LT5b and LT5"
|
||||
},
|
||||
{
|
||||
"name": "glade",
|
||||
"dir": "~/Studio/raea/projects/stay",
|
||||
"file": "v3/film.tsx",
|
||||
"composition": "v3-wide",
|
||||
"stills": [
|
||||
0,
|
||||
40
|
||||
],
|
||||
"shot": [
|
||||
10,
|
||||
14
|
||||
],
|
||||
"live_why": "raea play runs a file's first composition, and v3/film.tsx's isn't the wide shot",
|
||||
"spp": 512
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// HTML over 3D with one control (docs/realtime.feature RT0a): raster.tsx's scene under a caption and a lower third
|
||||
// drawn by the page, the hero cube's colour a prop. The page's text over 3D is where play and render already differ by
|
||||
// a level or two (docs/rerender.feature RR1: SSIM >= 0.999473).
|
||||
import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";
|
||||
import { Scene } from "./scene";
|
||||
|
||||
function Caption({ color = "#d04a3a" }: { color?: string }) {
|
||||
const f = useCurrentFrame();
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#9fb7c8" }}>
|
||||
<Scene color={color} />
|
||||
<div style={{ position: "absolute", left: 60, bottom: 70, padding: "14px 22px", borderRadius: 10, background: "rgba(12,16,24,0.72)", fontFamily: "Helvetica, Arial, sans-serif", color: "#fff" }}>
|
||||
<div style={{ fontSize: 18, letterSpacing: "0.25em", opacity: 0.75 }}>SHOT 1</div>
|
||||
<div style={{ fontSize: 44, fontWeight: 700, opacity: Math.min(1, f / 15) }}>The hero cube</div>
|
||||
</div>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="caption" component={Caption} defaultProps={{ color: "#d04a3a" }} width={1280} height={720} fps={30} durationInFrames={150} />);
|
||||
@@ -0,0 +1,19 @@
|
||||
// The window render's films (docs/realtime.feature RT1; the plan's experiment 2): RR0's six shots (bench/rerender/
|
||||
// shots.tsx: a procedural set with grass, trees, a room and a street, a look and a camera per 5 s shot) played round
|
||||
// for 60 s and for 180 s at 1920x1080, 30 fps. window.sh renders the same 5 s window of each, as the app's draft
|
||||
// renders the seconds around the playhead (`edit={{ segments, scale }}`), so any difference in its cost is the
|
||||
// length of the film around it.
|
||||
import { Composition, registerRoot, useCurrentFrame } from "raea";
|
||||
import { FPS, Frame, SHOT } from "../../rerender/shots";
|
||||
|
||||
function Round() {
|
||||
const f = useCurrentFrame();
|
||||
return <Frame k={Math.floor(f / SHOT) % 6} t={(f % SHOT) / FPS} />;
|
||||
}
|
||||
|
||||
registerRoot(() => (
|
||||
<>
|
||||
<Composition id="film-60" component={Round} width={1920} height={1080} fps={FPS} durationInFrames={60 * FPS} />
|
||||
<Composition id="film-180" component={Round} width={1920} height={1080} fps={FPS} durationInFrames={180 * FPS} />
|
||||
</>
|
||||
));
|
||||
@@ -0,0 +1,26 @@
|
||||
// A prop the running world can't take (docs/realtime.feature RT4g): the hero cube's size, which lands in the mesh's
|
||||
// shape, a column the live scene keeps from the part's first frame (runtime/scene/src/live.rs live_dynamic). The stage
|
||||
// answers stage.props with the part it held, and a written file with only the value changed is opened again rather
|
||||
// than taken in place, so the frame matches the render after all.
|
||||
import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";
|
||||
import { Camera3d } from "raea/camera";
|
||||
import { AmbientLight, DirectionalLight } from "raea/light";
|
||||
import { Cuboid, Mesh3d } from "raea/mesh";
|
||||
import { StandardMaterial } from "raea/pbr";
|
||||
import { Transform } from "raea/transform";
|
||||
|
||||
function Held({ size = 0.6 }: { size?: number }) {
|
||||
const f = useCurrentFrame();
|
||||
const a = 0.4 + f * 0.012;
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#9fb7c8" }}>
|
||||
<Camera3d transform={Transform.fromXyz(Math.cos(a) * 6, 2.6, Math.sin(a) * 6).lookingAt([0, 0.6, 0], [0, 1, 0])} projection={{ Perspective: { fov: (45 * Math.PI) / 180 } }} />
|
||||
<DirectionalLight name="sun" transform={Transform.fromXyz(4, 8, 3).lookingAt([0, 0, 0], [0, 1, 0])} illuminance={6000} shadow_maps_enabled />
|
||||
<AmbientLight brightness={120} />
|
||||
<Mesh3d name="floor" transform={Transform.fromXyz(0, -0.05, 0)}><Cuboid half_size={[8, 0.05, 8]} /><StandardMaterial base_color="#a8a196" perceptual_roughness={0.9} /></Mesh3d>
|
||||
<Mesh3d name="hero" transform={Transform.fromXyz(0, size, 0)}><Cuboid half_size={[size, size, size]} /><StandardMaterial base_color="#d04a3a" perceptual_roughness={0.45} /></Mesh3d>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="held" component={Held} defaultProps={{ size: 0.6 }} controls={{ size: { kind: "number", min: 0.2, max: 1.5, step: 0.05, cost: "reopen" } }} width={1280} height={720} fps={30} durationInFrames={150} />);
|
||||
@@ -0,0 +1,21 @@
|
||||
// The 2D piece of title.tsx with confetti placed by Math.random and a clock read from Date (docs/realtime.feature
|
||||
// RT0a): a render seeds Math.random from the composition and dates frame 0 at the render's epoch (sdk/raea/src/pure.ts),
|
||||
// a live session from its own seed and start (runtime/live/src/lib.rs new_session), so this case says what the seed
|
||||
// and the epoch alone cost a live frame.
|
||||
import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";
|
||||
|
||||
function Confetti({ hue = 210 }: { hue?: number }) {
|
||||
const f = useCurrentFrame();
|
||||
const dots = Array.from({ length: 40 }, (_, i) => ({ x: Math.random() * 1200, y: Math.random() * 660, r: 8 + Math.random() * 16, h: (hue + i * 9) % 360 }));
|
||||
const clock = new Date().getUTCSeconds();
|
||||
return (
|
||||
<AbsoluteFill style={{ background: `hsl(${hue}, 40%, 18%)` }}>
|
||||
{dots.map((d, i) => (
|
||||
<div key={i} style={{ position: "absolute", left: d.x, top: (d.y + f * 2) % 700, width: d.r * 2, height: d.r * 2, borderRadius: d.r, background: `hsl(${d.h}, 80%, 60%)` }} />
|
||||
))}
|
||||
<div style={{ position: "absolute", right: 40, top: 30, fontFamily: "Helvetica, Arial, sans-serif", fontSize: 40, color: "#fff" }}>{clock}</div>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="random" component={Confetti} defaultProps={{ hue: 210 }} width={1280} height={720} fps={30} durationInFrames={150} />);
|
||||
@@ -0,0 +1,15 @@
|
||||
// A raster-lit 3D piece with one control (docs/realtime.feature RT0a): a few parts on a floor under a sun, the camera
|
||||
// circling them over 5 s, the hero cube's colour a prop. Colour is on the live scene's keyed list
|
||||
// (runtime/scene/src/live.rs), so a running world takes the change without rebuilding the part.
|
||||
import { AbsoluteFill, Composition, registerRoot } from "raea";
|
||||
import { Scene } from "./scene";
|
||||
|
||||
function Raster({ color = "#d04a3a" }: { color?: string }) {
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#9fb7c8" }}>
|
||||
<Scene color={color} />
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="raster" component={Raster} defaultProps={{ color: "#d04a3a" }} width={1280} height={720} fps={30} durationInFrames={150} />);
|
||||
@@ -0,0 +1,24 @@
|
||||
// raster.tsx's scene, shared with caption.tsx: a few parts on a floor under a sun, the camera circling them over 5 s,
|
||||
// the hero cube's colour a prop.
|
||||
import { useCurrentFrame } from "raea";
|
||||
import { Camera3d } from "raea/camera";
|
||||
import { AmbientLight, DirectionalLight } from "raea/light";
|
||||
import { Cuboid, Mesh3d, Sphere } from "raea/mesh";
|
||||
import { StandardMaterial } from "raea/pbr";
|
||||
import { Transform } from "raea/transform";
|
||||
|
||||
export function Scene({ color = "#d04a3a" }: { color?: string }) {
|
||||
const f = useCurrentFrame();
|
||||
const a = 0.4 + f * 0.012;
|
||||
return (
|
||||
<>
|
||||
<Camera3d transform={Transform.fromXyz(Math.cos(a) * 6, 2.6, Math.sin(a) * 6).lookingAt([0, 0.6, 0], [0, 1, 0])} projection={{ Perspective: { fov: (45 * Math.PI) / 180 } }} />
|
||||
<DirectionalLight name="sun" transform={Transform.fromXyz(4, 8, 3).lookingAt([0, 0, 0], [0, 1, 0])} illuminance={6000} shadow_maps_enabled />
|
||||
<AmbientLight brightness={120} />
|
||||
<Mesh3d name="floor" transform={Transform.fromXyz(0, -0.05, 0)}><Cuboid half_size={[8, 0.05, 8]} /><StandardMaterial base_color="#a8a196" perceptual_roughness={0.9} /></Mesh3d>
|
||||
<Mesh3d name="hero" transform={Transform.fromXyz(0, 0.6, 0)}><Cuboid half_size={[0.6, 0.6, 0.6]} /><StandardMaterial base_color={color} perceptual_roughness={0.45} /></Mesh3d>
|
||||
<Mesh3d name="ball" transform={Transform.fromXyz(1.6, 0.45 + 0.25 * Math.abs(Math.sin(f / 9)), 0.8)}><Sphere radius={0.45} /><StandardMaterial base_color="#3a7bd0" perceptual_roughness={0.3} metallic={0.2} /></Mesh3d>
|
||||
<Mesh3d name="post" transform={Transform.fromXyz(-1.5, 0.9, -1)}><Cuboid half_size={[0.2, 0.9, 0.2]} /><StandardMaterial base_color="#e2c044" perceptual_roughness={0.7} /></Mesh3d>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// A ray-traced piece with one control (docs/realtime.feature RT0b): a closed room lit by Solari from a glowing panel
|
||||
// and a sun through a window, the camera dollying in over 5 s, the panel's glow a prop. Solari and MetalFX keep light
|
||||
// history between updates, so a frame jumped to isn't converged at once: the bench counts the updates a seeked frame
|
||||
// takes to come within SSIM 0.995 of the render's frame.
|
||||
import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";
|
||||
import { Camera3d } from "raea/camera";
|
||||
import { LinearRgba } from "raea/color";
|
||||
import { DirectionalLight, SolariLighting } from "raea/light";
|
||||
import { Cuboid, Mesh3d, Sphere } from "raea/mesh";
|
||||
import { StandardMaterial } from "raea/pbr";
|
||||
import { Transform } from "raea/transform";
|
||||
|
||||
type V3 = [number, number, number];
|
||||
// a 6 x 3 x 6 m room of thick slabs, a window in the east wall
|
||||
const SLABS: { name: string; min: V3; max: V3; c: string }[] = [
|
||||
{ name: "floor", min: [-3.2, -0.2, -3.2], max: [3.2, 0, 3.2], c: "#8a7b66" },
|
||||
{ name: "ceiling", min: [-3.2, 3, -3.2], max: [3.2, 3.2, 3.2], c: "#d8d4c8" },
|
||||
{ name: "wall-w", min: [-3.2, 0, -3.2], max: [-3, 3, 3.2], c: "#c9bfa4" },
|
||||
{ name: "wall-n", min: [-3.2, 0, -3.2], max: [3.2, 3, -3], c: "#b9c4cf" },
|
||||
{ name: "wall-s", min: [-3.2, 0, 3], max: [3.2, 3, 3.2], c: "#c9bfa4" },
|
||||
{ name: "wall-e1", min: [3, 0, -3.2], max: [3.2, 3, -0.8], c: "#c9bfa4" },
|
||||
{ name: "wall-e2", min: [3, 0, 0.8], max: [3.2, 3, 3.2], c: "#c9bfa4" },
|
||||
{ name: "wall-e3", min: [3, 0, -0.8], max: [3.2, 1, 0.8], c: "#c9bfa4" },
|
||||
{ name: "wall-e4", min: [3, 2.2, -0.8], max: [3.2, 3, 0.8], c: "#c9bfa4" },
|
||||
];
|
||||
const mid = (a: V3, b: V3): V3 => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
|
||||
const half = (a: V3, b: V3): V3 => [(b[0] - a[0]) / 2, (b[1] - a[1]) / 2, (b[2] - a[2]) / 2];
|
||||
|
||||
function Room({ glow = 600 }: { glow?: number }) {
|
||||
const f = useCurrentFrame();
|
||||
const z = 2.4 - f * 0.008;
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#000000" }}>
|
||||
<Camera3d transform={Transform.fromXyz(-1.8, 1.5, z).lookingAt([1.2, 0.9, -1.2], [0, 1, 0])} projection={{ Perspective: { fov: (60 * Math.PI) / 180 } }}>
|
||||
<SolariLighting bounces={2} />
|
||||
</Camera3d>
|
||||
<DirectionalLight name="sun" transform={Transform.fromXyz(10, 6, 1).lookingAt([0, 0, 0], [0, 1, 0])} illuminance={30000} />
|
||||
{SLABS.map(({ name, min, max, c }) => (
|
||||
<Mesh3d key={name} name={name} transform={Transform.fromXyz(...mid(min, max))}>
|
||||
<Cuboid half_size={half(min, max)} />
|
||||
<StandardMaterial base_color={c} perceptual_roughness={0.85} />
|
||||
</Mesh3d>
|
||||
))}
|
||||
<Mesh3d name="panel" castShadow={false} transform={Transform.fromXyz(0, 2.96, -1)}>
|
||||
<Cuboid half_size={[0.8, 0.02, 0.4]} />
|
||||
<StandardMaterial base_color="#ffffff" emissive={new LinearRgba(glow, glow * 0.95, glow * 0.85, 1)} />
|
||||
</Mesh3d>
|
||||
<Mesh3d name="table" transform={Transform.fromXyz(0.8, 0.4, -1.2)}><Cuboid half_size={[0.7, 0.4, 0.5]} /><StandardMaterial base_color="#6b4a32" perceptual_roughness={0.6} /></Mesh3d>
|
||||
<Mesh3d name="ball" transform={Transform.fromXyz(0.6, 1.1, -1.1)}><Sphere radius={0.3} /><StandardMaterial base_color="#d04a3a" perceptual_roughness={0.4} /></Mesh3d>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="solari" component={Room} defaultProps={{ glow: 600 }} width={1280} height={720} fps={30} durationInFrames={150} />);
|
||||
@@ -0,0 +1,23 @@
|
||||
// A 2D piece with one control (docs/realtime.feature RT0a): a title card whose background hue is a prop, its words
|
||||
// sliding in and a bar filling over 5 s. No 3D, no media, no randomness: its frame is a function of the frame number
|
||||
// and `hue` alone, so the stage and a render of the same frame and props must be the same pixels.
|
||||
import { AbsoluteFill, Composition, interpolate, registerRoot, useCurrentFrame } from "raea";
|
||||
|
||||
function Title({ hue = 210 }: { hue?: number }) {
|
||||
const f = useCurrentFrame();
|
||||
const y = interpolate(f, [0, 24], [60, 0], { extrapolateRight: "clamp" });
|
||||
const bar = interpolate(f, [0, 150], [0, 1], { extrapolateRight: "clamp" });
|
||||
return (
|
||||
<AbsoluteFill style={{ background: `hsl(${hue}, 55%, 28%)`, alignItems: "center", justifyContent: "center" }}>
|
||||
<div style={{ fontFamily: "Helvetica, Arial, sans-serif", fontSize: 120, fontWeight: 700, color: "#fff", transform: `translateY(${y}px)`, opacity: Math.min(1, f / 18) }}>
|
||||
Live controls
|
||||
</div>
|
||||
<div style={{ position: "absolute", left: 160, right: 160, bottom: 120, height: 14, borderRadius: 7, background: "rgba(255,255,255,0.2)" }}>
|
||||
<div style={{ width: `${bar * 100}%`, height: "100%", borderRadius: 7, background: `hsl(${(hue + 160) % 360}, 80%, 62%)` }} />
|
||||
</div>
|
||||
<div style={{ position: "absolute", left: 160 + bar * 800, top: 140, width: 80, height: 80, borderRadius: 40, background: "#fff", opacity: 0.85, transform: `rotate(${f * 3}deg)` }} />
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="title" component={Title} defaultProps={{ hue: 210 }} width={1280} height={720} fps={30} durationInFrames={150} />);
|
||||
@@ -0,0 +1,215 @@
|
||||
// The stage's side of the realtime bench (bench/realtime/stage.sh): a headless raea window running stage/page.tsx, its
|
||||
// stage driven over the window's MCP server as the app's useStage drives it. For one case:
|
||||
// 1. the composition A (its defaultProps as written) shown, paused, seeked to frame N, captured after each of
|
||||
// UPDATES draws of that frame (a paused stage draws again on a pointer move: one engine update each)
|
||||
// 2. stage.props {PROP: B} on that running world: the frame drawn again with them (ab), captured the same way, and
|
||||
// the time from the call to the stage's next painted frame
|
||||
// 3. the same frame seeked to again, as the app's useStage did after props on a paused stage (abs): the time from
|
||||
// the props call to the frame it paints, and captures as above
|
||||
// 4. a drag (RT4e): DRAGS props changes one after another, A and B in turn (ending on B), each waited for until
|
||||
// painted: the milliseconds from each call to the window's next painted frame (over MCP, an upper bound) and the
|
||||
// stage's own (status.props.ms: the call taken to the frame in the stage's texture), p50 and p95
|
||||
// 5. a burst: BURST props sent at once from the page (rt.calls), ending on B, as a drag sends them faster than a
|
||||
// frame draws: how many the stage passed over (newest wins), how many it drew, the values it ends on, and the
|
||||
// frame captured once (burst)
|
||||
// 6. the copy with B written into defaultProps shown over it (RT4f): taken in place when only values changed and
|
||||
// the 3D keeps none of them (status.last_show "adopted"), else opened; the time to its frame, captured (ad)
|
||||
// 7. the copy shown fresh (the stage cleared first, so it is opened) and captured the same way (b)
|
||||
// Captures are the window's own frame (frame_png), one window point a stage pixel. Writes OUT/{a,ab,abs,burst,ad,b}-K.png
|
||||
// and OUT/stage.json ({ props_ms, drag, burst, adopt, steps, window, scale }).
|
||||
// node bench/realtime/stage.mjs PORT OUT A.tsx B.tsx PROP A_JSON B_JSON FRAME W H UPDATES [MODE]
|
||||
// MODE: render (the default: stage.show {render: true}, drawn as `raea render` draws it) or live (as a game: the
|
||||
// stage's own session). RT_DRAGS (30) and RT_BURST (12) size steps 4 and 5.
|
||||
import { writeFileSync } from "node:fs";
|
||||
|
||||
const [port, out, fileA, fileB, prop, aJson, valueJson, frameS, wS, hS, updatesS, modeS] = process.argv.slice(2);
|
||||
const N = Number(frameS), W = Number(wS), H = Number(hS), UPDATES = Number(updatesS ?? 3);
|
||||
const was0 = JSON.parse(aJson), value = JSON.parse(valueJson);
|
||||
const RENDER = (modeS ?? "render") !== "live";
|
||||
const DRAGS = Number(process.env.RT_DRAGS ?? 30), BURST = Number(process.env.RT_BURST ?? 12);
|
||||
let id = 0;
|
||||
async function tool(name, args = {}) {
|
||||
const r = await fetch(`http://127.0.0.1:${port}/mcp`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json", accept: "application/json, text/event-stream" },
|
||||
body: JSON.stringify({ jsonrpc: "2.0", id: ++id, method: "tools/call", params: { name, arguments: args } }),
|
||||
});
|
||||
const j = await r.json();
|
||||
if (j.error) throw new Error(`${name}: ${j.error.message}`);
|
||||
return j.result;
|
||||
}
|
||||
const text = (res) => res?.content?.find((c) => c.type === "text")?.text;
|
||||
/** a stage host call through the page's one action */
|
||||
async function stage(name, args) {
|
||||
const res = await tool("action", { name: "rt.call", args: { name, args } });
|
||||
const t = text(res);
|
||||
let v;
|
||||
try {
|
||||
v = t ? JSON.parse(t) : res;
|
||||
} catch {
|
||||
// the window's own answer when the page didn't answer in time (a stage busy opening a file): an error, retried
|
||||
// by `until`
|
||||
throw new Error(`${name}: ${t}`);
|
||||
}
|
||||
if (v && typeof v === "object" && "error" in v && Object.keys(v).length === 1) throw new Error(`${name}: ${v.error}`);
|
||||
return v?.value !== undefined && Object.keys(v).length === 1 ? v.value : v;
|
||||
}
|
||||
/** the stage's status, asked again while the page is too busy to answer (up to a minute) */
|
||||
async function status() {
|
||||
const end = Date.now() + 60_000;
|
||||
for (;;) {
|
||||
try {
|
||||
return await stage("stage.status", null);
|
||||
} catch (e) {
|
||||
if (Date.now() > end) throw e;
|
||||
await new Promise((ok) => setTimeout(ok, 50));
|
||||
}
|
||||
}
|
||||
}
|
||||
async function png(file) {
|
||||
const res = await tool("frame_png");
|
||||
const data = res?.content?.find((c) => c.type === "image")?.data;
|
||||
if (!data) throw new Error("frame_png: no image");
|
||||
writeFileSync(file, Buffer.from(data, "base64"));
|
||||
}
|
||||
const pause = (ms) => new Promise((ok) => setTimeout(ok, ms));
|
||||
/** until `check` answers, polling the stage's status; the bound is the work's own (an opening can bundle for seconds) */
|
||||
async function until(what, check, ms) {
|
||||
const end = Date.now() + ms;
|
||||
for (;;) {
|
||||
let s;
|
||||
try {
|
||||
s = await status();
|
||||
} catch (e) {
|
||||
if (Date.now() > end) throw e;
|
||||
await pause(50);
|
||||
continue;
|
||||
}
|
||||
if (s?.error) throw new Error(`${what}: the stage says ${s.error}`);
|
||||
if (check(s)) return s;
|
||||
if (Date.now() > end) throw new Error(`${what}: not within ${ms} ms (status ${JSON.stringify(s)})`);
|
||||
await pause(5);
|
||||
}
|
||||
}
|
||||
|
||||
const result = { case: { fileA, fileB, prop, value, frame: N, size: [W, H] }, steps: [] };
|
||||
// the draws captured: every one up to 8, then 12, 16, 24, 32, 48, 64, ... and the last
|
||||
const KS = new Set([...Array.from({ length: Math.min(UPDATES, 9) }, (_, k) => k), ...[12, 16, 24, 32, 48, 64, 96, 128].filter((k) => k < UPDATES), UPDATES - 1]);
|
||||
/** the frame drawn again `UPDATES` times (k = 0 is the draw that put it there), captured after the draws in KS */
|
||||
async function captures(tag) {
|
||||
for (let k = 0; k < UPDATES; k++) {
|
||||
if (k > 0) {
|
||||
const was = (await status()).painted;
|
||||
await stage("stage.pointer", { x: 1 + (k % 2), y: 1, down: false });
|
||||
await until(`${tag} update ${k}`, (s) => s.painted > was, 30_000);
|
||||
}
|
||||
if (!KS.has(k)) continue;
|
||||
// the window composites the stage's newest frame on its next frame: two window frames on, so the capture is it
|
||||
await tool("frame_png");
|
||||
await png(`${out}/${tag}-${k}.png`);
|
||||
console.error(`captured ${tag}-${k}`);
|
||||
}
|
||||
}
|
||||
const pct = (xs, p) => {
|
||||
const v = [...xs].sort((a, b) => a - b);
|
||||
return v.length ? Math.round(v[Math.min(v.length - 1, Math.floor((p / 100) * v.length))] * 10) / 10 : null;
|
||||
};
|
||||
async function show(file, tag) {
|
||||
const t0 = Date.now();
|
||||
// answered once sent; an answer that didn't come back in time (the stage thread opening the last file) is waited
|
||||
// out by the status below
|
||||
await stage("stage.show", { src: file, w: W, h: H, render: RENDER }).catch((e) => console.error(`show: ${e.message}`));
|
||||
await until(`${tag} opened`, (s) => s.showing === file && s.painted > 0, 180_000);
|
||||
const opened = Date.now() - t0;
|
||||
await stage("stage.play", { on: false });
|
||||
const was = (await status()).painted;
|
||||
await stage("stage.seek", { frame: N });
|
||||
const s = await until(`${tag} at ${N}`, (s) => s.frame === N && s.painted > was && !s.playing, 60_000);
|
||||
result.steps.push({ tag, opened_ms: opened, frame: s.frame });
|
||||
await captures(tag);
|
||||
}
|
||||
|
||||
try {
|
||||
const state = JSON.parse(text(await tool("state")) ?? "{}");
|
||||
result.window = state.window ?? null;
|
||||
result.scale = state.scale ?? null;
|
||||
await show(fileA, "a");
|
||||
// the props on the running world: from the call to the stage's next painted frame
|
||||
const was = (await status()).painted;
|
||||
const t0 = performance.now();
|
||||
const answer = await stage("stage.props", { props: { [prop]: value } });
|
||||
const answered = performance.now() - t0;
|
||||
await until("props drawn", (s) => s.painted > was, 30_000);
|
||||
const after = await status();
|
||||
result.props_ms = { answered: Math.round(answered), painted: Math.round(performance.now() - t0), stage: after.props?.ms ?? null, answer };
|
||||
result.held = answer?.held ?? null;
|
||||
await captures("ab");
|
||||
// props, then the frame seeked to again behind them (the app sends the seek without waiting for the props' answer;
|
||||
// here it follows the answer, so the time is an upper bound by one round trip)
|
||||
const was2 = (await status()).painted;
|
||||
const t1 = performance.now();
|
||||
await stage("stage.props", { props: { [prop]: value } });
|
||||
await stage("stage.seek", { frame: N });
|
||||
await until("props and seek drawn", (s) => s.painted >= was2 + 2 && s.frame === N, 30_000);
|
||||
result.props_seek_ms = Math.round(performance.now() - t1);
|
||||
await captures("abs");
|
||||
// a drag: each change waited for until painted
|
||||
const wall = [], own = [];
|
||||
for (let i = 0; i < DRAGS; i++) {
|
||||
const v = i % 2 === 0 ? was0 : value;
|
||||
const w = (await status()).painted;
|
||||
const t = performance.now();
|
||||
await stage("stage.props", { props: { [prop]: v } });
|
||||
const s = await until(`drag ${i}`, (s) => s.painted > w && s.props?.ms > 0, 30_000);
|
||||
wall.push(performance.now() - t);
|
||||
own.push(s.props.ms);
|
||||
}
|
||||
result.drag = { n: DRAGS, wall_p50: pct(wall, 50), wall_p95: pct(wall, 95), stage_p50: pct(own, 50), stage_p95: pct(own, 95), stage_max: pct(own, 100) };
|
||||
console.error(`drag ${JSON.stringify(result.drag)}`);
|
||||
// a burst, ending on B (the drag ended on B too: the frame is compared against B's render either way)
|
||||
if (BURST > 0) {
|
||||
const s0 = await status();
|
||||
const calls = Array.from({ length: BURST }, (_, i) => ({ name: "stage.props", args: { props: { [prop]: (BURST - 1 - i) % 2 === 0 ? value : was0 } } }));
|
||||
const t = performance.now();
|
||||
const res = await tool("action", { name: "rt.calls", args: { calls } });
|
||||
const answers = JSON.parse(text(res) ?? "null");
|
||||
const answered = performance.now() - t;
|
||||
// each props set is passed over or drawn (painted in the stage's turn that took it)
|
||||
const s1 = await until("burst drawn", (s) => s.props.drawn + s.props.dropped >= s0.props.drawn + s0.props.dropped + BURST, 30_000);
|
||||
const list = Array.isArray(answers) ? answers : answers?.value;
|
||||
result.burst = { sent: BURST, answered_ms: Math.round(answered), dropped: s1.props.dropped - s0.props.dropped, drawn: s1.props.drawn - s0.props.drawn, ends_on: s1.values?.[prop], dropped_answers: Array.isArray(list) ? list.filter((a) => a?.value?.dropped).length : null };
|
||||
console.error(`burst ${JSON.stringify(result.burst)}`);
|
||||
await tool("frame_png");
|
||||
await png(`${out}/burst-0.png`);
|
||||
}
|
||||
// the copy written with B: taken in place, or opened when the 3D held the value
|
||||
{
|
||||
const s0 = await status();
|
||||
const t = performance.now();
|
||||
await stage("stage.show", { src: fileB, w: W, h: H, render: RENDER }).catch((e) => console.error(`adopt: ${e.message}`));
|
||||
const s1 = await until("copy shown", (s) => s.showing === fileB && (s.adopted > s0.adopted || s.opens > s0.opens) && s.painted > 0, 180_000);
|
||||
let s2 = s1;
|
||||
if (s1.opens > s0.opens) {
|
||||
// opened: paused and seeked back to N, as the app's useStage does after a reopen
|
||||
await stage("stage.play", { on: false });
|
||||
const w = (await status()).painted;
|
||||
await stage("stage.seek", { frame: N });
|
||||
s2 = await until("reopened at N", (s) => s.frame === N && s.painted > w && !s.playing, 60_000);
|
||||
} else await until("adopted drawn", (s) => s.painted > s0.painted, 30_000);
|
||||
result.adopt = { how: s1.last_show?.how, stage_ms: s1.last_show?.ms, wall_ms: Math.round(performance.now() - t), frame: s2.frame, playing: s2.playing, values: s2.values?.[prop] };
|
||||
console.error(`adopt ${JSON.stringify(result.adopt)}`);
|
||||
await captures("ad");
|
||||
}
|
||||
await stage("stage.show", { src: null, w: W, h: H }).catch((e) => console.error(`clear: ${e.message}`));
|
||||
await until("cleared", (s) => s.showing == null, 30_000);
|
||||
await show(fileB, "b");
|
||||
result.status = await status();
|
||||
result.ok = true;
|
||||
} catch (e) {
|
||||
result.ok = false;
|
||||
result.error = String(e?.message ?? e);
|
||||
console.error(`FAIL ${result.error}`);
|
||||
}
|
||||
writeFileSync(`${out}/stage.json`, JSON.stringify(result, null, 1));
|
||||
console.log(JSON.stringify({ ok: result.ok, props_ms: result.props_ms, props_seek_ms: result.props_seek_ms, held: result.held, drag: result.drag, burst: result.burst, adopt: result.adopt, steps: result.steps, window: result.window, scale: result.scale, error: result.error }));
|
||||
process.exit(result.ok ? 0 : 1);
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
# Is the live frame the render's frame? (docs/realtime.feature RT0a, RT0b; the plan's experiment 1.) For each case: the
|
||||
# composition shown on the engine's stage in a headless raea window, paused on frame N, then one control changed with
|
||||
# stage.props on that running world; against `raea render --frame N` of the same file and of the copy with the new
|
||||
# value written into its defaultProps. SSIM (ffmpeg's, over RGB) between:
|
||||
# a the stage on the file as written and its render: the stage against the render, no change
|
||||
# ab the stage after stage.props {PROP: B} and the copy's render: a props change on the running world
|
||||
# abs the same, the frame then seeked to again (what the app sends after props on a paused stage), and the
|
||||
# copy's render: what experiment 1 measures; and against the copy shown fresh on the stage
|
||||
# b the copy shown fresh and the copy's render
|
||||
# each after every one of UPDATES draws of the frame (k = 0 is the draw the seek or the props made): a ray-traced
|
||||
# frame's history converges over draws, and the first k at SSIM >= 0.995 is reported. A row:
|
||||
# FILE PROP A B FRAME UPDATES [SEED|-] [seq] (B as JSON; SEED: RAEA_SEED for the window, so a live session takes
|
||||
# the render's seed; seq: also against frame N of a run rendering 0 to N;
|
||||
# rows from RT_ROWS, default bench/realtime/stage.tsv)
|
||||
# bash bench/realtime/stage.sh [ROW-SUBSTRING...] RAEA_BIN, RAEA_PAGE_HOST_BIN: the binaries (target/release's);
|
||||
# RT_OUT: where pictures go; RT_PORT: the window's MCP port (7631)
|
||||
# Headless only: the window is raea-page-host without --window, on its own port, its sound off.
|
||||
cd "$(dirname "$0")/../.." || exit 2
|
||||
ROOT=$PWD
|
||||
export RAEA_SIGN=0 RAEA_MARK=0 RAEA_AUDIO_MUTE=1 RAEA_HOME=$ROOT
|
||||
BIN=${RAEA_BIN:-$ROOT/target/release/raea}
|
||||
HOST=${RAEA_PAGE_HOST_BIN:-$ROOT/target/release/raea-page-host}
|
||||
ROWS=${RT_ROWS:-$ROOT/bench/realtime/stage.tsv}
|
||||
PORT=${RT_PORT:-7631}
|
||||
OUT=${RT_OUT:-$(mktemp -d "${TMPDIR:-/tmp}/raea-rt-stage.XXXXXX")}
|
||||
mkdir -p "$OUT"
|
||||
bun "$ROOT/bench/realtime/stage/build.ts" "$OUT/page.js" || { echo "FAIL the stage page didn't build"; exit 1; }
|
||||
ssim() { ffmpeg -nostdin -hide_banner -nostats -i "$1" -i "$2" -lavfi "[0:v]format=rgb24[a];[1:v]format=rgb24[b];[a][b]ssim" -f null - 2>&1 | grep -o 'All:[0-9.]*' | cut -d: -f2; }
|
||||
dim() { grep '<Composition' "$1" | head -1 | grep -oE "$2=\{[0-9]+\}" | head -1 | tr -dc 0-9; }
|
||||
host=""
|
||||
copies=()
|
||||
stop() {
|
||||
[ -n "$host" ] && kill "$host" 2>/dev/null
|
||||
for c in "${copies[@]+"${copies[@]}"}"; do rm -f -- "$c"; done
|
||||
}
|
||||
trap stop EXIT
|
||||
pass=0 fail=0
|
||||
while IFS=$'\t' read -r path prop a b frame updates seed seq; do
|
||||
[[ -z $path || $path == \#* ]] && continue
|
||||
if [ $# -gt 0 ]; then hit=0; for s in "$@"; do [[ $path == *"$s"* ]] && hit=1; done; [ $hit = 1 ] || continue; fi
|
||||
[[ $path == /* ]] && src=$path || src=$ROOT/$path
|
||||
[ "$seed" = - ] && seed=""
|
||||
slug=$(basename "$src" .tsx)${seed:+-seed}
|
||||
dir=$OUT/$slug && rm -rf "${dir:?}" && mkdir -p "$dir"
|
||||
w=$(dim "$src" width); h=$(dim "$src" height)
|
||||
# the copy with B written into its defaultProps, beside the file (its imports resolve as the file's): as an edit's
|
||||
# draft is written (the app's host/draft.ts), and removed when this ends
|
||||
copy=$(dirname "$src")/.rt-$slug-b.tsx
|
||||
copies+=("$copy")
|
||||
PROP=$prop A=$a B=$b perl -0pe 's/(defaultProps=\{\{[^}]*\b\Q$ENV{PROP}\E:\s*)\Q$ENV{A}\E/$1$ENV{B}/' "$src" > "$copy"
|
||||
if cmp -s "$src" "$copy"; then echo "FAIL $path: couldn't write $prop: $b into its defaultProps"; fail=$((fail + 1)); continue; fi
|
||||
# the renders: the frame alone, in a process of its own (a still: `render --frame N`); with seq also frames 0 to N
|
||||
# in one run (`--at 0,...,N`), frame N as a film's render reaches it, one update a frame
|
||||
for v in a b; do
|
||||
f=$src; [ $v = b ] && f=$copy
|
||||
t0=$(perl -MTime::HiRes=time -e 'printf "%.3f", time')
|
||||
(cd "$(dirname "$src")" && RAEA_READBACK=rgba "$BIN" render "$f" --frame "$frame" -o "$dir/render-$v.png") > "$dir/render-$v.log" 2>&1 || echo "note $path: render $v exited 1 (its checks found errors; the picture is still compared): $(grep -m1 -E "^raea: error" "$dir/render-$v.log" | cut -c1-160)"
|
||||
[ -f "$dir/render-$v.png" ] || { echo "FAIL $path: render $v: $(grep -m1 -E 'REFUSED|error' "$dir/render-$v.log" | cut -c1-200)"; fail=$((fail + 1)); continue 2; }
|
||||
echo "render-$v $(perl -MTime::HiRes=time -e "printf '%.2f', time - $t0") s" >> "$dir/times.txt"
|
||||
if [ "$seq" = seq ]; then
|
||||
(cd "$(dirname "$src")" && RAEA_READBACK=rgba "$BIN" render "$f" --at "$(seq 0 "$frame" | paste -sd, -)" -o "$dir/seq-$v/") > "$dir/seq-$v.log" 2>&1
|
||||
[ -f "$dir/seq-$v/$(printf "frame-%05d.png" "$frame")" ] || { echo "FAIL $path: sequence render $v"; fail=$((fail + 1)); continue 2; }
|
||||
cp "$dir/seq-$v/$(printf 'frame-%05d.png' "$frame")" "$dir/film-$v.png"
|
||||
rm -rf "${dir:?}/seq-$v"
|
||||
fi
|
||||
done
|
||||
echo "rendered $path frame $frame: $(tr '\n' ' ' < "$dir/times.txt")"
|
||||
# the window: one window point a stage pixel, the stage at the composition's size
|
||||
[ -n "$host" ] && kill "$host" 2>/dev/null && wait "$host" 2>/dev/null
|
||||
if lsof -nP -iTCP:"$PORT" -sTCP:LISTEN -t >/dev/null; then echo "FAIL port $PORT is in use (RT_PORT)"; exit 1; fi
|
||||
( [ -n "$seed" ] && export RAEA_SEED=$seed; RAEA_PAGE_MCP_PORT=$PORT exec "$HOST" "$OUT/page.js" --size "${w}x$h" ) > "$dir/page.log" 2>&1 &
|
||||
host=$!
|
||||
curl -s --retry 120 --retry-connrefused --retry-delay 1 --retry-max-time 120 -o /dev/null "http://127.0.0.1:$PORT/" || { echo "FAIL $path: the window didn't start: $(tail -2 "$dir/page.log")"; exit 1; }
|
||||
# its progress a line a capture on stderr (kept in stage.err), so a long converging row is seen moving
|
||||
if ! node "$ROOT/bench/realtime/stage.mjs" "$PORT" "$dir" "$src" "$copy" "$prop" "$b" "$frame" "$w" "$h" "${updates:-3}" > "$dir/stage.out" 2> >(tee "$dir/stage.err" >&2); then
|
||||
echo "FAIL $path: the stage: $(grep -m1 FAIL "$dir/stage.err" | cut -c1-240)"; fail=$((fail + 1)); continue
|
||||
fi
|
||||
# each capture against the renders: columns k, a~render-a, ab~render-b, abs~render-b, abs~b, b~render-b, and with
|
||||
# seq a~film-a, abs~film-b, b~film-b
|
||||
for k in $(ls "$dir" | sed -n 's/^a-\([0-9]*\)\.png$/\1/p' | sort -n); do
|
||||
row="$k\t$(ssim "$dir/a-$k.png" "$dir/render-a.png")\t$(ssim "$dir/ab-$k.png" "$dir/render-b.png")\t$(ssim "$dir/abs-$k.png" "$dir/render-b.png")\t$(ssim "$dir/abs-$k.png" "$dir/b-$k.png")\t$(ssim "$dir/b-$k.png" "$dir/render-b.png")"
|
||||
[ "$seq" = seq ] && row="$row\t$(ssim "$dir/a-$k.png" "$dir/film-a.png")\t$(ssim "$dir/abs-$k.png" "$dir/film-b.png")\t$(ssim "$dir/b-$k.png" "$dir/film-b.png")"
|
||||
echo -e "$row" >> "$dir/ssim.tsv"
|
||||
done
|
||||
# the first draw at which a column comes within 0.995 and 1.000000, and its value at the first and last draw
|
||||
first() { awk -F'\t' -v c="$1" -v t="$2" '$c + 0 >= t { print $1; f = 1; exit } END { if (!f) print "never" }' "$dir/ssim.tsv"; }
|
||||
ends() { awk -F'\t' -v c="$1" 'NR == 1 { a = $c } { z = $c; k = $1 } END { printf "%s (k0) .. %s (k%s)", a, z, k }' "$dir/ssim.tsv"; }
|
||||
ms=$(node -e 'const r=require(process.argv[1]); console.log(`${r.props_ms ? r.props_ms.painted : "none"} ms, props+seek->painted ${r.props_seek_ms ?? "none"} ms`)' "$dir/stage.json")
|
||||
echo "ROW $path${seed:+ (seed $seed)} $prop=$b frame $frame: stage~render a $(ends 2); props alone ab $(ends 3); props+seek abs $(ends 4) (>= 0.995 at k=$(first 4 0.995), 1 at k=$(first 4 1)); abs~fresh b $(ends 5); fresh b $(ends 6) (>= 0.995 at k=$(first 6 0.995)); props->painted $ms"
|
||||
[ "$seq" = seq ] && echo "ROW $path against the film's frame (render --at 0..$frame): a $(ends 7); abs $(ends 8) (>= 0.995 at k=$(first 8 0.995)); fresh b $(ends 9) (>= 0.995 at k=$(first 9 0.995))"
|
||||
pass=$((pass + 1))
|
||||
done < "$ROWS"
|
||||
echo "stage = render: $pass rows measured, $fail failed (out: $OUT)"
|
||||
[ $fail = 0 ]
|
||||
@@ -0,0 +1,15 @@
|
||||
# The realtime bench's stage rows (stage.sh): a composition with one control in its defaultProps, the value it is
|
||||
# changed to on the running stage, the frame compared and how many draws of it are captured. Tab-separated:
|
||||
# path the composition, from the repo root (or absolute: a copy outside the repo)
|
||||
# prop the control, a key of its <Composition defaultProps>
|
||||
# a its value as written (as the source spells it)
|
||||
# b the value set with stage.props, as JSON (and written into the copy's defaultProps as spelled)
|
||||
# frame the frame compared
|
||||
# updates draws of the frame captured (1 for a frame drawn at once; many for ray-traced light converging)
|
||||
# seed optional: RAEA_SEED for the window, so the live session takes the render's seed
|
||||
bench/realtime/cases/title.tsx hue 210 30 75 3
|
||||
bench/realtime/cases/random.tsx hue 210 30 75 2
|
||||
bench/realtime/cases/random.tsx hue 210 30 75 2 340724834
|
||||
bench/realtime/cases/raster.tsx color "#d04a3a" "#3ac06a" 75 4
|
||||
bench/realtime/cases/caption.tsx color "#d04a3a" "#3ac06a" 75 4
|
||||
bench/realtime/cases/solari.tsx glow 600 2400 75 65 - seq
|
||||
|
@@ -0,0 +1,36 @@
|
||||
// The stage page (page.tsx) bundled for raea-page-host as ui-parity bundles a case's Bevy side
|
||||
// (sdk/ui/parity/build.ts): @raea/ui from the tree, React DOM swapped for its adapter, parity's one React.
|
||||
// bun bench/realtime/stage/build.ts OUT.js
|
||||
import { join } from "node:path";
|
||||
|
||||
const here = import.meta.dir;
|
||||
const parity = join(here, "../../../sdk/ui/parity");
|
||||
const mods = join(parity, "node_modules");
|
||||
const ui = join(here, "../../../sdk/ui/src");
|
||||
const out = process.argv[2];
|
||||
if (!out) {
|
||||
console.error("usage: bun build.ts OUT.js");
|
||||
process.exit(2);
|
||||
}
|
||||
const b = await Bun.build({
|
||||
entrypoints: [join(here, "page.tsx")],
|
||||
target: "browser",
|
||||
format: "iife",
|
||||
minify: { syntax: true },
|
||||
define: { "process.env.NODE_ENV": '"production"' },
|
||||
plugins: [
|
||||
{
|
||||
name: "rt-stage",
|
||||
setup(b) {
|
||||
b.onResolve({ filter: /^react-dom(\/client)?$/ }, () => ({ path: join(parity, "probe/react-dom-bevy.ts") }));
|
||||
b.onResolve({ filter: /^@raea\/ui(\/.*)?$/ }, (a) => ({ path: join(ui, (a.path.slice("@raea/ui/".length) || "index") + ".ts") }));
|
||||
b.onResolve({ filter: /^(react|react-dom|react-reconciler|scheduler)(\/.*)?$/ }, (a) => ({ path: Bun.resolveSync(a.path, mods + "/") }));
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
if (!b.success) {
|
||||
console.error(b.logs.map((l) => String(l)).join("\n"));
|
||||
process.exit(1);
|
||||
}
|
||||
await Bun.write(out, await b.outputs[0].text());
|
||||
@@ -0,0 +1,35 @@
|
||||
// The page the realtime bench drives (bench/realtime/stage.sh): nothing but the engine's stage, its image filling the
|
||||
// window at one window point a stage pixel, so a capture of the window is the stage's own frame. One action,
|
||||
// `rt.call {name, args}`, makes any stage host call (engine/page/stage: stage.show, stage.seek, stage.props, ...) and
|
||||
// answers what it answered, so a driver outside the page plays the stage as the app's useStage does; `rt.calls
|
||||
// {calls: [{name, args}]}` makes several at once without waiting between them, as a drag sends props (each answer, in
|
||||
// order, and the milliseconds to each).
|
||||
import "@raea/ui/dom-globals";
|
||||
import { mount } from "@raea/ui/react";
|
||||
import { call, emit, on } from "@raea/ui/wire";
|
||||
|
||||
emit("actions", [
|
||||
{ name: "rt.call", about: "a stage host call: {name, args}", args: {} },
|
||||
{ name: "rt.calls", about: "several stage host calls sent at once: {calls: [{name, args}]}", args: {} },
|
||||
]);
|
||||
type One = { name: string; args?: unknown };
|
||||
on<{ id: number; name: string; args?: One & { calls?: One[] } }>("action", ({ id, name, args }) => {
|
||||
if (name === "rt.calls" && Array.isArray(args?.calls)) {
|
||||
const t0 = performance.now();
|
||||
const sent = args.calls.map((c) => call(c.name, c.args ?? null).then((value) => ({ value: value === undefined ? null : JSON.parse(JSON.stringify(value)), ms: performance.now() - t0 }), (e: unknown) => ({ error: String((e as Error)?.message ?? e), ms: performance.now() - t0 })));
|
||||
return void Promise.all(sent).then((value) => emit("actionDone", { id, value }));
|
||||
}
|
||||
if (name !== "rt.call" || !args?.name) return emit("actionDone", { id, error: `no action ${name}` });
|
||||
call(args.name, args.args ?? null).then(
|
||||
(value) => emit("actionDone", { id, value: value === undefined ? null : JSON.parse(JSON.stringify(value)) }),
|
||||
(e: unknown) => emit("actionDone", { id, error: String((e as Error)?.message ?? e) }),
|
||||
);
|
||||
});
|
||||
|
||||
mount(
|
||||
<div style={{ position: "absolute", left: 0, top: 0, width: "100%", height: "100%", margin: 0, background: "#000" }}>
|
||||
<img data-raea-stage="" data-testid="stage" alt="" style={{ position: "absolute", left: 0, top: 0, width: "100%", height: "100%" }} />
|
||||
</div>,
|
||||
undefined,
|
||||
{ dom: true },
|
||||
);
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# Does a window render cost the window or the whole film? (docs/realtime.feature RT1; the plan's experiment 2.) For each
|
||||
# row: a copy of the film with `edit={{ segments: [[FROM, TO]], scale: SCALE }}` on its composition, as the app's
|
||||
# host/draft.ts writes the seconds around the playhead, rendered as the host renders a draft (`raea render COPY -o
|
||||
# OUT.mp4 --quality draft`, from the film's folder) with RAEA_SIGN=0, RAEA_EXPORT_CACHE=0 (a draft is a file never
|
||||
# rendered before: the export cache can't have it) and RAEA_STARTUP_TRACE=1 RAEA_BAKE_TRACE=1:
|
||||
# cold RAEA_BUNDLE_CACHE=0 as well: bundled afresh, as a draft's new file is
|
||||
# warm the same copy again with its bundle cached, RUNS times (2)
|
||||
# signed once more as the host runs it, signing on (no RAEA_SIGN or RAEA_MARK), by RAEA_SIGNED_BIN (default
|
||||
# RAEA_BIN; the public raea has signing's seam and no signer, so pass the build the app runs), then the
|
||||
# file searched for a C2PA manifest (its "c2pa" JUMBF label), beside the cold run's; RT_VERIFY, a command,
|
||||
# also reads both. Only rows with `sign`: each signing is one call to the signer, which counts them
|
||||
# One line a run: wall seconds, the startup marks after the process began (bundled, the first frame, the 3D restart
|
||||
# and its first frame), the frame time raea reports, the video's frames and seconds (ffprobe), and RAEA_BAKE_TRACE's
|
||||
# line when a bake ran (none did on 11-16: a draft's fed render steps only its window's frames). A row:
|
||||
# FILE COMPOSITION FROM TO SCALE [sign] (rows from RT_WINDOW_ROWS, default bench/realtime/window.tsv)
|
||||
# bash bench/realtime/window.sh [ROW-SUBSTRING...] RAEA_BIN: the raea to run; RT_OUT: where videos go
|
||||
cd "$(dirname "$0")/../.." || exit 2
|
||||
ROOT=$PWD
|
||||
export RAEA_AUDIO_MUTE=1 RAEA_HOME=$ROOT RAEA_EXPORT_CACHE=0 RAEA_STARTUP_TRACE=1 RAEA_BAKE_TRACE=1
|
||||
BIN=${RAEA_BIN:-$ROOT/target/release/raea}
|
||||
ROWS=${RT_WINDOW_ROWS:-$ROOT/bench/realtime/window.tsv}
|
||||
RUNS=${RUNS:-2}
|
||||
OUT=${RT_OUT:-$(mktemp -d "${TMPDIR:-/tmp}/raea-rt-window.XXXXXX")}
|
||||
mkdir -p "$OUT"
|
||||
copies=()
|
||||
trap 'for c in "${copies[@]+"${copies[@]}"}"; do rm -f -- "$c"; done' EXIT
|
||||
now() { perl -MTime::HiRes=time -e 'printf "%.3f", time'; }
|
||||
# one render, timed; prints its line
|
||||
run() {
|
||||
local tag=$1 copy=$2 comp=$3 out=$4 log=$5; shift 5
|
||||
local t0 t1
|
||||
t0=$(now)
|
||||
(cd "$(dirname "$copy")" && env "$@" "$BIN" render "$copy" --composition "$comp" -o "$out" --quality draft) > "$log" 2>&1
|
||||
local rc=$?
|
||||
t1=$(now)
|
||||
# the startup marks, in seconds after the process's first ("main")
|
||||
local marks
|
||||
marks=$(awk '/^raea startup:/ { t = $3; sub(/^raea startup: [0-9.]+ ms /, ""); sub(/ \(gpu.*/, ""); if (!t0) t0 = t; printf "%s %.2f s; ", $0, (t - t0) / 1000 }' "$log")
|
||||
local per frames secs
|
||||
per=$(grep -oE '\([0-9.]+ ms a frame' "$log" | head -1 | tr -dc '0-9.')
|
||||
frames=$(ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of csv=p=0 "$out" 2>/dev/null)
|
||||
secs=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$out" 2>/dev/null)
|
||||
local bake
|
||||
bake=$(grep -m1 '^raea bake:' "$log" | sed 's/^raea bake: //')
|
||||
printf '%s\texit %s\t%.2f s\t%s ms a frame\t%s frames, %s s of video\tbake: %s\tstartup: %s\n' "$tag" "$rc" "$(echo "$t1 - $t0" | bc)" "${per:-?}" "${frames:-?}" "${secs:-?}" "${bake:-none}" "$marks"
|
||||
}
|
||||
while IFS=$'\t' read -r path comp from to scale sign; do
|
||||
[[ -z $path || $path == \#* ]] && continue
|
||||
if [ $# -gt 0 ]; then hit=0; for s in "$@"; do [[ "$path $comp" == *"$s"* ]] && hit=1; done; [ $hit = 1 ] || continue; fi
|
||||
[[ $path == /* ]] && src=$path || src=$ROOT/$path
|
||||
slug=$comp
|
||||
dir=$OUT/$slug && rm -rf "${dir:?}" && mkdir -p "$dir"
|
||||
copy=$(dirname "$src")/.rt-window-$slug.tsx
|
||||
copies+=("$copy")
|
||||
COMP=$comp EDIT="edit={{ segments: [[$from, $to]], scale: $scale }} " perl -pe 's/(<Composition id="\Q$ENV{COMP}\E" )/$1$ENV{EDIT}/' "$src" > "$copy"
|
||||
if cmp -s "$src" "$copy"; then echo "FAIL $path: no <Composition id=\"$comp\" to give the window"; continue; fi
|
||||
echo "ROW $path #$comp window [$from, $to) at scale $scale"
|
||||
run cold "$copy" "$comp" "$dir/cold.mp4" "$dir/cold.log" RAEA_SIGN=0 RAEA_BUNDLE_CACHE=0
|
||||
for ((i = 1; i <= RUNS; i++)); do run "warm$i" "$copy" "$comp" "$dir/warm$i.mp4" "$dir/warm$i.log" RAEA_SIGN=0; done
|
||||
if [ "$sign" = sign ]; then
|
||||
BIN=${RAEA_SIGNED_BIN:-$BIN} run signed "$copy" "$comp" "$dir/signed.mp4" "$dir/signed.log" -u RAEA_SIGN -u RAEA_MARK
|
||||
for v in cold signed; do
|
||||
n=$(LC_ALL=C grep -a -c c2pa "$dir/$v.mp4")
|
||||
echo "credentials $v: $([ "${n:-0}" -gt 0 ] && echo "a C2PA manifest" || echo none)${RT_VERIFY:+; $($RT_VERIFY "$dir/$v.mp4" 2>&1 | head -c 400)}"
|
||||
done
|
||||
fi
|
||||
done < "$ROWS"
|
||||
echo "videos and logs in $OUT"
|
||||
@@ -0,0 +1,5 @@
|
||||
# The window render's rows (window.sh): a film, its composition, the window drawn ([from, to) of its own frames) and
|
||||
# the scale it's drawn at, as the app's host/draft.ts makes a draft of the seconds around the playhead (a long side of
|
||||
# 960 px). `sign`: one more run with signing on, its Content Credentials read. Tab-separated.
|
||||
bench/realtime/cases/films.tsx film-60 900 1050 0.5 sign
|
||||
bench/realtime/cases/films.tsx film-180 900 1050 0.5
|
||||
|
Loaded 100 of 566 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user