YouTube Reference (opt-in)
Pull a clip into ComfyUI input, with a verifiable receipt
- ui_widget
- input_reference
- video_id
- receipt
Video-to-video and audio-reference workflows all start with the same chore: you want to use a YouTube clip as a reference frame or audio source, and the official way to get it is... downloading it with a separate tool, naming it sensibly, dropping it in the right folder, and hoping the path lines up. LF_YouTubeReference automates that whole loop from inside ComfyUI: paste a URL, it downloads the clip, caches it under your input folder, and hands you a portable path plus a JSON receipt proving exactly what it downloaded. It's the reference-ingest node from the lf-nodes IO family.
The name has "(opt-in)" in it for a reason, and you need to know what you're opting into before it'll run at all.
How it works
Give it a YouTube URL and a media kind - audio_m4a (default) or video_mp4 - and it downloads the video, then caches it at ComfyUI/input/lf-workflow-runner/youtube/<video_id>/<media_kind>/. The engineering here is unusually careful for an IO node. It downloads YouTube's fixed progressive MP4 format (format 18) via yt-dlp - deliberately a single, credential-free file, because the node accepts no logins and sidesteps formats that demand a PO token. For the audio profile it then remuxes the AAC audio into an M4A container losslessly with PyAV - no transcoding, no shell calls, no quality loss. It verifies the container structure afterwards, refuses symlinks and anything that escapes the input directory, and locks cache publication across processes so two concurrent runs can't corrupt a cached entry.
The output receipt is where it gets fancy. receipt is a JSON object containing the video id, media kind, byte count, relative path, a SHA-256 of the media file, and a receipt_sha256 over the whole thing - so downstream nodes can verify the reference hasn't been tampered with or silently swapped. Cached entries are re-verified on every run against that hash.
The inputs that matter
- youtube_url (STRING) - the URL. Parsed strictly; a malformed URL fails rather than being half-guessed.
- media_kind (audio_m4a / video_mp4) - what you're taking. Audio is the default because for most reference tasks (music, dialogue, ambience) the audio is the point and it's a fraction of the size.
Outputs are input_reference (the portable path below ComfyUI input - this is what you wire to a load-image or load-audio node), video_id (the canonical 11-character id), and receipt (the JSON verification record).
Install and opt-in
It ships with lf-nodes, but two things are required before it works:
- Extra dependencies that are never auto-installed. Run:
That installscd ComfyUI/custom_nodes/lf-nodes pip install -r requirements-youtube-ingest.txtavandyt-dlp- the pack deliberately leaves them out of the base requirements. - Set
LF_YOUTUBE_INGEST_ENABLED=1in the environment before starting ComfyUI. Without it the node raises "YouTube ingress is disabled" on every run. The flag exists so the node can't quietly fetch the internet in the background of a workflow you didn't expect to phone home.
Install the pack itself the usual way:
- ComfyUI Manager: search "LF Nodes", install, restart.
- Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/lucafoscili/lf-nodes.git, restart.
Common issues
- "YouTube ingress is disabled" - you skipped the env var. Set
LF_YOUTUBE_INGEST_ENABLED=1and restart. This is the #1 thing that trips people up, and it's on purpose. - "yt-dlp is required" / "PyAV is required" - you skipped the extra requirements file.
pip install -r requirements-youtube-ingest.txtfrom the pack root fixes both. - Download fails on a video that clearly exists. The node deliberately supports only public, credential-free progressive MP4. Age-restricted, members-only, or heavily region-locked videos are out of scope by design - it won't pretend otherwise.
- The receipt is your friend. If a downstream check complains about the reference, the receipt's SHA-256 tells you whether the file on disk actually matches what was downloaded. Trust the hash, not your memory of the file.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| youtube_url | STRING | — | |
| media_kind | COMBO | audio_m4a | 2 options: audio_m4a, video_mp4 |
| ui_widgetopt | LF_CODE | ## YouTube Reference Enable external intake, then run to populate the verified cache receipt. | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| input_reference | STRING | Portable path below ComfyUI input. |
| video_id | STRING | The canonical eleven-character YouTube video id. |
| receipt | JSON | Cache receipt containing the verified media SHA-256. |