Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: Share page .ts file streaming
Richie McIlroy50b5ce47bd19
diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 4871ccc91..6036c7421 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -4,14 +4,15 @@"version": "0.1.0","scripts": {"dev": "tauri dev",- "build": "tsc && vite build",- "preview": "vite preview",+ "build": "tsc && next build","tauri": "tauri"},"dependencies": {"@cap/database": "workspace:*","@cap/ui": "workspace:*","@cap/utils": "workspace:*",+ "@ffmpeg/ffmpeg": "^0.12.10",+ "@ffmpeg/util": "^0.12.1","@tauri-apps/api": "^1.5.0","autoprefixer": "^10.4.16","cookies-next": "^4.1.0",diff --git a/apps/desktop/src-tauri/Cargo.lock b/apps/desktop/src-tauri/Cargo.lockindex 2e7757893..9a8b8d473 100644--- a/apps/desktop/src-tauri/Cargo.lock+++ b/apps/desktop/src-tauri/Cargo.lock@@ -98,7 +98,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c"dependencies = ["concurrent-queue",- "event-listener 4.0.2",+ "event-listener 4.0.3","event-listener-strategy","futures-core","pin-project-lite",@@ -110,11 +110,11 @@ version = "1.8.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c"dependencies = [- "async-lock 3.2.0",+ "async-lock 3.3.0","async-task","concurrent-queue","fastrand 2.0.1",- "futures-lite 2.1.0",+ "futures-lite 2.2.0","slab",]@@ -152,18 +152,18 @@ dependencies = [[[package]]name = "async-io"-version = "2.2.2"+version = "2.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7"+checksum = "8f97ab0c5b00a7cdbe5a371b9a782ee7be1316095885c8a4ea1daf490eb0ef65"dependencies = [- "async-lock 3.2.0",+ "async-lock 3.3.0","cfg-if","concurrent-queue","futures-io",- "futures-lite 2.1.0",+ "futures-lite 2.2.0","parking",- "polling 3.3.1",- "rustix 0.38.28",+ "polling 3.3.2",+ "rustix 0.38.30","slab","tracing","windows-sys 0.52.0",@@ -180,11 +180,11 @@ dependencies = [[[package]]name = "async-lock"-version = "3.2.0"+version = "3.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c"+checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b"dependencies = [- "event-listener 4.0.2",+ "event-listener 4.0.3","event-listener-strategy","pin-project-lite",]@@ -202,7 +202,7 @@ dependencies = ["cfg-if","event-listener 3.1.0","futures-lite 1.13.0",- "rustix 0.38.28",+ "rustix 0.38.30","windows-sys 0.48.0",]@@ -214,7 +214,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -223,13 +223,13 @@ version = "0.2.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5"dependencies = [- "async-io 2.2.2",+ "async-io 2.3.1","async-lock 2.8.0","atomic-waker","cfg-if","futures-core","futures-io",- "rustix 0.38.28",+ "rustix 0.38.30","signal-hook-registry","slab","windows-sys 0.48.0",@@ -237,9 +237,9 @@ dependencies = [[[package]]name = "async-task"-version = "4.6.0"+version = "4.7.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "e1d90cd0b264dfdd8eb5bad0a2c217c1f88fa96a8573f40e7b12de23fb468f46"+checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799"[[package]]name = "async-trait"@@ -249,7 +249,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -311,9 +311,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"[[package]]name = "base64"-version = "0.21.5"+version = "0.21.7"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"+checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"[[package]]name = "bit_field"@@ -329,9 +329,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"[[package]]name = "bitflags"-version = "2.4.1"+version = "2.4.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"+checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"[[package]]name = "block"@@ -355,11 +355,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118"dependencies = ["async-channel",- "async-lock 3.2.0",+ "async-lock 3.3.0","async-task","fastrand 2.0.1","futures-io",- "futures-lite 2.1.0",+ "futures-lite 2.2.0","piper","tracing",]@@ -403,9 +403,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"[[package]]name = "bytemuck"-version = "1.14.0"+version = "1.14.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"+checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9"[[package]]name = "byteorder"@@ -531,15 +531,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"[[package]]name = "chrono"-version = "0.4.31"+version = "0.4.33"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"+checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb"dependencies = ["android-tzdata","iana-time-zone","num-traits","serde",- "windows-targets 0.48.5",+ "windows-targets 0.52.0",][[package]]@@ -685,9 +685,9 @@ dependencies = [[[package]]name = "cpufeatures"-version = "0.2.11"+version = "0.2.12"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0"+checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"dependencies = ["libc",]@@ -703,44 +703,37 @@ dependencies = [[[package]]name = "crossbeam-channel"-version = "0.5.10"+version = "0.5.11"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2"+checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b"dependencies = [- "cfg-if","crossbeam-utils",][[package]]name = "crossbeam-deque"-version = "0.8.4"+version = "0.8.5"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751"+checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"dependencies = [- "cfg-if","crossbeam-epoch","crossbeam-utils",][[package]]name = "crossbeam-epoch"-version = "0.9.17"+version = "0.9.18"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d"+checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"dependencies = [- "autocfg",- "cfg-if","crossbeam-utils",][[package]]name = "crossbeam-utils"-version = "0.8.18"+version = "0.8.19"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c"-dependencies = [- "cfg-if",-]+checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"[[package]]name = "crunchy"@@ -782,7 +775,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"dependencies = ["quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -792,14 +785,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "30d2b3721e861707777e3195b0158f950ae6dc4a27e4d02ff9f67e3eb3de199e"dependencies = ["quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]name = "darling"-version = "0.20.3"+version = "0.20.4"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"+checksum = "da01daa5f6d41c91358398e8db4dde38e292378da1f28300b59ef4732b879454"dependencies = ["darling_core","darling_macro",@@ -807,27 +800,27 @@ dependencies = [[[package]]name = "darling_core"-version = "0.20.3"+version = "0.20.4"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621"+checksum = "f44f6238b948a3c6c3073cdf53bb0c2d5e024ee27e0f35bfe9d556a12395808a"dependencies = ["fnv","ident_case","proc-macro2","quote","strsim",- "syn 2.0.46",+ "syn 2.0.48",][[package]]name = "darling_macro"-version = "0.20.3"+version = "0.20.4"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"+checksum = "0d2d88bd93979b1feb760a6b5c531ac5ba06bd63e74894c377af02faee07b9cd"dependencies = ["darling_core","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -951,11 +944,12 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"[[package]]name = "embed-resource"-version = "2.4.0"+version = "2.4.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f54cc3e827ee1c3812239a9a41dede7b4d7d5d5464faa32d71bd7cba28ce2cb2"+checksum = "3bde55e389bea6a966bd467ad1ad7da0ae14546a5bc794d16d1e55e7fca44881"dependencies = ["cc",+ "memchr","rustc_version","toml 0.8.8","vswhom",@@ -995,7 +989,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -1043,9 +1037,9 @@ dependencies = [[[package]]name = "event-listener"-version = "4.0.2"+version = "4.0.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "218a870470cce1469024e9fb66b901aa983929d81304a1cdb299f28118e550d5"+checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e"dependencies = ["concurrent-queue","parking",@@ -1058,7 +1052,7 @@ version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3"dependencies = [- "event-listener 4.0.2",+ "event-listener 4.0.3","pin-project-lite",]@@ -1095,9 +1089,9 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"[[package]]name = "fdeflate"-version = "0.3.3"+version = "0.3.4"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "209098dd6dfc4445aa6111f0e98653ac323eaa4dfd212c9ca3931bf9955c31bd"+checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645"dependencies = ["simd-adler32",]@@ -1182,7 +1176,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -1281,9 +1275,9 @@ dependencies = [[[package]]name = "futures-lite"-version = "2.1.0"+version = "2.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143"+checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba"dependencies = ["fastrand 2.0.1","futures-core",@@ -1300,7 +1294,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -1474,9 +1468,9 @@ dependencies = [[[package]]name = "getrandom"-version = "0.2.11"+version = "0.2.12"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"+checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"dependencies = ["cfg-if","libc",@@ -1589,7 +1583,7 @@ dependencies = ["aho-corasick","bstr","log",- "regex-automata 0.4.3",+ "regex-automata 0.4.5","regex-syntax 0.8.2",]@@ -1661,9 +1655,9 @@ dependencies = [[[package]]name = "h2"-version = "0.3.22"+version = "0.3.24"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178"+checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"dependencies = ["bytes","fnv",@@ -1671,7 +1665,7 @@ dependencies = ["futures-sink","futures-util","http",- "indexmap 2.1.0",+ "indexmap 2.2.1","slab","tokio","tokio-util",@@ -1716,9 +1710,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"[[package]]name = "hermit-abi"-version = "0.3.3"+version = "0.3.4"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"+checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f"[[package]]name = "hex"@@ -1877,15 +1871,15 @@ dependencies = [[[package]]name = "ignore"-version = "0.4.21"+version = "0.4.22"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "747ad1b4ae841a78e8aba0d63adbfbeaea26b517b63705d47856b73015d27060"+checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1"dependencies = ["crossbeam-deque","globset","log","memchr",- "regex-automata 0.4.3",+ "regex-automata 0.4.5","same-file","walkdir","winapi-util",@@ -1893,9 +1887,9 @@ dependencies = [[[package]]name = "image"-version = "0.24.7"+version = "0.24.8"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711"+checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23"dependencies = ["bytemuck","byteorder",@@ -1903,7 +1897,6 @@ dependencies = ["exr","gif","jpeg-decoder",- "num-rational","num-traits","png","qoi",@@ -1923,9 +1916,9 @@ dependencies = [[[package]]name = "indexmap"-version = "2.1.0"+version = "2.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"+checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"dependencies = ["equivalent","hashbrown 0.14.3",@@ -2037,18 +2030,18 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"[[package]]name = "jpeg-decoder"-version = "0.3.0"+version = "0.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"+checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0"dependencies = ["rayon",][[package]]name = "js-sys"-version = "0.3.66"+version = "0.3.67"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"+checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1"dependencies = ["wasm-bindgen",]@@ -2116,9 +2109,9 @@ dependencies = [[[package]]name = "libc"-version = "0.2.151"+version = "0.2.152"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"+checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"[[package]]name = "libloading"@@ -2136,7 +2129,7 @@ version = "0.0.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"dependencies = [- "bitflags 2.4.1",+ "bitflags 2.4.2","libc","redox_syscall",]@@ -2158,9 +2151,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"[[package]]name = "linux-raw-sys"-version = "0.4.12"+version = "0.4.13"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"+checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"[[package]]name = "lock_api"@@ -2404,27 +2397,6 @@ dependencies = ["winapi",]-[[package]]-name = "num-integer"-version = "0.1.45"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"-dependencies = [- "autocfg",- "num-traits",-]--[[package]]-name = "num-rational"-version = "0.4.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"-dependencies = [- "autocfg",- "num-integer",- "num-traits",-]-[[package]]name = "num-traits"version = "0.2.17"@@ -2553,11 +2525,11 @@ dependencies = [[[package]]name = "openssl"-version = "0.10.62"+version = "0.10.63"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671"+checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8"dependencies = [- "bitflags 2.4.1",+ "bitflags 2.4.2","cfg-if","foreign-types 0.3.2","libc",@@ -2574,7 +2546,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -2585,9 +2557,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"[[package]]name = "openssl-sys"-version = "0.9.98"+version = "0.9.99"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7"+checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae"dependencies = ["cc","libc",@@ -2808,7 +2780,7 @@ dependencies = ["phf_shared 0.11.2","proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -2863,9 +2835,9 @@ dependencies = [[[package]]name = "pkg-config"-version = "0.3.28"+version = "0.3.29"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"+checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb"[[package]]name = "plist"@@ -2873,8 +2845,8 @@ version = "1.6.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef"dependencies = [- "base64 0.21.5",- "indexmap 2.1.0",+ "base64 0.21.7",+ "indexmap 2.2.1","line-wrap","quick-xml 0.31.0","serde",@@ -2883,9 +2855,9 @@ dependencies = [[[package]]name = "png"-version = "0.17.10"+version = "0.17.11"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64"+checksum = "1f6c3c3e617595665b8ea2ff95a86066be38fb121ff920a9c0eb282abcd1da5a"dependencies = ["bitflags 1.3.2","crc32fast",@@ -2912,14 +2884,14 @@ dependencies = [[[package]]name = "polling"-version = "3.3.1"+version = "3.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e"+checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41"dependencies = ["cfg-if","concurrent-queue","pin-project-lite",- "rustix 0.38.28",+ "rustix 0.38.30","tracing","windows-sys 0.52.0",]@@ -2984,9 +2956,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"[[package]]name = "proc-macro2"-version = "1.0.74"+version = "1.0.78"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db"+checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"dependencies = ["unicode-ident",]@@ -3087,7 +3059,7 @@ version = "0.6.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"dependencies = [- "getrandom 0.2.11",+ "getrandom 0.2.12",][[package]]@@ -3116,9 +3088,9 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"[[package]]name = "rayon"-version = "1.8.0"+version = "1.8.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"+checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051"dependencies = ["either","rayon-core",@@ -3126,9 +3098,9 @@ dependencies = [[[package]]name = "rayon-core"-version = "1.12.0"+version = "1.12.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"+checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"dependencies = ["crossbeam-deque","crossbeam-utils",@@ -3149,20 +3121,20 @@ version = "0.4.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4"dependencies = [- "getrandom 0.2.11",+ "getrandom 0.2.12","libredox","thiserror",][[package]]name = "regex"-version = "1.10.2"+version = "1.10.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"+checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"dependencies = ["aho-corasick","memchr",- "regex-automata 0.4.3",+ "regex-automata 0.4.5","regex-syntax 0.8.2",]@@ -3177,9 +3149,9 @@ dependencies = [[[package]]name = "regex-automata"-version = "0.4.3"+version = "0.4.5"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"+checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"dependencies = ["aho-corasick","memchr",@@ -3204,7 +3176,7 @@ version = "0.11.23"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41"dependencies = [- "base64 0.21.5",+ "base64 0.21.7","bytes","encoding_rs","futures-core",@@ -3294,14 +3266,14 @@ dependencies = [[[package]]name = "rustix"-version = "0.38.28"+version = "0.38.30"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"+checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"dependencies = [- "bitflags 2.4.1",+ "bitflags 2.4.2","errno","libc",- "linux-raw-sys 0.4.12",+ "linux-raw-sys 0.4.13","windows-sys 0.52.0",]@@ -3398,38 +3370,38 @@ dependencies = [[[package]]name = "semver"-version = "1.0.20"+version = "1.0.21"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"+checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"dependencies = ["serde",][[package]]name = "serde"-version = "1.0.194"+version = "1.0.196"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773"+checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32"dependencies = ["serde_derive",][[package]]name = "serde_derive"-version = "1.0.194"+version = "1.0.196"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0"+checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]name = "serde_json"-version = "1.0.110"+version = "1.0.113"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6fbd975230bada99c8bb618e0c365c2eefa219158d5c6c29610fd09ff1833257"+checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79"dependencies = ["itoa 1.0.10","ryu",@@ -3444,7 +3416,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -3470,15 +3442,15 @@ dependencies = [[[package]]name = "serde_with"-version = "3.4.0"+version = "3.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23"+checksum = "f5c9fdb6b00a489875b22efd4b78fe2b363b72265cc5f6eb2e2b9ee270e6140c"dependencies = [- "base64 0.21.5",+ "base64 0.21.7","chrono","hex","indexmap 1.9.3",- "indexmap 2.1.0",+ "indexmap 2.2.1","serde","serde_json","serde_with_macros",@@ -3487,14 +3459,14 @@ dependencies = [[[package]]name = "serde_with_macros"-version = "3.4.0"+version = "3.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788"+checksum = "dbff351eb4b33600a2e138dfa0b10b65a238ea8ff8fb2387c422c5022a3e8298"dependencies = ["darling","proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -3602,9 +3574,9 @@ dependencies = [[[package]]name = "smallvec"-version = "1.11.2"+version = "1.13.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"+checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"[[package]]name = "socket2"@@ -3735,9 +3707,9 @@ dependencies = [[[package]]name = "syn"-version = "2.0.46"+version = "2.0.48"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e"+checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"dependencies = ["proc-macro2","quote",@@ -3806,9 +3778,9 @@ dependencies = [[[package]]name = "tao"-version = "0.16.5"+version = "0.16.7"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "75f5aefd6be4cd3ad3f047442242fd9f57cbfb3e565379f66b5e14749364fa4f"+checksum = "d22205b267a679ca1c590b9f178488d50981fc3e48a1b91641ae31593db875ce"dependencies = ["bitflags 1.3.2","cairo-rs",@@ -3877,9 +3849,9 @@ dependencies = [[[package]]name = "target-lexicon"-version = "0.12.12"+version = "0.12.13"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a"+checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae"[[package]]name = "tauri"@@ -3961,7 +3933,7 @@ version = "1.4.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a1554c5857f65dbc377cefb6b97c8ac77b1cb2a90d30d3448114d5d6b48a77fc"dependencies = [- "base64 0.21.5",+ "base64 0.21.7","brotli","ico","json-patch",@@ -4156,7 +4128,7 @@ dependencies = ["cfg-if","fastrand 2.0.1","redox_syscall",- "rustix 0.38.28",+ "rustix 0.38.30","windows-sys 0.52.0",]@@ -4194,7 +4166,7 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -4209,9 +4181,9 @@ dependencies = [[[package]]name = "tiff"-version = "0.9.0"+version = "0.9.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211"+checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e"dependencies = ["flate2","jpeg-decoder",@@ -4295,7 +4267,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -4370,7 +4342,7 @@ version = "0.19.15"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"dependencies = [- "indexmap 2.1.0",+ "indexmap 2.2.1","serde","serde_spanned","toml_datetime",@@ -4383,7 +4355,7 @@ version = "0.21.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"dependencies = [- "indexmap 2.1.0",+ "indexmap 2.2.1","serde","serde_spanned","toml_datetime",@@ -4415,7 +4387,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48",][[package]]@@ -4500,9 +4472,9 @@ dependencies = [[[package]]name = "unicode-bidi"-version = "0.3.14"+version = "0.3.15"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416"+checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"[[package]]name = "unicode-ident"@@ -4545,11 +4517,11 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"[[package]]name = "uuid"-version = "1.6.1"+version = "1.7.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"+checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a"dependencies = [- "getrandom 0.2.11",+ "getrandom 0.2.12",][[package]]@@ -4641,9 +4613,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"[[package]]name = "wasm-bindgen"-version = "0.2.89"+version = "0.2.90"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"+checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406"dependencies = ["cfg-if","wasm-bindgen-macro",@@ -4651,24 +4623,24 @@ dependencies = [[[package]]name = "wasm-bindgen-backend"-version = "0.2.89"+version = "0.2.90"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"+checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd"dependencies = ["bumpalo","log","once_cell","proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48","wasm-bindgen-shared",][[package]]name = "wasm-bindgen-futures"-version = "0.4.39"+version = "0.4.40"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12"+checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461"dependencies = ["cfg-if","js-sys",@@ -4678,9 +4650,9 @@ dependencies = [[[package]]name = "wasm-bindgen-macro"-version = "0.2.89"+version = "0.2.90"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"+checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999"dependencies = ["quote","wasm-bindgen-macro-support",@@ -4688,22 +4660,22 @@ dependencies = [[[package]]name = "wasm-bindgen-macro-support"-version = "0.2.89"+version = "0.2.90"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"+checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7"dependencies = ["proc-macro2","quote",- "syn 2.0.46",+ "syn 2.0.48","wasm-bindgen-backend","wasm-bindgen-shared",][[package]]name = "wasm-bindgen-shared"-version = "0.2.89"+version = "0.2.90"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"+checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"[[package]]name = "wasm-streams"@@ -4720,9 +4692,9 @@ dependencies = [[[package]]name = "web-sys"-version = "0.3.66"+version = "0.3.67"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f"+checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed"dependencies = ["js-sys","wasm-bindgen",@@ -4815,9 +4787,9 @@ dependencies = [[[package]]name = "weezl"-version = "0.1.7"+version = "0.1.8"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"+checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"[[package]]name = "which"@@ -4828,7 +4800,7 @@ dependencies = ["either","home","once_cell",- "rustix 0.38.28",+ "rustix 0.38.30",][[package]]@@ -5276,9 +5248,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"[[package]]name = "winnow"-version = "0.5.31"+version = "0.5.35"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c"+checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d"dependencies = ["memchr",]@@ -5396,13 +5368,13 @@ dependencies = [[[package]]name = "xattr"-version = "1.2.0"+version = "1.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "914566e6413e7fa959cc394fb30e563ba80f3541fbd40816d4c05a0fc3f2a0f1"+checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f"dependencies = ["libc",- "linux-raw-sys 0.4.12",- "rustix 0.38.28",+ "linux-raw-sys 0.4.13",+ "rustix 0.38.30",][[package]]diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex 6435b4811..c7d953210 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -154,15 +154,10 @@ pub async fn stop_all_recordings(state: State<'_, Arc<Mutex<RecordingState>>>) -fn clean_and_create_dir(dir: &Path) -> Result<(), String> {if dir.exists() {- for entry in std::fs::read_dir(dir).map_err(|e| e.to_string())? {- let entry = entry.map_err(|e| e.to_string())?;- if entry.path().is_file() {- std::fs::remove_file(entry.path()).map_err(|e| e.to_string())?;- }- }- } else {- std::fs::create_dir_all(dir).map_err(|e| e.to_string())?;+ // Instead of just reading the directory, this will also handle subdirectories.+ std::fs::remove_dir_all(dir).map_err(|e| e.to_string())?;}+ std::fs::create_dir_all(dir).map_err(|e| e.to_string())?;// Ensure the segment list file exists within the given directory// This assumes a naming convention where the segment list file is named "segment_list.txt"@@ -193,7 +188,7 @@ async fn construct_recording_args(video_type: &str,input_index: &str,) -> Result<Vec<String>, String> {- let output_filename_pattern = format!("{}/recording_chunk_%03d.mkv", chunks_dir.display());+ let output_filename_pattern = format!("{}/recording_chunk_%03d.ts", chunks_dir.display());let segment_list_filename = format!("{}/segment_list.txt", chunks_dir.display());ensure_segment_list_exists(PathBuf::from(&segment_list_filename))@@ -223,7 +218,7 @@ async fn construct_recording_args("-r".to_string(), fps.to_string(),"-f".to_string(), "segment".to_string(),"-segment_time".to_string(), segment_time,- "-segment_format".to_string(), "matroska".to_string(),+ "-segment_format".to_string(), "mpegts".to_string(),"-segment_list".to_string(), segment_list_filename,"-segment_list_type".to_string(), segment_list_type,"-reset_timestamps".to_string(), "1".to_string(),@@ -242,7 +237,7 @@ async fn construct_recording_args("-r".to_string(), fps.to_string(),"-f".to_string(), "segment".to_string(),"-segment_time".to_string(), segment_time,- "-segment_format".to_string(), "matroska".to_string(),+ "-segment_format".to_string(), "mpegts".to_string(),"-segment_list".to_string(), segment_list_filename,"-segment_list_type".to_string(), segment_list_type,"-reset_timestamps".to_string(), "1".to_string(),@@ -448,12 +443,12 @@ async fn upload_remaining_chunks(let entries = std::fs::read_dir(chunks_dir).map_err(|e| format!("Error reading directory: {}", e))?;- let semaphore = Arc::new(Semaphore::new(16)); // Control concurrency to prevent resource exhaustion.+ let semaphore = Arc::new(Semaphore::new(16));let tasks: Vec<_> = entries.filter_map(|entry| entry.ok()).filter_map(|entry| {let path = entry.path();- if path.is_file() && (path.extension().map_or(false, |e| e == "mkv" || e == "webm")) && !shutdown_flag.load(Ordering::SeqCst) {+ if path.is_file() && (path.extension().map_or(false, |e| e == "ts" || e == "webm")) && !shutdown_flag.load(Ordering::SeqCst) {let video_type = video_type.to_string();let semaphore_clone = semaphore.clone();let actual_options_clone = actual_options.clone();diff --git a/apps/desktop/src-tauri/src/upload.rs b/apps/desktop/src-tauri/src/upload.rsindex c2f824db8..e1b2b9fa5 100644--- a/apps/desktop/src-tauri/src/upload.rs+++ b/apps/desktop/src-tauri/src/upload.rs@@ -1,8 +1,10 @@use serde_json::Value as JsonValue;use std::path::{Path};+use std::process::Command;use reqwest;use crate::recording::RecordingOptions;+use crate::utils::ffmpeg_path_as_str;#[tauri::command]pub async fn upload_file(@@ -13,6 +15,9 @@ pub async fn upload_file(if let Some(ref options) = options {println!("Uploading video...");+ let video_duration = get_video_duration(&file_path).await?;+ let video_duration_str = format!("{:.1}", video_duration);+let file_name = Path::new(&file_path).file_name().and_then(|name| name.to_str())@@ -26,6 +31,7 @@ pub async fn upload_file(// Create the request body for the Next.js handlerlet body = serde_json::json!({"userId": options.user_id,+ "duration": video_duration_str,"fileKey": file_key,"awsBucket": options.aws_bucket,"awsRegion": options.aws_region,@@ -65,7 +71,7 @@ pub async fn upload_file(let file_bytes = tokio::fs::read(&file_path).await.map_err(|e| format!("Failed to read file: {}", e))?;let file_part = reqwest::multipart::Part::bytes(file_bytes).file_name(file_name.clone())- .mime_str("application/octet-stream")+ .mime_str("video/mp2t").map_err(|e| format!("Error setting MIME type: {}", e))?;form = form.part("file", file_part);@@ -110,4 +116,46 @@ pub async fn upload_file(} else {return Err("No recording options provided".to_string());}+}++async fn get_video_duration(file_path: &str) -> Result<f64, String> {+ let ffmpeg_binary_path_str = ffmpeg_path_as_str()?;++ let output = Command::new(&ffmpeg_binary_path_str)+ .args(&[+ "-i", file_path,+ "-f", "null",+ "-"])+ .output()+ .map_err(|e| format!("Failed to execute FFmpeg for getting duration: {}", e))?;++ // Extract the duration from FFmpeg's stderr+ let stderr = String::from_utf8_lossy(&output.stderr);++ println!("Stderr: {}", stderr);++ let duration_line = stderr.split('\n')+ .find(|line| line.contains("Duration"))+ .ok_or("Duration line not found in FFmpeg output")?;++ println!("Duration line: {}", duration_line);++ let duration_str = duration_line.split("Duration:").nth(1).unwrap()+ .split(',').next().unwrap()+ .trim();++ println!("Duration string: {}", duration_str);++ let duration_parts: Vec<&str> = duration_str.split(':').collect();+ if duration_parts.len() != 3 {+ return Err("Invalid duration format".to_string());+ }++ let hours: f64 = duration_parts[0].parse().map_err(|_| "Failed to parse hours")?;+ let minutes: f64 = duration_parts[1].parse().map_err(|_| "Failed to parse minutes")?;+ let seconds: f64 = duration_parts[2].parse().map_err(|_| "Failed to parse seconds")?;++ let total_seconds = hours * 3600.0 + minutes * 60.0 + seconds;++ Ok(total_seconds)}\ No newline at end of filediff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsxindex 55d55a2e4..5164388da 100644--- a/apps/desktop/src/components/windows/inner/Recorder.tsx+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx@@ -245,79 +245,81 @@ export const Recorder = () => {}, []);return (- <div- data-tauri-drag-region- className="relative flex items-center justify-center"- >+ <>{countdownActive && (<CountdowncountdownFrom={3}onCountdownFinish={handleOverlayFinished}/>)}- <div className="w-full">- <div className="flex items-center justify-between mb-4">- <div>- <Logo className="w-24 h-auto" />- </div>- </div>- <div className="space-y-4 w-full">- <div>- <label className="text-sm font-medium">Display</label>- <div className="flex items-center space-x-1">- <ActionButton- handler={() => console.log("Screen option selected")}- icon={<Screen className="w-5 h-5" />}- label="Screen"- active={selectedDisplayType === "screen"}- />- <ActionButton- handler={() => toast.error("This option is coming soon!")}- icon={<Window className="w-5 h-5" />}- label="Window"- active={selectedDisplayType === "window"}- />+ <div+ data-tauri-drag-region+ className="relative flex items-center justify-center"+ >+ <div className="w-full">+ <div className="flex items-center justify-between mb-4">+ <div>+ <Logo className="w-24 h-auto" /></div></div>- <div>- <label className="text-sm font-medium">Webcam / Video</label>- <div className="space-y-1">- <ActionButton- width="full"- handler={() => handleContextClick("video")}- icon={<Video className="w-5 h-5" />}- label={selectedVideoDevice?.label || "Video"}- active={selectedVideoDevice !== null}- />- <ActionButton- width="full"- handler={() => handleContextClick("audio")}- icon={<Microphone className="w-5 h-5" />}- label={selectedAudioDevice?.label || "Mic"}- active={selectedAudioDevice !== null}- />+ <div className="space-y-4 w-full">+ <div>+ <label className="text-sm font-medium">Display</label>+ <div className="flex items-center space-x-1">+ <ActionButton+ handler={() => console.log("Screen option selected")}+ icon={<Screen className="w-5 h-5" />}+ label="Screen"+ active={selectedDisplayType === "screen"}+ />+ <ActionButton+ handler={() => toast.error("This option is coming soon!")}+ icon={<Window className="w-5 h-5" />}+ label="Window"+ active={selectedDisplayType === "window"}+ />+ </div>+ </div>+ <div>+ <label className="text-sm font-medium">Webcam / Video</label>+ <div className="space-y-1">+ <ActionButton+ width="full"+ handler={() => handleContextClick("video")}+ icon={<Video className="w-5 h-5" />}+ label={selectedVideoDevice?.label || "Video"}+ active={selectedVideoDevice !== null}+ />+ <ActionButton+ width="full"+ handler={() => handleContextClick("audio")}+ icon={<Microphone className="w-5 h-5" />}+ label={selectedAudioDevice?.label || "Mic"}+ active={selectedAudioDevice !== null}+ />+ </div></div>+ <Button+ className="w-[97.6%] flex mx-auto"+ onClick={() => {+ if (isRecording) {+ handleStopAllRecordings();+ } else {+ handleStartAllRecordings();+ }+ }}+ spinner={stoppingRecording}+ >+ {isRecording+ ? stoppingRecording+ ? currentStoppingMessage+ : "Stop Recording"+ : "Start Recording"}+ </Button></div>- <Button- className="w-[97.6%] flex mx-auto"- onClick={() => {- if (isRecording) {- handleStopAllRecordings();- } else {- handleStartAllRecordings();- }- }}- spinner={stoppingRecording}- >- {isRecording- ? stoppingRecording- ? currentStoppingMessage- : "Stop Recording"- : "Start Recording"}- </Button></div>+ <Toaster /></div>- <Toaster />- </div>+ </>);};diff --git a/apps/desktop/src/utils/recording/useMediaRecorder.ts b/apps/desktop/src/utils/recording/useMediaRecorder.tsindex 98d05e25e..b5c668e77 100644--- a/apps/desktop/src/utils/recording/useMediaRecorder.ts+++ b/apps/desktop/src/utils/recording/useMediaRecorder.ts@@ -1,12 +1,34 @@-import { useState, useRef, useCallback } from "react";-import { writeBinaryFile, createDir } from "@tauri-apps/api/fs";+import { useState, useRef, useCallback, useEffect } from "react";+import { FFmpeg as FfmpegType } from "@ffmpeg/ffmpeg";+import { fetchFile } from "@ffmpeg/util";+import {+ writeBinaryFile,+ writeTextFile,+ readTextFile,+ createDir,+} from "@tauri-apps/api/fs";import { appDataDir, join } from "@tauri-apps/api/path";-import { writeTextFile, readTextFile } from "@tauri-apps/api/fs";export const useMediaRecorder = () => {- const [isRecording, setIsRecording] = useState(false);+ const isRecording = useRef(false);const mediaRecorder = useRef<MediaRecorder | null>(null);- const chunkCounter = useRef(0);+ const [ffmpegLoaded, setFfmpegLoaded] = useState(false);+ const ffmpegRef = useRef<FfmpegType | null>(null);+ const queue = useRef<Blob[]>([]);+ const processingQueue = useRef(false);+ const segmentCounter = useRef(0);++ useEffect(() => {+ const loadFfmpeg = async () => {+ const { FFmpeg } = await import("@ffmpeg/ffmpeg");+ ffmpegRef.current = new FFmpeg();+ setFfmpegLoaded(true);+ };++ if (!ffmpegLoaded && !ffmpegRef.current) {+ loadFfmpeg();+ }+ }, [ffmpegLoaded]);const getVideoChunksDir = async () => {const dir = await appDataDir();@@ -19,93 +41,195 @@ export const useMediaRecorder = () => {let fileContent;try {- // Try to read the existing contentfileContent = await readTextFile(segmentListPath);} catch (error) {- // If there's an error (like file doesn't exist), we start with an empty stringfileContent = "";}- // Create new content by appending the new file name (not the full path)const newContent = `${fileContent}${fileName}\n`;-- // Write the new content back to the file, effectively appending itawait writeTextFile(segmentListPath, newContent);};- const handleDataAvailable = useCallback(async (event: BlobEvent) => {- const blob = new Blob([event.data], { type: "video/webm" });- const buffer = await blob.arrayBuffer();- const dir = await getVideoChunksDir();- const chunkNumber = chunkCounter.current++;- const fileName = `recording_chunk_${String(chunkNumber).padStart(- 3,- "0"- )}.webm`;- const filePath = await join(dir, fileName);-- // First write the binary file- await writeBinaryFile({- path: filePath,- contents: buffer,- })- .then(() => {- // After a successful write, append to the segment list file- appendToSegmentListFile(fileName).catch((error) => {- // Handle errors during the append operation- console.error(- `Failed to append to segment list file: ${error.message}`- );- });- })- .catch((error) => {- // Handle errors during the file writing- console.error(`Failed to write video chunk: ${error.message}`);- });- }, []);- const startMediaRecording = useCallback(- async (stream: MediaStream) => {- chunkCounter.current = 0;+ const saveFile = async (data: Uint8Array, fileName: string) => {+ try {const dir = await getVideoChunksDir();await createDir(dir, { recursive: true });- const segmentListPath = await join(dir, "segment_list.txt");- await writeTextFile({ path: segmentListPath, contents: "" });-- // Set up and start the MediaRecorder- if (MediaRecorder.isTypeSupported("video/webm;codecs=h264")) {- mediaRecorder.current = new MediaRecorder(stream, {- mimeType: "video/webm;codecs=h264",- });- } else {- // Fallback to the default MIME type if 'webm' is not supported- mediaRecorder.current = new MediaRecorder(stream);+ const filePath = await join(dir, fileName);+ await writeBinaryFile(filePath, data);+ await appendToSegmentListFile(fileName);+ } catch (error) {+ console.error("Failed to save file:", error);+ }+ };++ const processQueue = useCallback(async () => {+ if (+ ffmpegRef.current &&+ !processingQueue.current &&+ queue.current.length > 0+ ) {+ processingQueue.current = true;++ if (ffmpegRef.current) {+ try {+ await ffmpegRef.current.load();+ } catch (error) {+ console.error("Failed to load FFmpeg:", error);+ return;+ }}- mediaRecorder.current.ondataavailable = handleDataAvailable;- mediaRecorder.current.onerror = (event: any) => {- console.error("Recording error:", event.error);++ ffmpegRef.current.on("log", (log) => {+ console.log("FFmpeg log:", log.message);+ });++ while (queue.current.length > 0) {+ try {+ const chunk = queue.current.shift();++ if (!chunk) {+ continue;+ }++ console.log("log-1");++ const chunkNumber = segmentCounter.current++;++ const ffmpeg = ffmpegRef.current;++ if (!ffmpeg) {+ console.error("FFmpeg not loaded");+ return;+ }++ const inputFileName = `input-${String(chunkNumber).padStart(+ 3,+ "0"+ )}.mp4`;+ const outputFileName = `output-${String(chunkNumber).padStart(+ 3,+ "0"+ )}.ts`;++ const buffer = new Uint8Array(await chunk.arrayBuffer());+ const videoBuffer = await fetchFile(new Blob([buffer]));++ console.log("video buffer:");+ console.log(videoBuffer);++ console.log("log-2");++ await ffmpeg.writeFile(inputFileName, videoBuffer);++ console.log("log-3");++ await ffmpeg.exec([+ "-i",+ inputFileName,+ "-c:v",+ "libx264",+ "-preset",+ "veryfast",+ "-tune",+ "zerolatency",+ "-c:a",+ "aac",+ "-strict",+ "experimental",+ "-f",+ "mpegts",+ outputFileName,+ ]);++ console.log("log-4");++ try {+ const savedVideo = (await ffmpeg.readFile(+ outputFileName+ )) as Uint8Array;+ await saveFile(savedVideo, outputFileName);+ console.log("log-5");+ } catch (error) {+ console.error("Failed to save file:", error);+ }++ console.log("log-6");++ await ffmpeg.deleteFile(inputFileName);+ await ffmpeg.deleteFile(outputFileName);++ console.log("log-7");+ } catch (error) {+ console.error("Failed to process chunk:", error);+ }+ }++ processingQueue.current = false;+ }+ }, [queue]);++ const startMediaRecording = useCallback(+ async (stream: MediaStream) => {+ // Reset queue and counters here to ensure a fresh start+ queue.current = []; // Clear the queue+ segmentCounter.current = 0;+ processingQueue.current = false;+ isRecording.current = true;+ console.log("Recording started");++ const options = { mimeType: "video/mp4;" };+ mediaRecorder.current = new MediaRecorder(stream, options);++ mediaRecorder.current.ondataavailable = (event) => {+ console.log(`Blob size: ${event.data.size}`);+ if (event.data.size > 0) {+ queue.current.push(event.data);+ processQueue();+ }};- mediaRecorder.current.start(3000);- setIsRecording(true);+ mediaRecorder.current.start();++ const requestDataInterval = setInterval(() => {+ if (mediaRecorder.current && isRecording.current) {+ console.log("Requesting data periodically");+ mediaRecorder.current.stop();+ mediaRecorder.current.start();+ } else {+ clearInterval(requestDataInterval);+ }+ }, 3000);++ return () => {+ if (+ mediaRecorder.current &&+ mediaRecorder.current.state !== "inactive"+ ) {+ mediaRecorder.current.stop();+ isRecording.current = false;+ // clearInterval(requestDataInterval);+ }+ console.log("Recording stopped");+ };},- [handleDataAvailable]+ [processQueue]);const stopMediaRecording = useCallback(async () => {- if (mediaRecorder.current && isRecording) {- mediaRecorder.current.onstop = async () => {- setIsRecording(false);- chunkCounter.current = 0;+ isRecording.current = false;- console.log("Media recording stopped.");- };+ while (processingQueue.current || queue.current.length > 0) {+ await new Promise((resolve) => setTimeout(resolve, 100));+ }+ if (mediaRecorder.current && mediaRecorder.current.state !== "inactive") {mediaRecorder.current.stop();+ console.log("Media recording stopped and queue processed.");}- }, [isRecording]);+ }, []);return {- isRecording,+ isRecording: isRecording.current,startMediaRecording,stopMediaRecording,};diff --git a/apps/desktop/src/utils/recording/utils.ts b/apps/desktop/src/utils/recording/utils.tsindex b83b1234c..a29f97e88 100644--- a/apps/desktop/src/utils/recording/utils.ts+++ b/apps/desktop/src/utils/recording/utils.ts@@ -16,17 +16,15 @@ export const enumerateAndStoreDevices = async () => {};export const getLocalDevices = async () => {- if (typeof navigator !== "undefined" && typeof window !== "undefined") {- const videoDevices = JSON.parse(- window.localStorage.getItem("videoDevices") || "[]"- ) as MediaDeviceInfo[];+ const videoDevices = JSON.parse(+ window.localStorage.getItem("videoDevices") || "[]"+ ) as MediaDeviceInfo[];- const audioDevices = JSON.parse(- window.localStorage.getItem("audioDevices") || "[]"- ) as MediaDeviceInfo[];+ const audioDevices = JSON.parse(+ window.localStorage.getItem("audioDevices") || "[]"+ ) as MediaDeviceInfo[];- return { audioDevices, videoDevices };- }+ return { audioDevices, videoDevices };};export const getSelectedVideoProperties = async () => {diff --git a/apps/web/app/api/playlist/route.ts b/apps/web/app/api/playlist/route.tsnew file mode 100644index 000000000..5d39480fc--- /dev/null+++ b/apps/web/app/api/playlist/route.ts@@ -0,0 +1,178 @@+import { type NextRequest } from "next/server";+import { db } from "@cap/database";+import { videos } from "@cap/database/schema";+import { eq } from "drizzle-orm";+import {+ S3Client,+ ListObjectsV2Command,+ GetObjectCommand,+ HeadObjectCommand,+} from "@aws-sdk/client-s3";+import { getSignedUrl } from "@aws-sdk/s3-request-presigner";+import { getCurrentUser } from "@cap/database/auth/session";+import { generateM3U8Playlist } from "@/utils/video/ffmpeg/helpers";++export const revalidate = 3500;++export async function GET(request: NextRequest) {+ const searchParams = request.nextUrl.searchParams;+ const userId = searchParams.get("userId") || "";+ const videoId = searchParams.get("videoId") || "";+ const videoType = searchParams.get("videoType") || "";++ if (!userId || !videoId) {+ return new Response(+ JSON.stringify({+ error: true,+ message: "userId or videoId not supplied",+ }),+ {+ status: 401,+ headers: {+ "Content-Type": "application/json",+ },+ }+ );+ }++ const query = await db.select().from(videos).where(eq(videos.id, videoId));++ if (query.length === 0) {+ return new Response(+ JSON.stringify({ error: true, message: "Video does not exist" }),+ {+ status: 401,+ headers: {+ "Content-Type": "application/json",+ },+ }+ );+ }++ const video = query[0];++ if (video.public === false) {+ const user = await getCurrentUser();++ if (!user || user.userId !== video.ownerId) {+ return new Response(+ JSON.stringify({ error: true, message: "Video is not public" }),+ {+ status: 401,+ headers: {+ "Content-Type": "application/json",+ },+ }+ );+ }+ }++ const s3Client = new S3Client({+ region: process.env.CAP_AWS_REGION || "",+ credentials: {+ accessKeyId: process.env.CAP_AWS_ACCESS_KEY || "",+ secretAccessKey: process.env.CAP_AWS_SECRET_KEY || "",+ },+ });++ const bucket = process.env.CAP_AWS_BUCKET || "";+ const screenPrefix = `${userId}/${videoId}/screen/`;+ const videoPrefix = `${userId}/${videoId}/video/`;++ try {+ if (videoType === "screen") {+ const screenObjectsCommand = new ListObjectsV2Command({+ Bucket: bucket,+ Prefix: screenPrefix,+ });+ const screenObjects = await s3Client.send(screenObjectsCommand);++ const screenChunksUrls = await Promise.all(+ (screenObjects.Contents || []).map(async (object) => {+ const url = await getSignedUrl(+ s3Client,+ new GetObjectCommand({+ Bucket: bucket,+ Key: object.Key,+ }),+ { expiresIn: 3600 }+ );+ const metadata = await s3Client.send(+ new HeadObjectCommand({+ Bucket: bucket,+ Key: object.Key,+ })+ );++ return { url: url, duration: metadata?.Metadata?.duration ?? "" };+ })+ );++ const generatedScreenPlaylist = await generateM3U8Playlist(+ screenChunksUrls+ );++ return new Response(generatedScreenPlaylist, {+ status: 200,+ headers: { "content-type": "application/x-mpegURL" },+ });+ } else if (videoType === "video") {+ const videoObjectsCommand = new ListObjectsV2Command({+ Bucket: bucket,+ Prefix: videoPrefix,+ });+ const videoObjects = await s3Client.send(videoObjectsCommand);++ const videoChunksUrls = await Promise.all(+ (videoObjects.Contents || []).map(async (object) => {+ const url = await getSignedUrl(+ s3Client,+ new GetObjectCommand({+ Bucket: bucket,+ Key: object.Key,+ }),+ { expiresIn: 3600 }+ );+ const metadata = await s3Client.send(+ new HeadObjectCommand({+ Bucket: bucket,+ Key: object.Key,+ })+ );++ return { url: url, duration: metadata?.Metadata?.duration ?? "" };+ })+ );++ const generatedVideoPlaylist = await generateM3U8Playlist(+ videoChunksUrls+ );++ return new Response(generatedVideoPlaylist, {+ status: 200,+ headers: { "content-type": "application/x-mpegURL" },+ });+ } else {+ return new Response(+ JSON.stringify({ error: true, message: "Invalid video type" }),+ {+ status: 401,+ headers: {+ "Content-Type": "application/json",+ },+ }+ );+ }+ } catch (error) {+ console.error("Error generating video segment URLs", error);+ return new Response(+ JSON.stringify({ error: true, message: "Error generating video URLs" }),+ {+ status: 500,+ headers: {+ "Content-Type": "application/json",+ },+ }+ );+ }+}diff --git a/apps/web/app/api/upload/signed/route.ts b/apps/web/app/api/upload/signed/route.tsindex 8312bb518..08e03817b 100644--- a/apps/web/app/api/upload/signed/route.ts+++ b/apps/web/app/api/upload/signed/route.ts@@ -12,9 +12,14 @@ const s3Client = new S3Client({export async function POST(request: NextRequest) {try {- const { userId, fileKey, awsBucket, awsRegion } = await request.json();+ const { userId, fileKey, duration, awsBucket, awsRegion } =+ await request.json();- if (!userId || !fileKey || !awsBucket || !awsRegion) {+ console.log("Duration start...");+ console.log(duration);+ console.log("...Duration end...");++ if (!userId || !duration || !fileKey || !awsBucket || !awsRegion) {console.error("Missing required fields in /api/upload/signed/route.ts");return new Response(@@ -29,7 +34,9 @@ export async function POST(request: NextRequest) {}const Fields = {+ "Content-Type": "video/mp2t","x-amz-meta-userid": userId,+ "x-amz-meta-duration": duration,};const presignedPostData: PresignedPost = await createPresignedPost(diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsxindex dc543ce04..2c695c321 100644--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx@@ -10,7 +10,7 @@ import {History,} from "lucide-react";import Link from "next/link";-import { classNames } from "@/utils/helpers";+import { classNames } from "@cap/utils";// import {// Command,// CommandEmpty,diff --git a/apps/web/app/globals.css b/apps/web/app/globals.cssindex 45601b9ac..2126e0a03 100644--- a/apps/web/app/globals.css+++ b/apps/web/app/globals.css@@ -290,3 +290,8 @@ ul {slot:not(.dashboard-layout slot) {display: block;}++.video-player slot {+ width: 100%;+ height: 100%;+}diff --git a/apps/web/app/share/[videoId]/Share.tsx b/apps/web/app/share/[videoId]/Share.tsxindex 9af7fdf17..0ea9393f0 100644--- a/apps/web/app/share/[videoId]/Share.tsx+++ b/apps/web/app/share/[videoId]/Share.tsx@@ -1,129 +1,50 @@"use client";-import { fetchFile } from "@ffmpeg/util";-import { useEffect, useRef, useState } from "react";import { ShareHeader } from "./_components/ShareHeader";import { videos } from "@cap/database/schema";-import { FFmpeg as FfmpegType } from "@ffmpeg/ffmpeg";-import { concatenateSegments } from "@/utils/video/ffmpeg/helpers";--export const Share = ({- data,- urls,-}: {- data: typeof videos.$inferSelect;- urls: {- videoUrls: string[];- screenUrls: string[];- singleScreenUrl: string;- singleVideoUrl: string;- };-}) => {- const [videoSrc, setVideoSrc] = useState<string>("");- const [screenSrc, setScreenSrc] = useState<string>("");- const videoRef = useRef<HTMLVideoElement>(null);- const screenRef = useRef<HTMLVideoElement>(null);- const [loading, setLoading] = useState(true);- const [ffmpegLoaded, setFfmpegLoaded] = useState(false);- const ffmpegRef = useRef<FfmpegType | null>(null);-- useEffect(() => {- const loadFfmpeg = async () => {- const { FFmpeg } = await import("@ffmpeg/ffmpeg");- ffmpegRef.current = new FFmpeg();- setFfmpegLoaded(true);- };-- if (!ffmpegLoaded && !ffmpegRef.current) {- loadFfmpeg();- }- }, [ffmpegLoaded]);-- useEffect(() => {- const loadVideos = async () => {- setLoading(true);- try {- console.log("urls", urls);-- if (urls.singleVideoUrl) {- setVideoSrc(urls.singleVideoUrl);- }-- if (urls.singleScreenUrl) {- setScreenSrc(urls.singleScreenUrl);- }-- if (urls.videoUrls.length > 0 && ffmpegRef.current) {- const concatenatedVideoData = await concatenateSegments(- ffmpegRef.current,- urls.videoUrls,- data.id,- "video_output.mp4",- "webm",- "mp4"- );- setVideoSrc(- URL.createObjectURL(- new Blob([concatenatedVideoData], { type: "video/mp4" })- )- );- }-- if (urls.screenUrls.length > 0 && ffmpegRef.current) {- const concatenatedScreenData = await concatenateSegments(- ffmpegRef.current,- urls.screenUrls,- data.id,- "screen_output.mp4",- "mkv",- "mp4"- );- setScreenSrc(- URL.createObjectURL(- new Blob([concatenatedScreenData], { type: "video/mp4" })- )- );- }- } catch (error) {- console.error("Error loading videos", error);- // Handle video loading error if desired- } finally {- setLoading(false); // End loading process- }- };-- loadVideos();- }, [urls, ffmpegLoaded]);+import { VideoPlayer } from "./_components/VideoPlayer";+import { useState, useCallback } from "react";+import { PlayCircle, PauseCircle } from "lucide-react";++export const Share = ({ data }: { data: typeof videos.$inferSelect }) => {+ const [isPlaying, setIsPlaying] = useState(false);++ const handlePlayPause = useCallback(+ (playing: boolean | ((prevState: boolean) => boolean)) => {+ setIsPlaying(playing);+ },+ []+ );return (<div className="wrapper py-6"><div className="space-y-8"><ShareHeader title={data.name} />- <div>- {loading ? (- <p>Loading</p>- ) : (- <div className="aspect-video relative bg-gradient-to-b from-secondary to-secondary-3 p-10 flex items-center justify-center rounded-lg">- {videoSrc && (- <div className="absolute bottom-2 right-2 w-[180px] h-[180px] m-0 p-0 rounded-full overflow-hidden z-10 shadow-[0px 0px 200px rgba(0,0,0,0.18)] border-2 border-white">- <video- ref={videoRef}- className="w-full h-full object-cover"- controls- src={videoSrc}- />- </div>- )}- {screenSrc && (- <video- className="rounded-lg"- ref={screenRef}- controls- src={screenSrc}- />+ <div className="aspect-video relative bg-gradient-to-b from-secondary to-secondary-3 p-16 flex items-center justify-center rounded-lg group">+ <div className="video-player w-[175px] h-[175px] absolute bottom-4 right-12 overflow-hidden rounded-full z-10 shadow-[0px 0px 180px rgba(255, 255, 255, 0.18)]">+ <VideoPlayer+ isPlaying={isPlaying}+ onPlayPause={handlePlayPause}+ src={`${process.env.NEXT_PUBLIC_URL}/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=video`}+ />+ </div>+ <div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-10">+ <button+ className="hidden group-hover:block w-32 h-32 z-10 relative cursor-pointer"+ onClick={() => handlePlayPause(!isPlaying)}+ >+ {isPlaying ? (+ <PauseCircle className="w-full h-auto text-white" />+ ) : (+ <PlayCircle className="w-full h-auto text-white" />)}- </div>- )}+ </button>+ </div>+ <VideoPlayer+ isPlaying={isPlaying}+ onPlayPause={handlePlayPause}+ src={`${process.env.NEXT_PUBLIC_URL}/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=screen`}+ /></div></div></div>diff --git a/apps/web/app/share/[videoId]/_components/VideoPlayer.tsx b/apps/web/app/share/[videoId]/_components/VideoPlayer.tsxnew file mode 100644index 000000000..4403caac3--- /dev/null+++ b/apps/web/app/share/[videoId]/_components/VideoPlayer.tsx@@ -0,0 +1,85 @@+import { useEffect, useRef, useState } from "react";+import Hls from "hls.js";++export function VideoPlayer({+ src,+ isPlaying: isPlayingProp,+ onPlayPause,+}: {+ src: string;+ isPlaying: boolean;+ onPlayPause: (isPlaying: boolean) => void;+}) {+ const videoRef = useRef<HTMLVideoElement | null>(null);+ // Initialize local playing state based on prop+ const [isPlaying, setIsPlaying] = useState(isPlayingProp);+ const [isLoaded, setIsLoaded] = useState(false);++ const onLoadedData = () => {+ setIsLoaded(true);+ const video = videoRef.current;+ if (!video) return;+ video.currentTime = 0;+ video.play();+ };++ useEffect(() => {+ const video = videoRef.current;+ if (!video) return;++ if (Hls.isSupported()) {+ const hls = new Hls();+ hls.loadSource(src);+ hls.attachMedia(video);+ }++ // Synchronize video playback with local state+ const handlePlay = () => setIsPlaying(true);+ const handlePause = () => setIsPlaying(false);+ const handleLoadedData = () => onLoadedData();+ video.addEventListener("play", handlePlay);+ video.addEventListener("pause", handlePause);+ video.addEventListener("loadeddata", handleLoadedData);++ // Cleanup+ return () => {+ video.removeEventListener("play", handlePlay);+ video.removeEventListener("pause", handlePause);+ video.removeEventListener("loadeddata", handleLoadedData);+ };+ }, [src]);++ useEffect(() => {+ // Synchronize local state with prop when it changes+ setIsPlaying(isPlayingProp);+ }, [isPlayingProp]);++ // Propagate play/pause action upstream+ useEffect(() => {+ onPlayPause(isPlaying);+ }, [isPlaying, onPlayPause]);++ useEffect(() => {+ const video = videoRef.current;+ if (video) {+ isPlaying ? video.play() : video.pause();+ }+ }, [isPlaying]);++ if (!isLoaded) {+ return (+ <div className="w-full h-full object-cover">+ <p>Loading</p>+ </div>+ );+ } else {+ return (+ <video+ className="w-full h-full object-cover"+ ref={videoRef}+ src={src}+ autoPlay={isPlayingProp}+ />+ );+ }+}diff --git a/apps/web/app/share/[videoId]/page.tsx b/apps/web/app/share/[videoId]/page.tsxindex 3f6c5cd96..a41d5dfe3 100644--- a/apps/web/app/share/[videoId]/page.tsx+++ b/apps/web/app/share/[videoId]/page.tsx@@ -3,160 +3,22 @@ import { Share } from "./Share";import { db } from "@cap/database";import { eq } from "drizzle-orm";import { videos } from "@cap/database/schema";-import {- S3Client,- ListObjectsV2Command,- GetObjectCommand,- HeadObjectCommand,-} from "@aws-sdk/client-s3";-import { getSignedUrl } from "@aws-sdk/s3-request-presigner";type Props = {params: { [key: string]: string | string[] | undefined };};-const s3Client = new S3Client({- region: process.env.CAP_AWS_REGION || "",- credentials: {- accessKeyId: process.env.CAP_AWS_ACCESS_KEY || "",- secretAccessKey: process.env.CAP_AWS_SECRET_KEY || "",- },-});--async function generateVideoSegmentUrls(userId: string, videoId: string) {- const bucket = process.env.CAP_AWS_BUCKET || "";- const outputScreenKey = `${userId}/${videoId}/screen_output.mp4`;- const outputVideoKey = `${userId}/${videoId}/video_output.mp4`;-- // Prefixes for screen and video segments- const screenPrefix = `${userId}/${videoId}/screen/`;- const videoPrefix = `${userId}/${videoId}/video/`;-- const checkSingleOutputsExist = async (key: string) => {- try {- const headObjectCommand = new HeadObjectCommand({- Bucket: bucket,- Key: key,- });- await s3Client.send(headObjectCommand);- return true;- } catch (error: any) {- if (error?.name === "NotFound") return false;- throw error;- }- };-- const doesScreenOutputExist = await checkSingleOutputsExist(outputScreenKey);- const doesVideoOutputExist = await checkSingleOutputsExist(outputVideoKey);-- if (doesScreenOutputExist && doesVideoOutputExist) {- // Return pre-signed URLs for the single output files- const screenOutputUrl = await getSignedUrl(- s3Client,- new GetObjectCommand({- Bucket: bucket,- Key: outputScreenKey,- })- );-- const videoOutputUrl = await getSignedUrl(- s3Client,- new GetObjectCommand({- Bucket: bucket,- Key: outputVideoKey,- })- );-- return {- singleScreenUrl: screenOutputUrl,- singleVideoUrl: videoOutputUrl,- screenChunksUrls: [],- videoChunksUrls: [],- };- }-- try {- // Fetch the list of objects for screen recordings- const screenObjectsCommand = new ListObjectsV2Command({- Bucket: bucket,- Prefix: screenPrefix,- });- const screenObjects = await s3Client.send(screenObjectsCommand);-- // Fetch the list of objects for video recordings- const videoObjectsCommand = new ListObjectsV2Command({- Bucket: bucket,- Prefix: videoPrefix,- });- const videoObjects = await s3Client.send(videoObjectsCommand);-- // Generate pre-signed URLs for screen recording chunks- const screenChunksUrls = await Promise.all(- (screenObjects.Contents || []).map(async (object) => {- return getSignedUrl(- s3Client,- new GetObjectCommand({- Bucket: bucket,- Key: object.Key,- }),- { expiresIn: 3600 }- );- })- );-- // Generate pre-signed URLs for video recording chunks- const videoChunksUrls = await Promise.all(- (videoObjects.Contents || []).map(async (object) => {- return getSignedUrl(- s3Client,- new GetObjectCommand({- Bucket: bucket,- Key: object.Key,- }),- { expiresIn: 3600 }- );- })- );-- return {- screenChunksUrls,- videoChunksUrls,- singleScreenUrl: "",- singleVideoUrl: "",- };- } catch (error) {- console.error("Error generating video segment URLs", error);- throw new Error("Could not generate video segment URLs");- }-}-export default async function ShareVideoPage(props: Props) {const params = props.params;const videoId = params.videoId as string;- console.log("videoId: ", videoId);-const query = await db.select().from(videos).where(eq(videos.id, videoId));- console.log("query", query);-if (query.length === 0) {return <p>No video found</p>;}const video = query[0];- const urls = await generateVideoSegmentUrls(video.ownerId, video.id);-- const videoUrls = urls.videoChunksUrls || [];- const screenUrls = urls.screenChunksUrls || [];- const singleVideoUrl = urls.singleVideoUrl || "";- const singleScreenUrl = urls.singleScreenUrl || "";-- return (- <Share- data={video}- urls={{ videoUrls, screenUrls, singleScreenUrl, singleVideoUrl }}- />- );+ return <Share data={video} />;}diff --git a/apps/web/package.json b/apps/web/package.jsonindex 7b42a0029..af9110a66 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -26,6 +26,7 @@"cookies-next": "^4.1.0","dotenv": "^16.3.1","drizzle-orm": "^0.29.3",+ "hls.js": "^1.5.3","lucide-react": "^0.294.0","million": "^2.6.4","moment": "^2.30.1",@@ -35,8 +36,10 @@"react": "^18.2.0","react-dom": "^18.2.0","react-email": "^1.10.1",+ "react-hls-player": "^3.0.7","react-hook-form": "^7.49.2","react-hot-toast": "^2.4.1",+ "react-player": "^2.14.1","react-scroll-parallax": "^3.4.5","resend": "1.1.0","server-only": "^0.0.1",diff --git a/apps/web/utils/video/ffmpeg/helpers.ts b/apps/web/utils/video/ffmpeg/helpers.tsindex 5f45fa18a..b47840f3e 100644--- a/apps/web/utils/video/ffmpeg/helpers.ts+++ b/apps/web/utils/video/ffmpeg/helpers.ts@@ -52,23 +52,43 @@ export const concatenateSegments = async (// Read the resulting fileconst data = await ffmpeg.readFile(outputFilename);- // Convert the data to a Blob- const blob = new Blob([data], {- type: `video/${outputFormat}`,- });+ // // Convert the data to a Blob+ // const blob = new Blob([data], {+ // type: `video/${outputFormat}`,+ // });- console.log("Uploading to S3...");+ // console.log("Uploading to S3...");- const formData = new FormData();- formData.append("filename", outputFilename);- formData.append("videoId", videoId);- formData.append("blobData", blob);+ // const formData = new FormData();+ // formData.append("filename", outputFilename);+ // formData.append("videoId", videoId);+ // formData.append("blobData", blob);- await fetch(`${process.env.NEXT_PUBLIC_URL}/api/upload/new`, {- method: "POST",- body: formData,- });+ // await fetch(`${process.env.NEXT_PUBLIC_URL}/api/upload/new`, {+ // method: "POST",+ // body: formData,+ // });// Return the URL to the MP4 on S3return data;};++export async function generateM3U8Playlist(+ urls: { url: string; duration: string }[]+) {+ const baseM3U8Content = `#EXTM3U+#EXT-X-PLAYLIST-TYPE:VOD+#EXT-X-TARGETDURATION:4+#EXT-X-VERSION:4+#EXT-X-MEDIA-SEQUENCE:0+`;++ let m3u8Content = baseM3U8Content;+ urls.forEach((url) => {+ m3u8Content += `#EXTINF:${url.duration},\n${url.url}\n`;+ });++ m3u8Content += "#EXT-X-ENDLIST";++ return m3u8Content;+}diff --git a/packages/ui/src/components/Cmdk.tsx b/packages/ui/src/components/Cmdk.tsxindex 50468c1e6..74f8d6961 100644--- a/packages/ui/src/components/Cmdk.tsx+++ b/packages/ui/src/components/Cmdk.tsx@@ -5,7 +5,7 @@ import { DialogProps } from "@radix-ui/react-dialog";import { Command as CommandPrimitive } from "cmdk";import { Search } from "lucide-react";-import { classNames } from "@/utils/helpers";+import { classNames } from "@cap/utils";import { Dialog, DialogContent } from "./Dialog";const Command = React.forwardRef<diff --git a/packages/ui/src/components/Dialog.tsx b/packages/ui/src/components/Dialog.tsxindex a20d183b7..1a9921e0e 100644--- a/packages/ui/src/components/Dialog.tsx+++ b/packages/ui/src/components/Dialog.tsx@@ -4,7 +4,7 @@ import * as React from "react";import * as DialogPrimitive from "@radix-ui/react-dialog";import { X } from "lucide-react";-import { classNames } from "@/utils/helpers";+import { classNames } from "@cap/utils";const Dialog = DialogPrimitive.Root;diff --git a/packages/ui/src/components/Popover.tsx b/packages/ui/src/components/Popover.tsxindex cf5ddb027..6f2e22447 100644--- a/packages/ui/src/components/Popover.tsx+++ b/packages/ui/src/components/Popover.tsx@@ -3,7 +3,7 @@import * as React from "react";import * as PopoverPrimitive from "@radix-ui/react-popover";-import { classNames } from "@/utils/helpers";+import { classNames } from "@cap/utils";const Popover = PopoverPrimitive.Root;diff --git a/packages/ui/src/components/input/Input.tsx b/packages/ui/src/components/input/Input.tsxindex 4e46755a1..d2fa32dc5 100644--- a/packages/ui/src/components/input/Input.tsx+++ b/packages/ui/src/components/input/Input.tsx@@ -1,6 +1,6 @@import * as React from "react";-import { classNames } from "@/utils/helpers";+import { classNames } from "@cap/utils";export interface InputPropsextends React.InputHTMLAttributes<HTMLInputElement> {}diff --git a/packages/ui/src/components/input/Label.tsx b/packages/ui/src/components/input/Label.tsxindex 1539f6ce3..a554e6787 100644--- a/packages/ui/src/components/input/Label.tsx+++ b/packages/ui/src/components/input/Label.tsx@@ -4,7 +4,7 @@ import * as React from "react";import * as LabelPrimitive from "@radix-ui/react-label";import { cva, type VariantProps } from "class-variance-authority";-import { classNames } from "@/utils/helpers";+import { classNames } from "@cap/utils";const labelVariants = cva("text-base font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex fe1284d8d..16e1adf99 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -35,6 +35,12 @@ importers:'@cap/utils':specifier: workspace:*version: link:../../packages/utils+ '@ffmpeg/ffmpeg':+ specifier: ^0.12.10+ version: 0.12.10+ '@ffmpeg/util':+ specifier: ^0.12.1+ version: 0.12.1'@tauri-apps/api':specifier: ^1.5.0version: 1.5.3@@ -150,6 +156,9 @@ importers:drizzle-orm:specifier: ^0.29.3version: 0.29.3(@planetscale/[email protected])(@types/[email protected])([email protected])([email protected])+ hls.js:+ specifier: ^1.5.3+ version: 1.5.3lucide-react:specifier: ^0.294.0version: 0.294.0([email protected])@@ -177,12 +186,18 @@ importers:react-email:specifier: ^1.10.1version: 1.10.1+ react-hls-player:+ specifier: ^3.0.7+ version: 3.0.7([email protected])([email protected])react-hook-form:specifier: ^7.49.2version: 7.49.3([email protected])react-hot-toast:specifier: ^2.4.1+ react-player:+ specifier: ^2.14.1+ version: 2.14.1([email protected])react-scroll-parallax:specifier: ^3.4.5version: 3.4.5([email protected])([email protected])@@ -6154,6 +6169,10 @@ packages:es5-ext: 0.10.62dev: true+ resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}+ dev: false+resolution: {integrity: sha512-kEcvvCBByWXGnZy6JUlgAp2gBIUjfCAV6P6TgT1/aaQKcmuAEC4OZTV1I4EWQLz2gxZw76atuVyvHhTxvi0Flw==}engines: {node: '>=0.4.x'}@@ -6628,6 +6647,17 @@ packages:resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==}dev: true+ resolution: {integrity: sha512-25A7+m6qqp6UVkuzUQ//VVh2EEOPYlOBg32ypr34bcPO7liBMOkKFvbjbCBfiPAOTA/7BSx1Dujft3Th57WyFg==}+ dependencies:+ eventemitter3: 4.0.7+ url-toolkit: 2.2.5+ dev: false++ resolution: {integrity: sha512-gonnYpZ5bxuVdwpcbzfylUlNZ8917LjACUjpWXiaeo8zPAIDfPcMZjEQPy6CeeRSJbcg1P+aVqwxrXr2J+SeUg==}+ dev: false+resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==}dev: false@@ -7253,6 +7283,10 @@ packages:resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}+ resolution: {integrity: sha512-kPEjMFtZvwL9TaZo0uZ2ml+Ye9HUMmPwbYRJ324qF9tqMejwykJ5ggTyvzmrbBeapCAbk98BSbTeovHEEP1uCA==}+ dev: false+resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}engines: {node: '>=8'}@@ -7377,6 +7411,10 @@ packages:engines: {node: '>=8'}dev: false+ resolution: {integrity: sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==}+ dev: false+resolution: {integrity: sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==}dependencies:@@ -8176,7 +8214,6 @@ packages:loose-envify: 1.4.0object-assign: 4.1.1react-is: 16.13.1- dev: trueresolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==}@@ -8269,6 +8306,21 @@ packages:- encodingdev: false+ resolution: {integrity: sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==}+ dev: false++ resolution: {integrity: sha512-i5QWNyLmaUhV/mgnpljRJT0CBfJnylClV/bne8aiXO3ZqU0+D3U/jtTDwdXM4i5qHhyFy9lemyZ179IgadKd0Q==}+ peerDependencies:+ react: ^16.13.1+ react-dom: ^16.13.1+ dependencies:+ hls.js: 0.14.17+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ dev: false+resolution: {integrity: sha512-foD6r3juidAT1cOZzpmD/gOKt7fRsDhXXZ0y28+Al1CHgX+AY1qIN9VSIIItXRq1dN68QrRwl1ORFlwjBaAqeQ==}engines: {node: '>=18', pnpm: '8'}@@ -8294,7 +8346,6 @@ packages:resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}- dev: trueresolution: {integrity: sha512-NilqqwMh2v9omN7LteiDloEVpFyMIa0VGqF+ukqp0ncVlYu1sKYbYGX9JEl+GtOT9TKsh04zCHAbavnQ2USldA==}@@ -8304,6 +8355,19 @@ packages:react: 18.2.0dev: false+ resolution: {integrity: sha512-jILj7F9o+6NHzrJ1GqZIxfJgskvGmKeJ05FNhPvgiCpvMZFmFneKEkukywHcULDO2lqITm+zcEkLSq42mX0FbA==}+ peerDependencies:+ react: '>=16.6.0'+ dependencies:+ deepmerge: 4.3.1+ load-script: 1.0.0+ memoize-one: 5.2.1+ prop-types: 15.8.1+ react: 18.2.0+ react-fast-compare: 3.2.2+ dev: false+resolution: {integrity: sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==}engines: {node: '>=0.10.0'}@@ -9468,6 +9532,10 @@ packages:punycode: 2.3.1dev: true+ resolution: {integrity: sha512-mtN6xk+Nac+oyJ/PrI7tzfmomRVNFIWKUbG8jdYFt52hxbiReFAXIjYskvu64/dvuW71IcB7lV8l0HvZMac6Jg==}+ dev: false+resolution: {integrity: sha512-hzSUW2q06EqL1gKM/a+obYHLIO6ct2hwPuviqTTOcfFVc61UbfJ2Q32+uGL/HCPxKqrdGB5QUwIe7UqlDgwsOQ==}dependencies: