Skip to main content

Command Palette

Search for a command to run...

Infinite Piano Stream: How I Built a Low-Cost, 100% AI-Generated YouTube Livestream

Published
5 min read
Infinite Piano Stream: How I Built a Low-Cost, 100% AI-Generated YouTube Livestream

TL;DR
Generate endless piano music using AI tools. Pair it with simple looping visuals. Pipe everything through FFmpeg into YouTube Live. Run it on a cheap VM (even 2-core, 4GB works). Minimal latency, near-zero manual intervention.
Outcome: A "set-and-forget" infinite livestream with very low cost and effort.
Github Repo: https://github.com/pgAdmin/stream-blog-assets

I’ve been tinkering with this idea for a while now, and I finally got around to turning it into something that actually works, ie, a chill, never-ending musical livestream on YouTube that’s 100% AI-generated. No me sitting there playing for hours, no expensive continuous video generation… just smart hacks to keep costs low and make it look & sound pretty convincing.

It had to be affordable, since generating full-motion video frame-by-frame gets extremely expensive at 24–25 fps.

The Core Insight: Separate Video and Audio, Then Sync Them

Video generation (especially realistic human motion) is computationally heavy and costly on most AI platforms. Audio generation, on the other hand, is much cheaper (and in some cases free).

So the plan became:

  • Generate short, video clips with the same start and end frame (silent, no audio).

  • Generate long instrumental tracks (of 5-7 minutes each).

  • Stitch and stream them together using FFmpeg for a seamless, endless broadcast.

Choosing the Right Instrument and Camera Angle

Early experiments with other instruments failed because sync errors become obvious:

  • Tabla or drums: Distinct percussive hits make any mismatch glaring.

  • Saxophone (even jazz): Finger positions and bell movement clearly shift for different notes. Viewers will spot the inconsistencies pretty quickly.

  • Piano, from a side view: This became the winner. From the side, you can't easily see exactly which keys are being pressed. Hand and arm movements are repetitive and fluid, so small AI imperfections blend in. People focus more on the overall ambiance than precise key accuracy.

The side profile hides potential "AI artifacts" in finger-to-key alignment while keeping the scene elegant and hypnotic.

Making Video Loop Without Jumps: The Key Trick

Instead of generating one long continuous video (impossibly expensive), I created many short clips (5–10 seconds each) with a deliberate constraint:

  • Every clip starts and ends on the exact same frame (same hand position, posture, lighting, etc.).

When the start frame = end frame, you can:

  • Loop a single clip endlessly with no visible jump.

  • Randomly rearrange and concatenate multiple clips for variety—yet the transitions feel natural because they return to the same "rest" pose.

I generated about 20 such short clips using Kling 2.5 / 2.6 (which support start/end frame control nicely). This gave enough variation so the stream doesn't feel too repetitive over time.

Audio: Long, Free, Piano-Only Tracks

For the soundtrack I used ACE-Step 1.5, a powerful open-source/local AI music generation model. It's impressive: high quality, fast, and runs on consumer hardware with low VRAM.

  • Prompted it for generic piano instrumentals (solo piano, ambient/chill/classical/jazz-infused styles).

  • Generated 10–15 tracks, each 5-7 minutes long.

  • Total audio library: around 50-80 minutes of royalty-free piano music (and you can generate more anytime, since it's free and pretty fast).

This audio library provides plenty of content before any noticeable repeat.

Putting It All Together with FFmpeg

With video clips and audio ready, FFmpeg handles the heavy lifting for streaming (e.g., to YouTube RTMP).

  1. Prepare a text file (e.g., videos.txt) listing the short clips in a desired random/repeating order:

    file 'clip1.mp4'
    file 'clip5.mp4'
    file 'clip12.mp4'
    ... (repeat/rearrange as needed)
    

    Because each clip loops seamlessly back to itself, concatenating them in any order works without cuts.

  2. For audio, either:

    • Concatenate the longer tracks into one big file, or

    • Use a concat list for audio too (audios.txt).

  3. Example FFmpeg command for a looping livestream:

    A basic version for infinite stream:

    ffmpeg \
      -stream_loop -1 -re -f concat -safe 0 -i videos.txt \
      -stream_loop -1 -re -i long_piano_audio.mp3 \
      -c:v libx264 -b:v 2M -preset veryfast -pix_fmt yuv420p \
      -c:a aac -b:a 128k \
      -shortest -f flv rtmp://a.rtmp.youtube.com/live2/YOUR_STREAM_KEY
    
    • -stream_loop -1: Loops inputs forever.

    • -re: Reads at realtime speed (critical for live).

    • -f concat -safe 0 -i videos.txt: Stitches video clips.

    • Map video from first input, audio from second if needed.

    • Adjust bitrate/quality for YouTube (e.g., 2–4 Mbps video).

    Variations:

    • Randomize clip order via script that regenerates videos.txt periodically.

    • Use -shortest or trim to match segments if needed.

This setup creates a smooth, endless piano performance stream with realistic visuals and pleasant audio -> all AI-generated.

Here is Barbara Lee's recorded stream:

https://www.youtube.com/watch?v=PvBeGn5CE80

Why This Works So Well (and Final Thoughts)

  • Cost-effective: Only ~20 short video generations (Kling credits) + free/local audio via ACE-Step.

  • Convincing: Side-view piano hides flaws; seamless loops avoid jump cuts.

  • Scalable: Add more clips/tracks anytime; rearrange for "fresh" feel.

  • Relaxing vibe: Perfect for study, sleep, background, or "lofi piano" style channels.

If you're into AI media creation or want passive YouTube content, this technique is gold. The separation of concerns (video loops vs. long audio) + clever frame matching unlocks long-form streaming without breaking the bank.

Github Repo: https://github.com/pgAdmin/stream-blog-assets

Have you tried something similar? What instrument or angle would you pick next? Let me know in the comments, I might iterate on this!

Happy streaming! 🎹