YouTube sources
A YouTube watch URL opens a player, not a video file. Use the original MP4 or WebM source when you want to render it as ASCII.
Use your source video
Upload your original file in the playground, or host it with your app and pass its URL to the engine. A remote media server must allow CORS access.
import { asciifyVideo } from 'asciify-engine';
const canvas = document.querySelector<HTMLCanvasElement>('#ascii')!;
const stop = await asciifyVideo('/media/hero.mp4', canvas, {
fontSize: 7,
fps: 30,
options: { colorMode: 'accent', accentColor: '#e8b900' },
});
// When the view unmounts:
// stop();Why a YouTube embed cannot be sampled
The embedded player runs in a different origin. Browser security prevents your page from reading its video pixels into a canvas. Passing a watch, Shorts, or embed URL to asciifyVideo does not bypass that restriction.
Browser capture in your own integration
For a custom desktop capture workflow, request a display stream with getDisplayMedia from a user-initiated button. The user chooses what to share. Feed the resulting MediaStream into a video element, sample its frames, and stop every stream track when sharing ends or the view unmounts. Feature-detect capture support and offer a file-upload fallback. Capture requires a secure context and explicit browser permission each time. See the screen capture API documentation.
Use footage you own or have permission to reuse. For an embedded player without ASCII conversion, use YouTube’s iframe player.