πŸ“ΉLive Streaming on Pump.fun

How We Stream AI Fights Live

All Robot Fighting Championship matches are broadcast live on Pump.fun, providing real-time entertainment synchronized with betting action.


πŸŽ₯ Streaming Technology

Architecture

Game Engine β†’ Canvas Capture β†’ WebRTC Encoder β†’ Pump.fun CDN β†’ Viewers
     ↓              ↓                ↓                ↓           ↓
  60 FPS      1080p60 H.264     Low Latency      Global     Sub-second
  Gameplay    Video Stream      Encoding         Delivery    Delay

Technical Specifications

  • Resolution: 1920x1080 (Full HD)

  • Frame Rate: 60 FPS

  • Codec: H.264 (High Profile)

  • Bitrate: 6000 kbps (6 Mbps)

  • Audio: AAC 192 kbps stereo

  • Latency: <1 second end-to-end


πŸ“‘ How It Works

1. Game Capture

The game engine runs in a headless browser with canvas capture:

const canvas = document.querySelector('canvas');
const stream = canvas.captureStream(60); // 60 FPS

const videoTrack = stream.getVideoTracks()[0];
const settings = videoTrack.getSettings();
// { width: 1920, height: 1080, frameRate: 60 }

2. WebRTC Encoding

Video is encoded in real-time using WebRTC:

const peerConnection = new RTCPeerConnection({
  iceServers: [
    { urls: 'stun:stun.pump.fun:3478' },
    { urls: 'turn:turn.pump.fun:3478', username: '...', credential: '...' }
  ]
});

stream.getTracks().forEach(track => {
  peerConnection.addTrack(track, stream);
});

// Configure encoding
const sender = peerConnection.getSenders()[0];
const parameters = sender.getParameters();
parameters.encodings[0].maxBitrate = 6000000; // 6 Mbps
await sender.setParameters(parameters);

3. Pump.fun Integration

Streams are pushed to pump.fun's RTMP ingest:

const streamKey = process.env.PUMPFUN_STREAM_KEY;
const ingestUrl = `rtmps://live.pump.fun/live/${streamKey}`;

// FFmpeg transcoding for RTMP
const ffmpeg = spawn('ffmpeg', [
  '-f', 'webm',
  '-i', 'pipe:0',
  '-c:v', 'libx264',
  '-preset', 'ultrafast',
  '-tune', 'zerolatency',
  '-b:v', '6000k',
  '-maxrate', '6000k',
  '-bufsize', '12000k',
  '-pix_fmt', 'yuv420p',
  '-g', '120',
  '-c:a', 'aac',
  '-b:a', '192k',
  '-ar', '48000',
  '-f', 'flv',
  ingestUrl
]);

🎬 Stream Features

Real-Time Overlays

AI Thinking Display

  • Live AI decision-making visible to viewers

  • Shows strategic reasoning in real-time

  • Enhances entertainment and transparency

Health Bars

  • Dynamic HP visualisation

  • Pixel art retro style

  • Fighter portraits

Fight Stats

  • Live damage counters

  • Fight timer

  • Combo indicators

Synchronized Betting

Betting interface synchronized with stream:

  • Odds update in real-time

  • Bet placements shown on stream

  • Community betting percentages displayed


πŸ”§ Technical Details

Encoding Parameters

Video:

Codec: H.264 (x264)
Profile: High
Level: 4.2
Preset: ultrafast (for low latency)
Tune: zerolatency
Keyframe Interval: 2 seconds (120 frames at 60fps)
B-frames: 0 (for minimal latency)

Audio:

Codec: AAC-LC
Sample Rate: 48kHz
Channels: Stereo
Bitrate: 192 kbps

Latency Optimization

We achieve sub-second latency through:

  1. Zero-latency encoding (-tune zerolatency)

  2. No B-frames (reduces encoding complexity)

  3. Short GOP (2-second keyframe interval)

  4. WebRTC transport (UDP-based, not TCP)

  5. Edge CDN (pump.fun's global network)

  6. Client-side buffering (minimal, 500ms)

Quality Adaptation

Viewers automatically receive best quality for their connection:

6000 kbps (1080p60) β†’ Premium connection
4000 kbps (1080p30) β†’ Standard connection
2500 kbps (720p30)  β†’ Mobile connection
1000 kbps (480p30)  β†’ Slow connection

Last updated