Add rolling replay media pipeline

This commit is contained in:
Alvin-Zilverstand committed 2026-09-09 10:43:35 +02:00
1 parent 0338342051
commit af3e6c28e5
11 files changed
+3182 -130

No files matched your search

Generated
+1556
View File
File diff suppressed because it is too large. Load diff
+6
View File
@@ -13,6 +13,12 @@ path = "src/lib.rs"
name = "clipforge"
path = "src/main.rs"
[dependencies]
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "multipart", "rustls-tls"] }
rusqlite = { version = "0.32", features = ["bundled"] }
serde_json = "1"
sysinfo = "0.31"
[profile.dev]
debug = true
+551 -15
View File
@@ -8,6 +8,18 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "ahash"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
dependencies = [
"cfg-if",
"once_cell",
"version_check",
"zerocopy",
]
[[package]]
name = "aho-corasick"
version = "1.1.5"
@@ -315,6 +327,23 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "cfg_aliases"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
[[package]]
name = "chacha20"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
dependencies = [
"cfg-if",
"cpufeatures 0.3.1",
"rand_core",
]
[[package]]
name = "chrono"
version = "0.4.45"
@@ -330,6 +359,12 @@ dependencies = [
[[package]]
name = "clipforge"
version = "0.1.0"
dependencies = [
"reqwest 0.12.28",
"rusqlite",
"serde_json",
"sysinfo",
]
[[package]]
name = "clipforge-desktop"
@@ -410,6 +445,15 @@ dependencies = [
"libc",
]
[[package]]
name = "cpufeatures"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
dependencies = [
"libc",
]
[[package]]
name = "crc32fast"
version = "1.5.1"
@@ -428,6 +472,25 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.23"
@@ -732,6 +795,12 @@ version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
[[package]]
name = "either"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
[[package]]
name = "embed-resource"
version = "3.0.11"
@@ -769,6 +838,18 @@ dependencies = [
"typeid",
]
[[package]]
name = "fallible-iterator"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
[[package]]
name = "fallible-streaming-iterator"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "fastrand"
version = "2.5.0"
@@ -866,6 +947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
@@ -1046,8 +1128,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi",
"wasm-bindgen",
]
[[package]]
@@ -1069,8 +1153,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"r-efi 6.0.0",
"rand_core",
"wasm-bindgen",
]
[[package]]
@@ -1227,12 +1314,30 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
]
[[package]]
name = "hashbrown"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]]
name = "hashlink"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af"
dependencies = [
"hashbrown 0.14.5",
]
[[package]]
name = "heck"
version = "0.4.1"
@@ -1320,6 +1425,22 @@ dependencies = [
"want",
]
[[package]]
name = "hyper-rustls"
version = "0.27.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f"
dependencies = [
"http",
"hyper",
"hyper-util",
"rustls",
"tokio",
"tokio-rustls",
"tower-service",
"webpki-roots",
]
[[package]]
name = "hyper-util"
version = "0.1.20"
@@ -1753,6 +1874,17 @@ dependencies = [
"libc",
]
[[package]]
name = "libsqlite3-sys"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149"
dependencies = [
"cc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "litemap"
version = "0.8.3"
@@ -1774,6 +1906,12 @@ version = "0.4.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
[[package]]
name = "lru-slab"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
[[package]]
name = "markup5ever"
version = "0.38.0"
@@ -1806,6 +1944,16 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "miniz_oxide"
version = "0.8.9"
@@ -1888,6 +2036,15 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "ntapi"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"
dependencies = [
"winapi",
]
[[package]]
name = "num-conv"
version = "0.2.2"
@@ -2397,6 +2554,62 @@ dependencies = [
"memchr",
]
[[package]]
name = "quinn"
version = "0.11.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c1a41e437b6bbd489372cd4971de128e85c855f56c57f283d20ff016cf7c0a8"
dependencies = [
"bytes",
"cfg_aliases",
"pin-project-lite",
"quinn-proto",
"quinn-udp",
"rustc-hash",
"rustls",
"socket2",
"thiserror 2.0.20",
"tokio",
"tracing",
"web-time",
]
[[package]]
name = "quinn-proto"
version = "0.11.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04759210543be93709136e28212294a659ef5001836ff4eab4d663e4529bba83"
dependencies = [
"bytes",
"getrandom 0.4.3",
"lru-slab",
"rand",
"rand_pcg",
"ring",
"rustc-hash",
"rustls",
"rustls-pki-types",
"slab",
"thiserror 2.0.20",
"tinyvec",
"tracing",
"web-time",
]
[[package]]
name = "quinn-udp"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35a133f956daabe89a61a685c2649f13d82d5aa4bd5d12d1277e1072a21c0694"
dependencies = [
"cfg_aliases",
"libc",
"once_cell",
"socket2",
"tracing",
"windows-sys 0.61.2",
]
[[package]]
name = "quote"
version = "1.0.47"
@@ -2418,12 +2631,58 @@ version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]]
name = "rand"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"
dependencies = [
"chacha20",
"getrandom 0.4.3",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
[[package]]
name = "rand_pcg"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a"
dependencies = [
"rand_core",
]
[[package]]
name = "raw-window-handle"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539"
[[package]]
name = "rayon"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "redox_syscall"
version = "0.5.18"
@@ -2493,6 +2752,47 @@ version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
[[package]]
name = "reqwest"
version = "0.12.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"
dependencies = [
"base64 0.22.1",
"bytes",
"futures-channel",
"futures-core",
"futures-util",
"http",
"http-body",
"http-body-util",
"hyper",
"hyper-rustls",
"hyper-util",
"js-sys",
"log",
"mime_guess",
"percent-encoding",
"pin-project-lite",
"quinn",
"rustls",
"rustls-pki-types",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"tokio",
"tokio-rustls",
"tower",
"tower-http",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots",
]
[[package]]
name = "reqwest"
version = "0.13.4"
@@ -2527,6 +2827,34 @@ dependencies = [
"web-sys",
]
[[package]]
name = "ring"
version = "0.17.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
dependencies = [
"cc",
"cfg-if",
"getrandom 0.2.17",
"libc",
"untrusted",
"windows-sys 0.52.0",
]
[[package]]
name = "rusqlite"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e"
dependencies = [
"bitflags 2.13.1",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink",
"libsqlite3-sys",
"smallvec",
]
[[package]]
name = "rustc-hash"
version = "2.1.3"
@@ -2542,12 +2870,53 @@ dependencies = [
"semver",
]
[[package]]
name = "rustls"
version = "0.23.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba"
dependencies = [
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-pki-types"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"
dependencies = [
"web-time",
"zeroize",
]
[[package]]
name = "rustls-webpki"
version = "0.103.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"
dependencies = [
"ring",
"rustls-pki-types",
"untrusted",
]
[[package]]
name = "rustversion"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
[[package]]
name = "ryu"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
[[package]]
name = "same-file"
version = "1.0.6"
@@ -2738,6 +3107,18 @@ dependencies = [
"serde_core",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [
"form_urlencoded",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_with"
version = "3.23.0"
@@ -2809,7 +3190,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"cpufeatures 0.2.17",
"digest",
]
@@ -2937,6 +3318,12 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "subtle"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "swift-rs"
version = "1.0.8"
@@ -3000,6 +3387,20 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "sysinfo"
version = "0.31.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be"
dependencies = [
"core-foundation-sys",
"libc",
"memchr",
"ntapi",
"rayon",
"windows 0.57.0",
]
[[package]]
name = "system-deps"
version = "6.2.2"
@@ -3047,7 +3448,7 @@ dependencies = [
"tao-macros",
"unicode-segmentation",
"url",
"windows",
"windows 0.61.3",
"windows-core 0.61.2",
"windows-version",
"x11-dl",
@@ -3100,7 +3501,7 @@ dependencies = [
"percent-encoding",
"plist",
"raw-window-handle",
"reqwest",
"reqwest 0.13.4",
"serde",
"serde_json",
"serde_repr",
@@ -3118,7 +3519,7 @@ dependencies = [
"webkit2gtk",
"webview2-com",
"window-vibrancy",
"windows",
"windows 0.61.3",
]
[[package]]
@@ -3205,7 +3606,7 @@ dependencies = [
"url",
"webkit2gtk",
"webview2-com",
"windows",
"windows 0.61.3",
]
[[package]]
@@ -3230,7 +3631,7 @@ dependencies = [
"url",
"webkit2gtk",
"webview2-com",
"windows",
"windows 0.61.3",
"wry",
]
@@ -3401,6 +3802,16 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "tokio-rustls"
version = "0.26.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0c85f2c3ef0b1cd58b36682f4b17aaa995f0e5db534d85692b4903abce21f67"
dependencies = [
"rustls",
"tokio",
]
[[package]]
name = "tokio-util"
version = "0.7.19"
@@ -3679,6 +4090,12 @@ dependencies = [
"unic-common",
]
[[package]]
name = "unicase"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
[[package]]
name = "unicode-ident"
version = "1.0.24"
@@ -3691,6 +4108,12 @@ version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
[[package]]
name = "untrusted"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "url"
version = "2.5.8"
@@ -3734,6 +4157,12 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version-compare"
version = "0.2.1"
@@ -3878,6 +4307,16 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "web_atoms"
version = "0.2.6"
@@ -3934,6 +4373,15 @@ dependencies = [
"system-deps",
]
[[package]]
name = "webpki-roots"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "webview2-com"
version = "0.38.2"
@@ -3942,10 +4390,10 @@ checksum = "7130243a7a5b33c54a444e54842e6a9e133de08b5ad7b5861cd8ed9a6a5bc96a"
dependencies = [
"webview2-com-macros",
"webview2-com-sys",
"windows",
"windows 0.61.3",
"windows-core 0.61.2",
"windows-implement",
"windows-interface",
"windows-implement 0.60.2",
"windows-interface 0.59.3",
]
[[package]]
@@ -3966,7 +4414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "381336cfffd772377d291702245447a5251a2ffa5bad679c99e61bc48bacbf9c"
dependencies = [
"thiserror 2.0.20",
"windows",
"windows 0.61.3",
"windows-core 0.61.2",
]
@@ -4016,6 +4464,16 @@ dependencies = [
"windows-version",
]
[[package]]
name = "windows"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
dependencies = [
"windows-core 0.57.0",
"windows-targets 0.52.6",
]
[[package]]
name = "windows"
version = "0.61.3"
@@ -4038,14 +4496,26 @@ dependencies = [
"windows-core 0.61.2",
]
[[package]]
name = "windows-core"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
dependencies = [
"windows-implement 0.57.0",
"windows-interface 0.57.0",
"windows-result 0.1.2",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
dependencies = [
"windows-implement",
"windows-interface",
"windows-implement 0.60.2",
"windows-interface 0.59.3",
"windows-link 0.1.3",
"windows-result 0.3.4",
"windows-strings 0.4.2",
@@ -4057,8 +4527,8 @@ version = "0.62.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
dependencies = [
"windows-implement",
"windows-interface",
"windows-implement 0.60.2",
"windows-interface 0.59.3",
"windows-link 0.2.1",
"windows-result 0.4.1",
"windows-strings 0.5.1",
@@ -4075,6 +4545,17 @@ dependencies = [
"windows-threading",
]
[[package]]
name = "windows-implement"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "windows-implement"
version = "0.60.2"
@@ -4086,6 +4567,17 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "windows-interface"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "windows-interface"
version = "0.59.3"
@@ -4119,6 +4611,15 @@ dependencies = [
"windows-link 0.1.3",
]
[[package]]
name = "windows-result"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-result"
version = "0.3.4"
@@ -4164,6 +4665,15 @@ dependencies = [
"windows-targets 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
@@ -4405,7 +4915,7 @@ dependencies = [
"webkit2gtk",
"webkit2gtk-sys",
"webview2-com",
"windows",
"windows 0.61.3",
"windows-core 0.61.2",
"windows-version",
"x11-dl",
@@ -4455,6 +4965,26 @@ dependencies = [
"synstructure",
]
[[package]]
name = "zerocopy"
version = "0.8.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d35102a9f36d089ccae9e4c6802bc118be4487b80aaffc0ab4e0cf5ce92d2873"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146c01f5ab44258da43cf276c74a2763db2ff3969c9c652c3f2de07041d0b2bc"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "zerofrom"
version = "0.1.8"
@@ -4476,6 +5006,12 @@ dependencies = [
"synstructure",
]
[[package]]
name = "zeroize"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"
[[package]]
name = "zerotrie"
version = "0.2.5"
+150 -66
View File
@@ -1,12 +1,17 @@
use clipforge::capture::{
ffmpeg_is_available, find_ffmpeg_executable, CaptureBackend, CaptureConfig, CaptureSource,
EncoderPreference, FfmpegCaptureBackend,
EncoderPreference, FfmpegReplayCaptureBackend,
};
use clipforge::database::ClipDatabase;
use clipforge::game_detection::{default_profiles, detect_game};
use clipforge::media::{
collect_segments, concat_segments, generate_thumbnail, prune_old_segments, recent_segments,
trim_clip as ffmpeg_trim_clip,
};
use clipforge::game_detection::{default_profiles, detect_game, RunningProcess};
use clipforge::models::{Clip, ClipSource, RecordingStatus, UploadProvider};
use clipforge::recorder::{BufferSegment, RecorderAction, RecorderService};
use clipforge::recorder::{RecorderAction, RecorderService};
use clipforge::settings::AppSettings;
use clipforge::storage::{clip_path, is_inside_root, write_placeholder_mp4, LibraryPaths};
use clipforge::storage::{clip_path, is_inside_root, LibraryPaths};
use serde::Serialize;
use std::env;
use std::fs;
@@ -18,14 +23,17 @@ use tauri::State;
struct AppRuntime {
recorder: Mutex<RecorderService>,
database: Mutex<ClipDatabase>,
capture: Mutex<Option<ActiveCapture>>,
}
#[derive(Debug)]
struct ActiveCapture {
output_path: PathBuf,
buffer_dir: PathBuf,
session_output_path: PathBuf,
segment_duration: Duration,
started_at: SystemTime,
backend: FfmpegCaptureBackend,
backend: FfmpegReplayCaptureBackend,
}
#[derive(Debug, Serialize)]
@@ -55,6 +63,7 @@ struct ClipDto {
created_at: String,
upload_state: String,
path: String,
thumbnail_path: Option<String>,
tags: Vec<String>,
color_class: String,
}
@@ -75,7 +84,24 @@ fn list_clips(runtime: State<'_, AppRuntime>) -> Result<Vec<ClipDto>, String> {
#[tauri::command]
fn save_manual_clip(seconds: u64, runtime: State<'_, AppRuntime>) -> Result<ClipDto, String> {
let mut recorder = runtime.recorder.lock().map_err(|error| error.to_string())?;
let capture = runtime.capture.lock().map_err(|error| error.to_string())?;
let Some(active) = capture.as_ref() else {
return Err("Start recording before saving a replay clip.".to_string());
};
let ffmpeg = find_ffmpeg_executable()
.ok_or_else(|| "FFmpeg was not found on PATH or in the bundled sidecar.".to_string())?;
let now = SystemTime::now();
let segment_paths = recent_segments(
&active.buffer_dir,
Duration::from_secs(seconds),
active.segment_duration,
now,
)
.map_err(|error| error.to_string())?;
if segment_paths.is_empty() {
return Err("The replay buffer has not produced any segments yet.".to_string());
}
let action = recorder
.save_manual_clip(Duration::from_secs(seconds), now)
.ok_or_else(|| "No active recording session is available.".to_string())?;
@@ -92,7 +118,22 @@ fn save_manual_clip(seconds: u64, runtime: State<'_, AppRuntime>) -> Result<Clip
.cloned()
.ok_or_else(|| "Created clip was not found in the library.".to_string())?;
write_placeholder_mp4(&clip.path, &clip.id).map_err(|error| error.to_string())?;
if let Err(error) = concat_segments(&ffmpeg, &segment_paths, &clip.path) {
recorder.library.remove_clip(&clip.id);
if let Ok(database) = runtime.database.lock() {
let _ = database.delete_clip(&clip.id);
}
return Err(error.to_string());
}
if let Some(thumbnail_path) = &clip.thumbnail_path {
let _ = generate_thumbnail(&ffmpeg, &clip.path, thumbnail_path);
}
let _ = prune_old_segments(
&active.buffer_dir,
recorder.settings.replay_buffer,
active.segment_duration,
);
persist_clip(&runtime, &clip)?;
save_manifest(&recorder)?;
Ok(clip_to_dto(&clip))
}
@@ -119,9 +160,13 @@ fn start_capture(runtime: State<'_, AppRuntime>) -> Result<DesktopStatus, String
.active_session_id
.clone()
.ok_or_else(|| "Recorder session did not start.".to_string())?;
let output_dir = recorder.paths.sessions_root.join(&session_id);
fs::create_dir_all(&output_dir).map_err(|error| error.to_string())?;
let output_path = output_dir.join(format!("session-{}.mp4", unix_millis(now)));
let session_dir = recorder.paths.sessions_root.join(&session_id);
let buffer_dir = recorder.paths.buffer_root.join(&session_id);
fs::create_dir_all(&session_dir).map_err(|error| error.to_string())?;
fs::create_dir_all(&buffer_dir).map_err(|error| error.to_string())?;
let session_output_path = session_dir.join(format!("session-{}.mp4", unix_millis(now)));
let segment_duration = Duration::from_secs(5);
let segment_pattern = buffer_dir.join("segment-%05d.mp4");
let config = CaptureConfig {
source: CaptureSource::Desktop,
@@ -130,12 +175,17 @@ fn start_capture(runtime: State<'_, AppRuntime>) -> Result<DesktopStatus, String
fps: recorder.settings.quality.fps,
bitrate_kbps: recorder.settings.quality.bitrate_kbps,
encoder: EncoderPreference::HardwareH264,
system_audio_enabled: true,
mic_enabled: recorder.settings.privacy.mic_enabled,
system_audio_device: None,
mic_device: None,
};
let mut backend = FfmpegCaptureBackend::new(ffmpeg, &output_path);
let mut backend = FfmpegReplayCaptureBackend::new(ffmpeg, &segment_pattern, segment_duration);
backend.start(config).map_err(|error| error.to_string())?;
*capture = Some(ActiveCapture {
output_path,
buffer_dir,
session_output_path,
segment_duration,
started_at: now,
backend,
});
@@ -150,7 +200,30 @@ fn stop_capture(runtime: State<'_, AppRuntime>) -> Result<DesktopStatus, String>
if let Some(mut active) = capture.take() {
active.backend.stop().map_err(|error| error.to_string())?;
add_session_clip(&mut recorder, active.output_path, active.started_at, SystemTime::now())?;
let ffmpeg = find_ffmpeg_executable()
.ok_or_else(|| "FFmpeg was not found on PATH or in the bundled sidecar.".to_string())?;
let segments = collect_segments(&active.buffer_dir)
.map_err(|error| error.to_string())?
.into_iter()
.map(|segment| segment.path)
.collect::<Vec<_>>();
if !segments.is_empty() {
concat_segments(&ffmpeg, &segments, &active.session_output_path)
.map_err(|error| error.to_string())?;
let clip = add_session_clip(
&mut recorder,
active.session_output_path,
active.started_at,
SystemTime::now(),
)?;
if let Some(thumbnail_path) = &clip.thumbnail_path {
let _ = generate_thumbnail(&ffmpeg, &clip.path, thumbnail_path);
}
persist_clip(&runtime, &clip)?;
}
if is_inside_root(&recorder.paths.buffer_root, &active.buffer_dir) {
let _ = fs::remove_dir_all(&active.buffer_dir);
}
}
if matches!(recorder.state.status, RecordingStatus::RecordingSession) {
@@ -172,7 +245,13 @@ fn delete_clip(clip_id: String, runtime: State<'_, AppRuntime>) -> Result<Vec<Cl
if can_delete_file && clip.path.exists() {
fs::remove_file(&clip.path).map_err(|error| error.to_string())?;
}
if let Some(thumbnail_path) = &clip.thumbnail_path {
if is_inside_root(&recorder.paths.thumbs_root, thumbnail_path) && thumbnail_path.exists() {
fs::remove_file(thumbnail_path).map_err(|error| error.to_string())?;
}
}
delete_clip_record(&runtime, &clip_id)?;
save_manifest(&recorder)?;
Ok(recorder.library.all().iter().map(clip_to_dto).collect())
}
@@ -234,27 +313,14 @@ fn trim_clip(
fs::create_dir_all(parent).map_err(|error| error.to_string())?;
}
let status = Command::new(ffmpeg)
.args([
"-y",
"-hide_banner",
"-loglevel",
"error",
"-ss",
&format!("{start_seconds:.3}"),
"-to",
&format!("{end_seconds:.3}"),
"-i",
&source_clip.path.display().to_string(),
"-c",
"copy",
&output_path.display().to_string(),
])
.status()
.map_err(|error| error.to_string())?;
if !status.success() {
return Err("FFmpeg could not trim this clip.".to_string());
}
ffmpeg_trim_clip(
&ffmpeg,
&source_clip.path,
&output_path,
start_seconds,
end_seconds,
)
.map_err(|error| error.to_string())?;
let clip = Clip {
id: trimmed_id,
@@ -279,7 +345,11 @@ fn trim_clip(
upload_url: None,
upload_provider: None,
};
if let Some(thumbnail_path) = &clip.thumbnail_path {
let _ = generate_thumbnail(&ffmpeg, &clip.path, thumbnail_path);
}
recorder.library.add_clip(clip.clone());
persist_clip(&runtime, &clip)?;
save_manifest(&recorder)?;
Ok(clip_to_dto(&clip))
}
@@ -294,22 +364,25 @@ fn upload_clip(clip_id: String, runtime: State<'_, AppRuntime>) -> Result<ClipDt
{
return Err(format!("Clip {clip_id} was not found."));
}
save_manifest(&recorder)?;
recorder
let clip = recorder
.library
.all()
.iter()
.find(|clip| clip.id == clip_id)
.map(clip_to_dto)
.ok_or_else(|| format!("Clip {clip_id} was not found."))
.cloned()
.ok_or_else(|| format!("Clip {clip_id} was not found."))?;
persist_clip(&runtime, &clip)?;
save_manifest(&recorder)?;
Ok(clip_to_dto(&clip))
}
fn main() {
let recorder = create_boot_recorder();
let (recorder, database) = create_runtime().expect("could not initialize ClipForge runtime");
tauri::Builder::default()
.manage(AppRuntime {
recorder: Mutex::new(recorder),
database: Mutex::new(database),
capture: Mutex::new(None),
})
.invoke_handler(tauri::generate_handler![
@@ -327,36 +400,25 @@ fn main() {
.expect("error while running ClipForge desktop shell");
}
fn create_boot_recorder() -> RecorderService {
fn create_runtime() -> Result<(RecorderService, ClipDatabase), String> {
let root = env::current_dir()
.unwrap_or_else(|_| PathBuf::from("."))
.join("clipforge-library");
let settings = AppSettings::default_for_root(&root);
let paths = LibraryPaths::new(&root);
let _ = paths.ensure();
paths.ensure().map_err(|error| error.to_string())?;
let database = ClipDatabase::open(root.join("library.sqlite"))
.map_err(|error| format!("Could not open clip database: {error}"))?;
let mut recorder = RecorderService::new(settings, paths);
let sample_processes = vec![RunningProcess {
pid: 730,
process_name: "cs2.exe".to_string(),
executable_path: "C:/Steam/cs2.exe".to_string(),
window_title: Some("Counter-Strike 2".to_string()),
}];
if let Some(game) = detect_game(&sample_processes, &default_profiles()) {
let now = SystemTime::now();
recorder.start_for_game(game.game_id, now);
for index in 0..12 {
recorder.add_segment(BufferSegment {
id: format!("boot-segment-{index}"),
started_at: now + Duration::from_secs(index * 5),
duration: Duration::from_secs(5),
path_hint: format!("boot_segment_{index}.mp4"),
});
}
for clip in database
.load_clips()
.map_err(|error| format!("Could not load clip database: {error}"))?
{
recorder.library.add_clip(clip);
}
recorder
let _ = detect_game(&[], &default_profiles());
Ok((recorder, database))
}
fn add_session_clip(
@@ -364,9 +426,12 @@ fn add_session_clip(
output_path: PathBuf,
started_at: SystemTime,
stopped_at: SystemTime,
) -> Result<(), String> {
) -> Result<Clip, String> {
if !output_path.exists() {
return Ok(());
return Err(format!(
"Session recording was not written: {}",
output_path.display()
));
}
let duration = stopped_at
@@ -398,8 +463,9 @@ fn add_session_clip(
upload_url: None,
upload_provider: None,
};
recorder.library.add_clip(clip);
save_manifest(recorder)
recorder.library.add_clip(clip.clone());
save_manifest(recorder)?;
Ok(clip)
}
fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCapture>) -> DesktopStatus {
@@ -411,7 +477,7 @@ fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCaptu
upload_enabled: false,
session_recording: matches!(recorder.state.status, RecordingStatus::RecordingSession),
capture_active: capture.is_some(),
capture_path: capture.map(|active| active.output_path.display().to_string()),
capture_path: capture.map(|active| active.session_output_path.display().to_string()),
clip_count: recorder.library.all().len(),
library_root: recorder.paths.clip_root.display().to_string(),
ffmpeg_available: ffmpeg_is_available(),
@@ -455,6 +521,10 @@ fn clip_to_dto(clip: &Clip) -> ClipDto {
"Local only".to_string()
},
path: clip.path.display().to_string(),
thumbnail_path: clip
.thumbnail_path
.as_ref()
.map(|path| path.display().to_string()),
tags: clip.tags.clone(),
color_class: match clip.source {
ClipSource::ManualHotkey => "manual".to_string(),
@@ -465,6 +535,20 @@ fn clip_to_dto(clip: &Clip) -> ClipDto {
}
}
fn persist_clip(runtime: &State<'_, AppRuntime>, clip: &Clip) -> Result<(), String> {
let database = runtime.database.lock().map_err(|error| error.to_string())?;
database
.upsert_clip(clip)
.map_err(|error| format!("Could not save clip database record: {error}"))
}
fn delete_clip_record(runtime: &State<'_, AppRuntime>, clip_id: &str) -> Result<(), String> {
let database = runtime.database.lock().map_err(|error| error.to_string())?;
database
.delete_clip(clip_id)
.map_err(|error| format!("Could not delete clip database record: {error}"))
}
fn save_manifest(recorder: &RecorderService) -> Result<(), String> {
let manifest = recorder
.paths
+235 -30
View File
@@ -31,7 +31,10 @@ pub struct CaptureConfig {
pub fps: u32,
pub bitrate_kbps: u32,
pub encoder: EncoderPreference,
pub system_audio_enabled: bool,
pub mic_enabled: bool,
pub system_audio_device: Option<String>,
pub mic_device: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -126,42 +129,125 @@ impl FfmpegRecordingPlan {
output: impl Into<PathBuf>,
config: &CaptureConfig,
) -> Self {
let preset = match config.encoder {
EncoderPreference::HardwareH264 => "h264_mf",
EncoderPreference::SoftwareH264 => "libx264",
};
let output = output.into();
let size = format!("{}x{}", config.width, config.height);
let fps = config.fps.to_string();
let bitrate = format!("{}k", config.bitrate_kbps);
let mut args = base_desktop_input_args(config);
args.extend([
"-movflags".to_string(),
"+faststart".to_string(),
output.display().to_string(),
]);
Self {
executable: executable.into(),
args: vec![
"-y".to_string(),
"-hide_banner".to_string(),
"-loglevel".to_string(),
"error".to_string(),
"-f".to_string(),
"gdigrab".to_string(),
"-framerate".to_string(),
fps,
"-video_size".to_string(),
size,
"-i".to_string(),
"desktop".to_string(),
"-c:v".to_string(),
preset.to_string(),
"-b:v".to_string(),
bitrate,
"-pix_fmt".to_string(),
"yuv420p".to_string(),
"-movflags".to_string(),
"+faststart".to_string(),
output.display().to_string(),
],
args,
}
}
pub fn for_windows_desktop_segments(
executable: impl Into<PathBuf>,
output_pattern: impl Into<PathBuf>,
config: &CaptureConfig,
segment_duration: Duration,
) -> Self {
let output_pattern = output_pattern.into();
let mut args = base_desktop_input_args(config);
args.extend([
"-f".to_string(),
"segment".to_string(),
"-segment_time".to_string(),
segment_duration.as_secs().max(1).to_string(),
"-reset_timestamps".to_string(),
"1".to_string(),
"-segment_format".to_string(),
"mp4".to_string(),
output_pattern.display().to_string(),
]);
Self {
executable: executable.into(),
args,
}
}
}
fn base_desktop_input_args(config: &CaptureConfig) -> Vec<String> {
let preset = match config.encoder {
EncoderPreference::HardwareH264 => "h264_mf",
EncoderPreference::SoftwareH264 => "libx264",
};
let size = format!("{}x{}", config.width, config.height);
let fps = config.fps.to_string();
let bitrate = format!("{}k", config.bitrate_kbps);
let mut args = vec![
"-y".to_string(),
"-hide_banner".to_string(),
"-loglevel".to_string(),
"error".to_string(),
"-f".to_string(),
"gdigrab".to_string(),
"-framerate".to_string(),
fps,
"-video_size".to_string(),
size,
"-i".to_string(),
"desktop".to_string(),
];
let mut next_input_index = 1;
let mut audio_maps = Vec::new();
if config.system_audio_enabled {
args.extend([
"-f".to_string(),
"wasapi".to_string(),
"-i".to_string(),
config
.system_audio_device
.clone()
.unwrap_or_else(|| "default".to_string()),
]);
audio_maps.push(format!("{next_input_index}:a?"));
next_input_index += 1;
}
if config.mic_enabled {
args.extend([
"-f".to_string(),
"dshow".to_string(),
"-i".to_string(),
format!(
"audio={}",
config
.mic_device
.clone()
.unwrap_or_else(|| "Microphone".to_string())
),
]);
audio_maps.push(format!("{next_input_index}:a?"));
}
args.extend([
"-map".to_string(),
"0:v:0".to_string(),
"-c:v".to_string(),
preset.to_string(),
"-b:v".to_string(),
bitrate,
"-pix_fmt".to_string(),
"yuv420p".to_string(),
]);
for audio_map in audio_maps {
args.extend(["-map".to_string(), audio_map]);
}
if config.system_audio_enabled || config.mic_enabled {
args.extend([
"-c:a".to_string(),
"aac".to_string(),
"-b:a".to_string(),
"160k".to_string(),
]);
}
args
}
#[derive(Debug)]
@@ -239,6 +325,96 @@ impl Drop for FfmpegCaptureBackend {
}
}
#[derive(Debug)]
pub struct FfmpegReplayCaptureBackend {
executable: PathBuf,
output_pattern: PathBuf,
segment_duration: Duration,
child: Option<Child>,
}
impl FfmpegReplayCaptureBackend {
pub fn new(
executable: impl Into<PathBuf>,
output_pattern: impl Into<PathBuf>,
segment_duration: Duration,
) -> Self {
Self {
executable: executable.into(),
output_pattern: output_pattern.into(),
segment_duration,
child: None,
}
}
pub fn plan(&self, config: &CaptureConfig) -> FfmpegRecordingPlan {
FfmpegRecordingPlan::for_windows_desktop_segments(
&self.executable,
&self.output_pattern,
config,
self.segment_duration,
)
}
}
impl CaptureBackend for FfmpegReplayCaptureBackend {
fn name(&self) -> &'static str {
"ffmpeg-gdigrab-segments"
}
fn start(&mut self, config: CaptureConfig) -> Result<(), CaptureError> {
if self.child.is_some() {
return Ok(());
}
let plan = self.plan(&config);
let child = Command::new(&plan.executable)
.args(&plan.args)
.stdin(Stdio::piped())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
.map_err(|error| CaptureError::DeviceUnavailable(error.to_string()))?;
self.child = Some(child);
Ok(())
}
fn stop(&mut self) -> Result<(), CaptureError> {
stop_ffmpeg_child(&mut self.child)
}
}
impl Drop for FfmpegReplayCaptureBackend {
fn drop(&mut self) {
let _ = self.stop();
}
}
fn stop_ffmpeg_child(child: &mut Option<Child>) -> Result<(), CaptureError> {
if let Some(mut child) = child.take() {
if let Some(stdin) = child.stdin.as_mut() {
let _ = stdin.write_all(b"q\n");
}
let deadline = Instant::now() + Duration::from_secs(5);
loop {
if child
.try_wait()
.map_err(|error| CaptureError::DeviceUnavailable(error.to_string()))?
.is_some()
{
break;
}
if Instant::now() >= deadline {
let _ = child.kill();
let _ = child.wait();
break;
}
thread::sleep(Duration::from_millis(100));
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
@@ -252,7 +428,10 @@ mod tests {
fps: 30,
bitrate_kbps: 6000,
encoder: EncoderPreference::HardwareH264,
system_audio_enabled: false,
mic_enabled: false,
system_audio_device: None,
mic_device: None,
};
let plan = FfmpegRecordingPlan::for_windows_desktop("ffmpeg", "out.mp4", &config);
@@ -261,4 +440,30 @@ mod tests {
assert!(plan.args.contains(&"1280x720".to_string()));
assert!(plan.args.contains(&"6000k".to_string()));
}
#[test]
fn ffmpeg_segment_plan_uses_segment_muxer() {
let config = CaptureConfig {
source: CaptureSource::Desktop,
width: 1280,
height: 720,
fps: 30,
bitrate_kbps: 6000,
encoder: EncoderPreference::HardwareH264,
system_audio_enabled: false,
mic_enabled: false,
system_audio_device: None,
mic_device: None,
};
let plan = FfmpegRecordingPlan::for_windows_desktop_segments(
"ffmpeg",
"segment-%05d.mp4",
&config,
Duration::from_secs(5),
);
assert!(plan.args.contains(&"segment".to_string()));
assert!(plan.args.contains(&"segment-%05d.mp4".to_string()));
}
}
+231
View File
@@ -0,0 +1,231 @@
use crate::models::{Clip, ClipSource, GameEventType, UploadProvider};
use rusqlite::{params, Connection};
use std::path::{Path, PathBuf};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
#[derive(Debug)]
pub struct ClipDatabase {
connection: Connection,
}
impl ClipDatabase {
pub fn open(path: impl AsRef<Path>) -> rusqlite::Result<Self> {
let path = path.as_ref();
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)
.map_err(|error| rusqlite::Error::ToSqlConversionFailure(Box::new(error)))?;
}
let connection = Connection::open(path)?;
let database = Self { connection };
database.init()?;
Ok(database)
}
pub fn init(&self) -> rusqlite::Result<()> {
self.connection.execute_batch(
"
CREATE TABLE IF NOT EXISTS clips (
id TEXT PRIMARY KEY NOT NULL,
session_id TEXT NOT NULL,
game_id TEXT NOT NULL,
path TEXT NOT NULL,
thumbnail_path TEXT,
created_at_ms INTEGER NOT NULL,
duration_ms INTEGER NOT NULL,
source TEXT NOT NULL,
event_type TEXT,
tags_json TEXT NOT NULL,
upload_url TEXT,
upload_provider TEXT
);
CREATE INDEX IF NOT EXISTS clips_created_at_idx ON clips(created_at_ms DESC);
CREATE INDEX IF NOT EXISTS clips_game_id_idx ON clips(game_id);
",
)
}
pub fn load_clips(&self) -> rusqlite::Result<Vec<Clip>> {
let mut statement = self.connection.prepare(
"
SELECT id, session_id, game_id, path, thumbnail_path, created_at_ms, duration_ms,
source, event_type, tags_json, upload_url, upload_provider
FROM clips
ORDER BY created_at_ms DESC
",
)?;
let rows = statement.query_map([], |row| {
let tags_json: String = row.get(9)?;
let tags = serde_json::from_str::<Vec<String>>(&tags_json).unwrap_or_default();
let event_type = row
.get::<_, Option<String>>(8)?
.map(|value| parse_event_type(&value));
let upload_provider = row
.get::<_, Option<String>>(11)?
.and_then(|value| parse_upload_provider(&value));
Ok(Clip {
id: row.get(0)?,
session_id: row.get(1)?,
game_id: row.get(2)?,
path: PathBuf::from(row.get::<_, String>(3)?),
thumbnail_path: row.get::<_, Option<String>>(4)?.map(PathBuf::from),
created_at: millis_to_system_time(row.get(5)?),
duration: Duration::from_millis(row.get::<_, i64>(6)?.max(0) as u64),
source: parse_clip_source(&row.get::<_, String>(7)?),
event_type,
tags,
upload_url: row.get(10)?,
upload_provider,
})
})?;
rows.collect()
}
pub fn upsert_clip(&self, clip: &Clip) -> rusqlite::Result<()> {
let tags_json = serde_json::to_string(&clip.tags).unwrap_or_else(|_| "[]".to_string());
self.connection.execute(
"
INSERT INTO clips (
id, session_id, game_id, path, thumbnail_path, created_at_ms, duration_ms,
source, event_type, tags_json, upload_url, upload_provider
)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)
ON CONFLICT(id) DO UPDATE SET
session_id = excluded.session_id,
game_id = excluded.game_id,
path = excluded.path,
thumbnail_path = excluded.thumbnail_path,
created_at_ms = excluded.created_at_ms,
duration_ms = excluded.duration_ms,
source = excluded.source,
event_type = excluded.event_type,
tags_json = excluded.tags_json,
upload_url = excluded.upload_url,
upload_provider = excluded.upload_provider
",
params![
clip.id,
clip.session_id,
clip.game_id,
clip.path.display().to_string(),
clip.thumbnail_path
.as_ref()
.map(|path| path.display().to_string()),
system_time_to_millis(clip.created_at),
clip.duration.as_millis().min(i64::MAX as u128) as i64,
clip_source_name(&clip.source),
clip.event_type.as_ref().map(ToString::to_string),
tags_json,
clip.upload_url,
clip.upload_provider.as_ref().map(upload_provider_name),
],
)?;
Ok(())
}
pub fn delete_clip(&self, clip_id: &str) -> rusqlite::Result<()> {
self.connection
.execute("DELETE FROM clips WHERE id = ?1", params![clip_id])?;
Ok(())
}
}
fn parse_clip_source(value: &str) -> ClipSource {
match value {
"manual_hotkey" => ClipSource::ManualHotkey,
"auto_event" => ClipSource::AutoEvent,
"full_session_bookmark" => ClipSource::FullSessionBookmark,
_ => ClipSource::Imported,
}
}
fn clip_source_name(source: &ClipSource) -> &'static str {
match source {
ClipSource::ManualHotkey => "manual_hotkey",
ClipSource::AutoEvent => "auto_event",
ClipSource::FullSessionBookmark => "full_session_bookmark",
ClipSource::Imported => "imported",
}
}
fn parse_event_type(value: &str) -> GameEventType {
match value {
"kill" => GameEventType::Kill,
"death" => GameEventType::Death,
"assist" => GameEventType::Assist,
"round_win" => GameEventType::RoundWin,
"match_win" => GameEventType::MatchWin,
"objective" => GameEventType::Objective,
"multi_kill" => GameEventType::MultiKill,
"bookmark" => GameEventType::Bookmark,
value => GameEventType::Unknown(value.to_string()),
}
}
fn parse_upload_provider(value: &str) -> Option<UploadProvider> {
match value {
"catbox" => Some(UploadProvider::Catbox),
"litterbox" => Some(UploadProvider::Litterbox),
"lustful" => Some(UploadProvider::Lustful),
"custom_http" => Some(UploadProvider::CustomHttp),
_ => None,
}
}
fn upload_provider_name(provider: &UploadProvider) -> &'static str {
match provider {
UploadProvider::Catbox => "catbox",
UploadProvider::Litterbox => "litterbox",
UploadProvider::Lustful => "lustful",
UploadProvider::CustomHttp => "custom_http",
}
}
fn system_time_to_millis(time: SystemTime) -> i64 {
time.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_millis()
.min(i64::MAX as u128) as i64
}
fn millis_to_system_time(millis: i64) -> SystemTime {
UNIX_EPOCH + Duration::from_millis(millis.max(0) as u64)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn round_trips_clip_records() {
let db_path = std::env::temp_dir().join(format!(
"clipforge-db-{}.sqlite",
system_time_to_millis(SystemTime::now())
));
let database = ClipDatabase::open(&db_path).expect("database");
let clip = Clip {
id: "clip-1".to_string(),
session_id: "session-1".to_string(),
game_id: "counter-strike-2".to_string(),
path: PathBuf::from("C:/clips/clip-1.mp4"),
thumbnail_path: Some(PathBuf::from("C:/clips/clip-1.jpg")),
created_at: UNIX_EPOCH + Duration::from_secs(10),
duration: Duration::from_secs(60),
source: ClipSource::ManualHotkey,
event_type: Some(GameEventType::Kill),
tags: vec!["clutch".to_string()],
upload_url: Some("https://example.test/clip.mp4".to_string()),
upload_provider: Some(UploadProvider::CustomHttp),
};
database.upsert_clip(&clip).expect("upsert");
let loaded = database.load_clips().expect("load");
assert_eq!(loaded, vec![clip]);
database.delete_clip("clip-1").expect("delete");
assert!(database.load_clips().expect("load empty").is_empty());
let _ = std::fs::remove_file(db_path);
}
}
+2
View File
@@ -1,9 +1,11 @@
pub mod capture;
pub mod database;
pub mod game_detection;
pub mod hotkeys;
pub mod integrations;
pub mod jobs;
pub mod library;
pub mod media;
pub mod models;
pub mod recorder;
pub mod settings;
+265
View File
@@ -0,0 +1,265 @@
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SegmentFile {
pub path: PathBuf,
pub modified_at: SystemTime,
}
pub fn collect_segments(buffer_dir: &Path) -> io::Result<Vec<SegmentFile>> {
let mut segments = Vec::new();
if !buffer_dir.exists() {
return Ok(segments);
}
for entry in fs::read_dir(buffer_dir)? {
let entry = entry?;
let path = entry.path();
if path.extension().and_then(|value| value.to_str()) != Some("mp4") {
continue;
}
let metadata = entry.metadata()?;
segments.push(SegmentFile {
path,
modified_at: metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH),
});
}
segments.sort_by(|left, right| left.modified_at.cmp(&right.modified_at));
Ok(segments)
}
pub fn recent_segments(
buffer_dir: &Path,
window: Duration,
segment_duration: Duration,
now: SystemTime,
) -> io::Result<Vec<PathBuf>> {
let cutoff = now
.checked_sub(window + segment_duration)
.unwrap_or(SystemTime::UNIX_EPOCH);
Ok(collect_segments(buffer_dir)?
.into_iter()
.filter(|segment| segment.modified_at >= cutoff)
.map(|segment| segment.path)
.collect())
}
pub fn prune_old_segments(
buffer_dir: &Path,
replay_window: Duration,
segment_duration: Duration,
) -> io::Result<usize> {
let mut segments = collect_segments(buffer_dir)?;
let keep_count =
(replay_window.as_secs_f64() / segment_duration.as_secs_f64()).ceil() as usize + 4;
if segments.len() <= keep_count {
return Ok(0);
}
let remove_count = segments.len() - keep_count;
let mut removed = 0;
for segment in segments.drain(..remove_count) {
fs::remove_file(segment.path)?;
removed += 1;
}
Ok(removed)
}
pub fn concat_segments(
ffmpeg: &Path,
segments: &[PathBuf],
output: &Path,
) -> Result<(), MediaError> {
if segments.is_empty() {
return Err(MediaError::NoSegments);
}
if let Some(parent) = output.parent() {
fs::create_dir_all(parent)?;
}
if segments.len() == 1 {
fs::copy(&segments[0], output)?;
return Ok(());
}
let list_path = output.with_extension("concat.txt");
let mut list = String::new();
for segment in segments {
list.push_str("file '");
list.push_str(&escape_concat_path(segment));
list.push_str("'\n");
}
fs::write(&list_path, list)?;
let status = Command::new(ffmpeg)
.args([
"-y",
"-hide_banner",
"-loglevel",
"error",
"-f",
"concat",
"-safe",
"0",
"-i",
&list_path.display().to_string(),
"-c",
"copy",
&output.display().to_string(),
])
.status()
.map_err(|error| MediaError::Ffmpeg(error.to_string()))?;
let _ = fs::remove_file(list_path);
if status.success() {
Ok(())
} else {
Err(MediaError::Ffmpeg("FFmpeg concat failed".to_string()))
}
}
pub fn trim_clip(
ffmpeg: &Path,
input: &Path,
output: &Path,
start_seconds: f64,
end_seconds: f64,
) -> Result<(), MediaError> {
if !(end_seconds > start_seconds && start_seconds >= 0.0) {
return Err(MediaError::InvalidWindow);
}
if let Some(parent) = output.parent() {
fs::create_dir_all(parent)?;
}
let status = Command::new(ffmpeg)
.args([
"-y",
"-hide_banner",
"-loglevel",
"error",
"-ss",
&format!("{start_seconds:.3}"),
"-to",
&format!("{end_seconds:.3}"),
"-i",
&input.display().to_string(),
"-c",
"copy",
&output.display().to_string(),
])
.status()
.map_err(|error| MediaError::Ffmpeg(error.to_string()))?;
if status.success() {
Ok(())
} else {
Err(MediaError::Ffmpeg("FFmpeg trim failed".to_string()))
}
}
pub fn generate_thumbnail(ffmpeg: &Path, input: &Path, output: &Path) -> Result<(), MediaError> {
if let Some(parent) = output.parent() {
fs::create_dir_all(parent)?;
}
let status = Command::new(ffmpeg)
.args([
"-y",
"-hide_banner",
"-loglevel",
"error",
"-ss",
"00:00:01",
"-i",
&input.display().to_string(),
"-frames:v",
"1",
"-q:v",
"3",
&output.display().to_string(),
])
.status()
.map_err(|error| MediaError::Ffmpeg(error.to_string()))?;
if status.success() {
Ok(())
} else {
Err(MediaError::Ffmpeg(
"FFmpeg thumbnail generation failed".to_string(),
))
}
}
fn escape_concat_path(path: &Path) -> String {
path.display()
.to_string()
.replace('\\', "/")
.replace('\'', "'\\''")
}
#[derive(Debug)]
pub enum MediaError {
Io(io::Error),
Ffmpeg(String),
InvalidWindow,
NoSegments,
}
impl std::fmt::Display for MediaError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Io(error) => write!(f, "{error}"),
Self::Ffmpeg(error) => write!(f, "{error}"),
Self::InvalidWindow => f.write_str("clip window is invalid"),
Self::NoSegments => f.write_str("no replay buffer segments are available"),
}
}
}
impl From<io::Error> for MediaError {
fn from(value: io::Error) -> Self {
Self::Io(value)
}
}
pub fn timestamp_millis(time: SystemTime) -> u128 {
time.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_millis()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn concat_paths_are_ffmpeg_friendly() {
let path = Path::new("C:\\clips\\a'b.mp4");
assert_eq!(escape_concat_path(path), "C:/clips/a'\\''b.mp4");
}
#[test]
fn prune_keeps_replay_window_plus_slack() {
let root = std::env::temp_dir().join(format!(
"clipforge-media-{}",
timestamp_millis(SystemTime::now())
));
fs::create_dir_all(&root).expect("test root");
for index in 0..8 {
fs::write(root.join(format!("segment-{index}.mp4")), b"x").expect("segment");
}
let removed = prune_old_segments(&root, Duration::from_secs(10), Duration::from_secs(5))
.expect("prune");
assert_eq!(removed, 2);
assert_eq!(collect_segments(&root).expect("segments").len(), 6);
let _ = fs::remove_dir_all(root);
}
}
+146 -17
View File
@@ -1,5 +1,6 @@
use crate::models::UploadProvider;
use std::path::Path;
use std::time::Duration;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UploadMetadata {
@@ -37,6 +38,17 @@ pub enum UploadError {
Provider(String),
}
impl std::fmt::Display for UploadError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NotConfigured(message) => write!(f, "{message}"),
Self::FileTooLarge { max_mb } => write!(f, "file is larger than {max_mb} MB"),
Self::Network(message) => write!(f, "upload network error: {message}"),
Self::Provider(message) => write!(f, "upload provider error: {message}"),
}
}
}
pub trait Uploader {
fn info(&self) -> UploaderInfo;
fn upload(&self, file: &Path, metadata: &UploadMetadata) -> Result<UploadResult, UploadError>;
@@ -63,10 +75,31 @@ impl Uploader for CatboxUploader {
fn upload(&self, file: &Path, _metadata: &UploadMetadata) -> Result<UploadResult, UploadError> {
ensure_file_limit(file, 200)?;
Err(UploadError::Network(
"Catbox upload is wired at the adapter boundary; enable HTTP client dependency for live uploads."
.to_string(),
))
let client = upload_client()?;
let file_part = reqwest::blocking::multipart::Part::file(file)
.map_err(|error| UploadError::Network(error.to_string()))?;
let mut form = reqwest::blocking::multipart::Form::new()
.text("reqtype", "fileupload")
.part("fileToUpload", file_part);
if let Some(userhash) = &self.userhash {
if !userhash.trim().is_empty() {
form = form.text("userhash", userhash.clone());
}
}
let body = client
.post("https://catbox.moe/user/api.php")
.multipart(form)
.send()
.map_err(|error| UploadError::Network(error.to_string()))?
.error_for_status()
.map_err(|error| UploadError::Provider(error.to_string()))?
.text()
.map_err(|error| UploadError::Network(error.to_string()))?;
let url = parse_plain_url(&body)?;
Ok(UploadResult {
provider: UploadProvider::Catbox,
url,
})
}
}
@@ -98,10 +131,27 @@ impl Uploader for LitterboxUploader {
"Litterbox expiry must be one of 1, 12, 24, or 72 hours.".to_string(),
));
}
Err(UploadError::Network(
"Litterbox upload is wired at the adapter boundary; enable HTTP client dependency for live uploads."
.to_string(),
))
let client = upload_client()?;
let file_part = reqwest::blocking::multipart::Part::file(file)
.map_err(|error| UploadError::Network(error.to_string()))?;
let form = reqwest::blocking::multipart::Form::new()
.text("reqtype", "fileupload")
.text("time", format!("{}h", self.expiry_hours))
.part("fileToUpload", file_part);
let body = client
.post("https://litterbox.catbox.moe/resources/internals/api.php")
.multipart(form)
.send()
.map_err(|error| UploadError::Network(error.to_string()))?
.error_for_status()
.map_err(|error| UploadError::Provider(error.to_string()))?
.text()
.map_err(|error| UploadError::Network(error.to_string()))?;
let url = parse_plain_url(&body)?;
Ok(UploadResult {
provider: UploadProvider::Litterbox,
url,
})
}
}
@@ -111,6 +161,7 @@ pub struct CustomHttpUploader {
pub method: String,
pub multipart_field: String,
pub response_url_path: String,
pub headers: Vec<(String, String)>,
}
impl Uploader for CustomHttpUploader {
@@ -127,20 +178,52 @@ impl Uploader for CustomHttpUploader {
}
}
fn upload(
&self,
_file: &Path,
_metadata: &UploadMetadata,
) -> Result<UploadResult, UploadError> {
fn upload(&self, file: &Path, metadata: &UploadMetadata) -> Result<UploadResult, UploadError> {
if self.endpoint.trim().is_empty() {
return Err(UploadError::NotConfigured(
"custom upload endpoint is required".to_string(),
));
}
Err(UploadError::Network(
"Custom upload is configured; enable HTTP client dependency for live uploads."
.to_string(),
))
if !self.method.eq_ignore_ascii_case("POST") {
return Err(UploadError::Provider(
"custom uploads currently support POST multipart requests".to_string(),
));
}
let client = upload_client()?;
let file_part = reqwest::blocking::multipart::Part::file(file)
.map_err(|error| UploadError::Network(error.to_string()))?;
let field_name = if self.multipart_field.trim().is_empty() {
"file"
} else {
self.multipart_field.trim()
};
let form = reqwest::blocking::multipart::Form::new()
.text("clip_id", metadata.clip_id.clone())
.text("game_id", metadata.game_id.clone())
.text("title", metadata.title.clone())
.part(field_name.to_string(), file_part);
let mut request = client.post(&self.endpoint).multipart(form);
for (name, value) in &self.headers {
if !name.trim().is_empty() {
request = request.header(name, value);
}
}
let body = request
.send()
.map_err(|error| UploadError::Network(error.to_string()))?
.error_for_status()
.map_err(|error| UploadError::Provider(error.to_string()))?
.text()
.map_err(|error| UploadError::Network(error.to_string()))?;
let url = if self.response_url_path.trim().is_empty() {
parse_plain_url(&body)?
} else {
extract_json_path(&body, &self.response_url_path)?
};
Ok(UploadResult {
provider: UploadProvider::CustomHttp,
url,
})
}
}
@@ -178,6 +261,42 @@ fn ensure_file_limit(file: &Path, max_mb: u64) -> Result<(), UploadError> {
Ok(())
}
fn upload_client() -> Result<reqwest::blocking::Client, UploadError> {
reqwest::blocking::Client::builder()
.timeout(Duration::from_secs(120))
.user_agent("ClipForge/0.1")
.build()
.map_err(|error| UploadError::Network(error.to_string()))
}
fn parse_plain_url(body: &str) -> Result<String, UploadError> {
let trimmed = body.trim();
if trimmed.starts_with("http://") || trimmed.starts_with("https://") {
Ok(trimmed.to_string())
} else {
Err(UploadError::Provider(trimmed.to_string()))
}
}
fn extract_json_path(body: &str, path: &str) -> Result<String, UploadError> {
let mut value: &serde_json::Value = &serde_json::from_str(body)
.map_err(|error| UploadError::Provider(format!("invalid JSON response: {error}")))?;
for key in path.trim().trim_start_matches("$.").split('.') {
if key.is_empty() {
continue;
}
value = value.get(key).ok_or_else(|| {
UploadError::Provider(format!("response URL path was not found: {path}"))
})?;
}
let Some(url) = value.as_str() else {
return Err(UploadError::Provider(format!(
"response URL path is not a string: {path}"
)));
};
parse_plain_url(url)
}
#[cfg(test)]
mod tests {
use super::*;
@@ -196,4 +315,14 @@ mod tests {
assert!(matches!(result, Err(UploadError::Provider(_))));
}
#[test]
fn extracts_custom_json_url_path() {
let url = extract_json_path(
r#"{"data":{"url":"https://example.test/c.mp4"}}"#,
"data.url",
)
.expect("url");
assert_eq!(url, "https://example.test/c.mp4");
}
}
+31 -2
View File
@@ -1,3 +1,5 @@
import { convertFileSrc } from "@tauri-apps/api/core";
type RecordingState =
| "WaitingForGame"
| "Buffering"
@@ -19,6 +21,9 @@ type Clip = {
createdAt: string;
uploadState: UploadState;
path: string;
thumbnailPath: string | null;
videoUrl: string | null;
thumbnailUrl: string | null;
tags: string[];
colorClass: string;
};
@@ -55,6 +60,7 @@ type ClipDto = {
created_at: string;
upload_state: UploadState;
path: string;
thumbnail_path: string | null;
tags: string[];
color_class: string;
};
@@ -115,6 +121,9 @@ const state: AppState = {
createdAt: "Today 12:08",
uploadState: "Local only",
path: "",
thumbnailPath: null,
videoUrl: null,
thumbnailUrl: null,
tags: ["clutch", "kill"],
colorClass: "kill",
},
@@ -128,6 +137,9 @@ const state: AppState = {
createdAt: "Today 11:44",
uploadState: "Queued",
path: "",
thumbnailPath: null,
videoUrl: null,
thumbnailUrl: null,
tags: ["objective"],
colorClass: "objective",
},
@@ -141,6 +153,9 @@ const state: AppState = {
createdAt: "Yesterday 22:15",
uploadState: "Uploaded",
path: "",
thumbnailPath: null,
videoUrl: null,
thumbnailUrl: null,
tags: ["teamfight"],
colorClass: "manual",
},
@@ -270,6 +285,9 @@ function clipFromDto(dto: ClipDto): Clip {
createdAt: dto.created_at,
uploadState: dto.upload_state,
path: dto.path,
thumbnailPath: dto.thumbnail_path,
videoUrl: dto.path ? convertFileSrc(dto.path) : null,
thumbnailUrl: dto.thumbnail_path ? convertFileSrc(dto.thumbnail_path) : null,
tags: dto.tags,
colorClass: dto.color_class,
};
@@ -278,7 +296,9 @@ function clipFromDto(dto: ClipDto): Clip {
function renderClipCard(clip: Clip) {
return `
<article class="clip-card ${state.selectedClipId === clip.id ? "selected" : ""}" data-clip-id="${clip.id}">
<div class="thumb ${clip.colorClass}">${clip.event}</div>
<div class="thumb ${clip.colorClass}">
${clip.thumbnailUrl ? `<img src="${clip.thumbnailUrl}" alt="" />` : clip.event}
</div>
<h3>${clip.title}</h3>
<p>${clip.game} · ${clip.source} · ${clip.duration}</p>
</article>
@@ -298,7 +318,13 @@ function renderClipDetails(clip: Clip | undefined) {
return `
<aside class="detail-panel">
<div class="preview"><span>Preview</span></div>
<div class="preview">
${
clip.videoUrl
? `<video controls preload="metadata" src="${clip.videoUrl}" poster="${clip.thumbnailUrl ?? ""}"></video>`
: `<span>Preview</span>`
}
</div>
<h2>${clip.title}</h2>
<p class="muted">${clip.game} · ${clip.event} · ${clip.createdAt} · ${clip.uploadState}</p>
<div class="tag-row">${clip.tags.map((tag) => `<span>${tag}</span>`).join("")}</div>
@@ -502,6 +528,9 @@ async function saveClip() {
createdAt: "Just now",
uploadState: "Local only",
path: "",
thumbnailPath: null,
videoUrl: null,
thumbnailUrl: null,
tags: ["manual"],
colorClass: "manual",
});
+9
View File
@@ -276,6 +276,7 @@ h3 {
.thumb {
display: grid;
place-items: center;
overflow: hidden;
height: 132px;
margin-bottom: 12px;
background: #243244;
@@ -284,6 +285,13 @@ h3 {
letter-spacing: 0;
}
.thumb img,
.preview video {
width: 100%;
height: 100%;
object-fit: cover;
}
.thumb.kill {
background: linear-gradient(135deg, #1f2937, #7f1d1d);
}
@@ -306,6 +314,7 @@ h3 {
.preview {
display: grid;
place-items: center;
overflow: hidden;
aspect-ratio: 16 / 9;
margin-bottom: 14px;
border-radius: 8px;