You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
compile: every segment of the same source re-hashes the full media file twice (hundreds of GB read for long videos) #155
compile (and add-video / add-audio) calls copyAssetDeduped() once per segment. From the second segment of the same source on, assets/<kind>/<basename> already exists, so planAssetCopy() calls sameContent(src, dest). That function SHA-1-hashes both files completely every time (dist/factory.js, fileSha1 / sameContent, introduced with the collision fix in #38).
For a talking-head video that is cut into many segments, the cost grows with segments × file size:
63 segments from two camera files (3.0 GB + 2.7 GB): about 33 × 6 GB + 28 × 5.4 GB ≈ 350 GB read, ~20 minutes per compile on an NVMe SSD (~300 MB/s sustained, CPU mostly idle). The process was observed at 145 GB read / 2.9 GB written after 8 minutes.
Smaller cut lists finish fast only while the file fits in the OS page cache.
A spec with 40 one-second items on one video track, all "path": "video.mp4" with different sourceStart, then capcut compile spec.json --out draft --template <empty template>.
time
bytes read by node
0.29.0 as published
13.6 s
20.8 GB
with the cache below
1.0 s
0.8 GB
The resulting draft_content.json is identical apart from ids and timestamps. 0.30.0 has the same fileSha1 / sameContent / planAssetCopy code.
Suggested fix
Memoise the comparison per process, keyed by both paths plus size and mtime, so a file that changes is still hashed again:
Possible further steps: remember the source → destination mapping of files copied by the same run (no hash at all after the copy), or cache fileSha1(src) separately so the collision branch does not hash the source again.
Activity