### Install and Run Development Server Source: https://github.com/doedja/scenecut/blob/main/README.md Install dependencies and start the development server for the browser application. The `build:core:wasm` command requires the emscripten SDK. ```bash bun install bun run build:core:wasm # needs emscripten SDK bun run dev:app ``` -------------------------------- ### Install Dependencies and Build Project Source: https://github.com/doedja/scenecut/blob/main/README.md Installs project dependencies using Bun and then builds the core components (WASM, TS), Node.js CLI, web client, and application. ```bash bun install # one shot: builds core (WASM + TS), node, web, app bun run build ``` -------------------------------- ### Install @doedja/scenecut-web Source: https://github.com/doedja/scenecut/blob/main/packages/web/README.md Install the package using npm or yarn. ```bash npm install @doedja/scenecut-web ``` -------------------------------- ### Install @doedja/scenecut CLI Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Install the scenecut command-line tool globally using npm. ```bash npm install -g @doedja/scenecut ``` -------------------------------- ### Quick Start with Vite Source: https://github.com/doedja/scenecut/blob/main/packages/web/README.md Initialize WASM factory and motion pool, then use detectSceneChanges for video analysis. Ensure WASM files are served as static assets. ```typescript import { detectSceneChanges, createWebWasmFactory, createWebMotionPool } from '@doedja/scenecut-web'; // Serve these from your public folder (copy from node_modules/@doedja/scenecut-core/dist/) const wasmBase = new URL('/wasm/', location.href).href; const glueUrl = `${wasmBase}detection.wasm.js`; const wasmUrl = `${wasmBase}detection.wasm`; const wasmFactory = createWebWasmFactory({ glueUrl, wasmUrl }); const pool = createWebMotionPool({ glueUrl, wasmUrl, createWorker: () => new Worker( new URL('./my-motion-worker.ts', import.meta.url), { type: 'module' } ) }); async function detect(file: File) { const result = await detectSceneChanges(file, { wasmFactory, pool, sensitivity: 'low', onProgress: (p) => console.log(`${p.percent}%`), onScene: (s) => console.log(`cut @ ${s.timecode}`) }); return result.scenes; } ``` -------------------------------- ### scenecut CLI Usage Example Source: https://github.com/doedja/scenecut/blob/main/apps/web/index.html Demonstrates how to use the scenecut command-line interface to detect scene changes in a video file and specify the output format. ```shell scenecut video.mkv --format edl ``` -------------------------------- ### Cancellation Example Source: https://github.com/doedja/scenecut/blob/main/packages/web/README.md Demonstrates how to abort a scene detection process using AbortController and passing its signal to the detectSceneChanges function. ```typescript const ctrl = new AbortController(); const result = await detectSceneChanges(file, { wasmFactory, pool, signal: ctrl.signal }); // later: ctrl.abort(); ``` -------------------------------- ### Build Core WASM Module Source: https://github.com/doedja/scenecut/blob/main/README.md Builds the core WebAssembly module. Requires the Emscripten SDK to be installed. ```bash bun run build:core:wasm ``` -------------------------------- ### Motion Worker Setup Source: https://github.com/doedja/scenecut/blob/main/packages/web/README.md Configure the motion worker script to handle WASM initialization and motion detection tasks. This script is instantiated by the bundler for each worker. ```typescript import { installMotionHandler } from '@doedja/scenecut-core'; import type { WorkerMessagePort } from '@doedja/scenecut-core'; import { createWebWasmFactory } from '@doedja/scenecut-web/wasm-factory'; installMotionHandler(self as unknown as WorkerMessagePort, (glueUrl, wasmUrl) => createWebWasmFactory({ glueUrl, wasmUrl }) ); ``` -------------------------------- ### Browser Library Usage for Scene Detection Source: https://github.com/doedja/scenecut/blob/main/README.md Integrate the SceneCut browser library to detect scene changes in videos. This example shows how to set up the WebAssembly factory and motion pool, and then call the `detectSceneChanges` function. ```javascript import { detectSceneChanges, createWebWasmFactory, createWebMotionPool } from '@doedja/scenecut-web'; const wasmFactory = createWebWasmFactory({ glueUrl: new URL('./wasm/detection.wasm.js', location.href).href, wasmUrl: new URL('./wasm/detection.wasm', location.href).href }); const pool = createWebMotionPool({ glueUrl: '...', wasmUrl: '...', createWorker: () => new Worker( new URL('./motion-worker.ts', import.meta.url), { type: 'module' } ) }); const result = await detectSceneChanges(file, { wasmFactory, pool, sensitivity: 'low', onScene: (s) => console.log(s) }); ``` -------------------------------- ### Build Application Source: https://github.com/doedja/scenecut/blob/main/README.md Builds the main application, likely encompassing all necessary components. ```bash bun run build:app ``` -------------------------------- ### Build Web Client Source: https://github.com/doedja/scenecut/blob/main/README.md Builds the web client components for browser-based usage. ```bash bun run build:web ``` -------------------------------- ### Build Node.js CLI Source: https://github.com/doedja/scenecut/blob/main/README.md Builds the Node.js command-line interface for the project. ```bash bun run build:node ``` -------------------------------- ### Generate scene thumbnails Source: https://github.com/doedja/scenecut/blob/main/README.md Create thumbnail images for detected scenes and save them into a specified directory. ```bash scenecut video.mp4 --thumbnails ./thumbs ``` -------------------------------- ### Adjust sensitivity and enable verbose output Source: https://github.com/doedja/scenecut/blob/main/README.md Run scenecut with higher sensitivity to detect more subtle transitions and enable verbose mode to see per-scene details. ```bash scenecut anime.mkv -s high -v ``` -------------------------------- ### Import WASM Binary (Vite) Source: https://github.com/doedja/scenecut/blob/main/packages/core/README.md Import the raw WASM binary file using Vite's URL import syntax. This is a shortcut for importing the compiled WASM module. ```typescript import wasmUrl from '@doedja/scenecut-core/wasm-binary?url'; ``` -------------------------------- ### Export scene changes to FCPXML format Source: https://github.com/doedja/scenecut/blob/main/README.md Generate a Final Cut Pro X timeline with scene markers by exporting scene changes using the fcpxml format. ```bash scenecut video.mkv -f fcpxml ``` -------------------------------- ### Import WASM Glue Code (Vite) Source: https://github.com/doedja/scenecut/blob/main/packages/core/README.md Import the ES-module glue code for the WASM binary using Vite's URL import syntax. This is a shortcut for importing the compiled WASM module. ```typescript import glueUrl from '@doedja/scenecut-core/wasm?url'; // via Vite ``` -------------------------------- ### Build Core TypeScript Module Source: https://github.com/doedja/scenecut/blob/main/README.md Builds the core TypeScript components of the project. ```bash bun run build:core:ts ``` -------------------------------- ### Default Scene Cut Detection Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Run scenecut with default settings to detect scene changes and output Aegisub keyframes. ```bash scenecut input.mkv ``` -------------------------------- ### Export scene changes to JSON format Source: https://github.com/doedja/scenecut/blob/main/README.md Save the detailed scene change detection results, including metadata and statistics, in a JSON file. ```bash scenecut video.mp4 -f json -o scenes.json ``` -------------------------------- ### Advanced Scene Cut Detection Options Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Configure scene cut detection with higher sensitivity and verbosity, or set a timeout to abort processing. ```bash scenecut anime.mkv -s high -v # higher sensitivity, verbose ``` ```bash scenecut long.mkv -t 120 # abort after 2 minutes ``` ```bash scenecut video.mp4 --thumbnails ./thumbs ``` -------------------------------- ### Export scene changes to CSV format Source: https://github.com/doedja/scenecut/blob/main/README.md Generate a generic CSV file containing scene change information such as frame number, timestamp, timecode, confidence, and duration. ```bash scenecut video.mp4 -f csv -o scenes.csv ``` -------------------------------- ### Low-level Source Imports Source: https://github.com/doedja/scenecut/blob/main/packages/web/README.md Importing specific frame source classes for direct control over video frame extraction. These classes implement the FrameSource interface from @doedja/scenecut-core. ```typescript import { WebCodecsSource, // MP4 / MOV MkvSource, // MKV / WebM VideoElementSource // fallback } from '@doedja/scenecut-web'; ``` -------------------------------- ### Parallel Scene Cut Detection with Worker Pool Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Utilize a worker pool for parallel analysis to speed up scene detection. The number of workers can be specified or set to auto. ```bash scenecut video.mkv -w true # auto (cpus - 1, capped at 8) ``` ```bash scenecut video.mkv -w 4 # pin to 4 workers ``` -------------------------------- ### Export scene changes to timecode format Source: https://github.com/doedja/scenecut/blob/main/README.md Output scene changes as a plain list of timecodes in HH:MM:SS.mmm format, one per line. ```bash scenecut video.mp4 -f timecode ``` -------------------------------- ### Scene Cut Detection for Technical Formats Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Output scene cut information in technical formats like JSON, CSV, or timecode. ```bash scenecut video.mp4 -f json -o scenes.json ``` ```bash scenecut video.mp4 -f csv ``` ```bash scenecut video.mp4 -f timecode ``` -------------------------------- ### Export Scene Detection Results Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Utilize exporter functions like `formatEdl`, `formatFcpxml`, and `formatPremiereMarkers` to convert the detection results into standard editing formats. ```javascript const { formatEdl, formatFcpxml, formatPremiereMarkers } = require('@doedja/scenecut'); const edl = formatEdl(result, 'my-clip'); ``` -------------------------------- ### Set processing timeout Source: https://github.com/doedja/scenecut/blob/main/README.md Limit the processing time for a video file by specifying a timeout in seconds. The process will abort if it exceeds this duration. ```bash scenecut long-movie.mkv -t 120 ``` -------------------------------- ### Scene Cut Detection for NLE Exports Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Generate scene cut data in formats compatible with Non-Linear Editors (NLEs) like Premiere, Resolve, and Final Cut Pro X. ```bash scenecut video.mkv -f edl # CMX3600 — Premiere, Resolve, Avid ``` ```bash scenecut video.mkv -f fcpxml # Final Cut Pro X timeline with markers ``` ```bash scenecut video.mkv -f premiere # Premiere Pro Import Markers CSV ``` -------------------------------- ### Export scene changes to EDL format Source: https://github.com/doedja/scenecut/blob/main/README.md Use scenecut to detect scene changes and export them in CMX3600 EDL format, compatible with professional NLE software like Premiere, Resolve, and Avid. ```bash scenecut video.mkv -f edl ``` -------------------------------- ### Detect Scene Changes in Node.js Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Use the `detectSceneChanges` function to analyze a video file and identify scene transitions. Configure sensitivity, enable workers for performance, and provide callbacks for progress and scene detection events. ```javascript const { detectSceneChanges } = require('@doedja/scenecut'); const result = await detectSceneChanges('input.mp4', { sensitivity: 'low', workers: true, onProgress: (p) => console.log(`${p.percent}% — ${p.fps?.toFixed(1)} fps`), onScene: (s) => console.log(`cut @ ${s.timecode} conf=${s.confidence?.toFixed(2)}`) }); console.log(`${result.scenes.length} scenes`); ``` -------------------------------- ### Extract Scene Images Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Use the `extractSceneImages` function to generate thumbnail images for detected scenes. Specify output directory, image format, and quality settings. ```javascript const { extractSceneImages } = require('@doedja/scenecut'); await extractSceneImages('input.mp4', { sensitivity: 'low' }, { outputDir: './thumbs', format: 'jpg', quality: 85 } ); ``` -------------------------------- ### Export scene changes for Premiere Pro Source: https://github.com/doedja/scenecut/blob/main/README.md Export scene changes in a CSV format suitable for importing as markers in Adobe Premiere Pro using the 'File → Import Markers' option. ```bash scenecut video.mkv -f premiere ``` -------------------------------- ### Cancel Scene Detection with AbortSignal Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Implement cancellation for long-running scene detection tasks by passing an `AbortSignal` to the `detectSceneChanges` function. This allows for graceful termination of the process. ```javascript const ctrl = new AbortController(); setTimeout(() => ctrl.abort(), 60_000); await detectSceneChanges('input.mp4', { signal: ctrl.signal }); ``` -------------------------------- ### Configure parallel worker pool Source: https://github.com/doedja/scenecut/blob/main/README.md Control the number of parallel workers used for scene detection. Set to 'true' for automatic detection (CPU cores - 1, capped at 8), a specific number, or 'off' to disable. ```bash scenecut video.mkv -w true ``` ```bash scenecut video.mkv -w 4 ``` -------------------------------- ### Exporter Imports Source: https://github.com/doedja/scenecut/blob/main/packages/web/README.md Importing various formatting functions to export detection results into different standard formats like EDL, FCPXML, and Premiere markers. These are re-exported from the core library. ```typescript import { formatEdl, formatFcpxml, formatPremiereMarkers } from '@doedja/scenecut-web'; const edl = formatEdl(result, 'my-clip'); ``` -------------------------------- ### Scene Detection Result Interface Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Describes the structure of the `DetectionResult` object returned by `detectSceneChanges`, including details about detected scenes, video metadata, and processing statistics. ```typescript interface DetectionResult { scenes: Array<{ frameNumber: number; timestamp: number; // seconds timecode: string; // HH:MM:SS.mmm confidence: number; // 0–1 (sigmoid-calibrated) duration: number; frameCount: number; }>; metadata: { totalFrames, duration, fps, resolution, codec?, pixelFormat?, bitrate? }; stats: { processingTime, framesPerSecond }; } ``` -------------------------------- ### Scene Detection Result Interface Source: https://github.com/doedja/scenecut/blob/main/README.md Describes the structure of the `DetectionResult` object returned by `detectSceneChanges`, including details about detected scenes and video metadata. ```typescript interface DetectionResult { scenes: Array<{ frameNumber: number; timestamp: number; // seconds timecode: string; // HH:MM:SS.mmm confidence: number; // 0–1 duration: number; frameCount: number; }>; metadata: { totalFrames, duration, fps, resolution, codec?, pixelFormat?, bitrate? }; stats: { processingTime, framesPerSecond }; } ``` -------------------------------- ### Node Detection Options Interface Source: https://github.com/doedja/scenecut/blob/main/packages/node/README.md Defines the available options for the `detectSceneChanges` function, including sensitivity, search range, worker configuration, and event callbacks. ```typescript interface NodeDetectionOptions { sensitivity?: 'low' | 'medium' | 'high'; // default: 'low' searchRange?: 'auto' | 'small' | 'medium' | 'large'; // default: 'auto' workers?: number | boolean; // default: off onProgress?: (p: Progress) => void; onScene?: (s: SceneInfo) => void; signal?: AbortSignal; } ``` -------------------------------- ### Reveal Body on Load Source: https://github.com/doedja/scenecut/blob/main/apps/web/index.html This JavaScript reveals the body element once the CSS and fonts have been painted at least once, ensuring a smooth visual experience. ```javascript document.addEventListener('DOMContentLoaded', () => { requestAnimationFrame(() => document.body.classList.add('is-ready')); }); ``` -------------------------------- ### Critical CSS for scenecut Source: https://github.com/doedja/scenecut/blob/main/apps/web/index.html This CSS is critical for preventing Flash of Unstyled Content (FOUC) while the main stylesheet loads. It ensures a smooth transition by matching the main stylesheet's variables. ```css html, body { margin: 0; background: #0a0a0b; color: #e8e6df; font-family: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; color-scheme: dark; } [hidden] { display: none !important; } body { opacity: 0; transition: opacity 120ms ease-out; } body.is-ready { opacity: 1; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.