Skip to content
shuttiePublic

About

SlopTV: an infinite AI slop generator from youtube comments

Resources

Stars

43 stars

Watchers

0 watching

Forks

Repository files navigation

sloptv

An infinite AI slop broadcast. Viewers type into a YouTube live chat, an LLM rewrites each comment into a video-model prompt, two local GPUs render ~15-second clips, and a streamer plays the growing clip pool back to the same broadcast over RTMP. The loop closes: people watch what earlier comments produced and comment on that.

YouTube live chat ──► generate.py ──► LLM ──► GPU workers (ComfyUI + MiniMax H3)
                                                    │
                                                    ▼
                                             pool/*.mp4
                                                    │
stream.py ◄─────────────────────────────────────────┘
    └──► decode ─► upscale to 1080x1920 ─► x264/AAC ─► RTMP ─► YouTube

Architecture in one paragraph

Two services, one directory between them. generate.py writes finished clips into pool/; stream.py scans that directory and plays them out. The pool is the only contract, so either side can crash and restart without the other noticing. No database, no message broker, no RPC.

generate.py: chat to clips

Chat ingest. YouTube's gRPC streamList endpoint pushes chat messages over a persistent connection. The alternative, REST polling, burns the daily API quota in hours. A small state machine handles reconnects, chat-end, rate-limit backoff, and waiting for the next broadcast.

The LLM stage. Each comment goes through gpt-5.6-luna (via pydantic-ai) with a system prompt (prompt/script.md) doing three jobs at once:

  • Convert a three-word comment into the structured prompt format MiniMax H3 was trained on: labeled shots with timestamps, dialogue tags, soundscape.
  • Apply dramaturgy so 15 seconds have a hook, a build, and a payoff.
  • Moderate. Steering comes before rejection: a franchise character becomes a renamed archetype, a named song becomes a described original score. Only comments whose entire point is a YouTube policy violation get dropped.

One lesson from prompt testing (RFC 0002): a small model parrots any concrete example you put in its instructions, so the prompt is all rules and placeholders, no worked examples.

Never idle. New comments are served first-come-first-served. When none are waiting, the LLM gets a placeholder meaning "invent the whole concept yourself", so at 3 AM with zero viewers the GPUs keep producing original slop.

Rendering. One worker process per GPU (two RTX 5090s), each embedding a ComfyUI executor directly — no ComfyUI server, no HTTP; jobs and errors are plain Python. Clips render at 352x608 portrait, which sounds like a compromise but isn't: practitioner testing puts H3's best prompt adherence in the 352p–416p band, and higher resolutions start ignoring camera and placement instructions. Workers render into a staging directory and rename() into the pool, so the streamer never sees a half-written file.

stream.py: clips to RTMP

The whole design serves one goal: no gaps. Dead air comes from tearing down an encoder or an RTMP connection between clips, so there is exactly one of each, opened at startup and never closed.

  • One FLV container and one x264+AAC encoder pair, everything through PyAV, in-process.
  • A decoder thread reads the next clip whole into RAM and upscales it to 1080x1920 while the current one plays.
  • The encoder stamps frames against its own synthesized clock, never reset between clips. Audio is padded or trimmed to each clip's exact video duration, so A/V drift cannot accumulate over a multi-week run.
  • If the RTMP connection drops, the container reopens and the clock keeps counting; YouTube sees the same broadcast resuming.

Clip selection mirrors the generate side: files not yet played this session play in timestamp order, then uniform random from the whole pool. Fresh slop first, reruns to fill.

Running it

Python 3.13, uv-driven, one TOML config per service:

uv run python -m sloptv.auth              # one-time OAuth consent flow → token.json
uv run python -m sloptv.generate          # reads generate.toml
uv run python -m sloptv.stream            # reads stream.toml
  • generate.toml picks the chat source (youtube, or static with a canned message for offline testing), the GPUs, and the video knobs.
  • stream.toml needs no stream key: the ingest URL and key are resolved through the YouTube API at startup, so token.json is the only credential on disk.
  • SLOPTV_FAKE_WORKER=1 replaces the render with a 2-second sleep, for testing the pipeline without touching a GPU.
  • ComfyUI is vendored as a pinned submodule; H3 model weights (~66 GB) are shared from an existing ComfyUI install via extra_model_paths.yaml.

More detail

The rfcs/ directory records the design and what changed as reality pushed back:

RFC Topic
0001 Overall design
0002 The comment-to-prompt system prompt and moderation policy
0003 YouTube chat ingest over gRPC
0004 The generation pipeline
0005 Stream playout, and wiring the YouTube source

Later RFCs supersede earlier ones in places; the code wins where they disagree.

About

SlopTV: an infinite AI slop generator from youtube comments

Resources

Stars

43 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages