Bedrud includes Python-based bot agents that can join meeting rooms and stream media content. These are useful for background music, radio streams, or sharing video content.

Available Agents

AgentDescriptionMedia Type
music_agentPlays audio files into a roomAudio (PCM)
radio_agentStreams internet radio stationsAudio (PCM via FFmpeg)
video_stream_agentShares video content (HLS, MP4)Video + Audio

How Agents Work

All agents follow the same connection pattern:

flowchart TD
    A[1. Parse meeting URL] --> B[2. Guest login<br/>POST /api/auth/guest-login]
    B --> C[3. Join room<br/>POST /api/room/join]
    C --> D[4. Connect to LiveKit<br/>WebSocket + Token]
    D --> E[5. Publish tracks<br/>Stream audio/video frames]
flowchart LR
    subgraph Media["Media Source"]
        MS["File / URL<br/>(MP3, radio, HLS, MP4)"]
    end
    subgraph Agent["Python Agent"]
        FF[FFmpeg Decoder]
        PA[Agent Logic]
    end
    subgraph Server["Bedrud Server"]
        GL[Guest Login<br/>/api/auth/guest-login]
        JR[Join Room<br/>/api/room/join]
    end
    subgraph LK["LiveKit SFU<br/>(WebRTC)"]
        WS[WebSocket Connect]
        PT[Publish Tracks]
    end
    MS --> FF --> PA
    PA --> GL
    GL --> JR
    JR --> WS
    WS --> PT

Music Agent

Plays audio files (MP3, WAV, etc.) into a meeting room.

Setup

cd agents/music_agent
pip install -r requirements.txt

Dependencies: httpx, livekit, pydub

Usage

python agent.py "https://meet.example.com/m/room-name"

How It Works

  1. Decodes audio files using pydub
  2. Converts to PCM frames
  3. Publishes audio frames to LiveKit as a microphone track

See Music Agent README for setup and usage instructions.


Radio Agent

Streams internet radio stations into a meeting room using FFmpeg for audio decoding.

Setup

cd agents/radio_agent
pip install -r requirements.txt

Dependencies: httpx, livekit

System requirement: FFmpeg must be installed (brew install ffmpeg or apt install ffmpeg)

Usage

python agent.py "https://meet.example.com/m/room-name"

How It Works

  1. Connects to a radio stream URL
  2. Pipes the stream through FFmpeg to decode to raw PCM
  3. Publishes PCM audio frames to LiveKit

See Radio Agent README for setup and usage instructions.


Video Stream Agent

Shares video and audio from a URL (HLS/m3u8, MP4) into a meeting room.

Setup

cd agents/video_stream_agent
pip install -r requirements.txt

Dependencies: httpx, livekit

System requirement: FFmpeg must be installed

Usage

python agent.py "https://meet.example.com/m/room-name"

How It Works

  1. Runs two FFmpeg processes in parallel:
    • Video: Decodes to YUV420p raw frames (1280x720 @ 30fps)
    • Audio: Decodes to PCM samples
  2. Publishes video as a screen share track
  3. Publishes audio as a microphone track

See Video Stream Agent README for setup and usage instructions.

Video Specifications

SettingValue
Width1280
Height720
FPS30
Pixel FormatYUV420p

Writing a Custom Agent

To create a new agent, follow this pattern:

import httpx
from livekit import rtc
 
# 1. Parse the meeting URL to extract room name
room_name = parse_url(meeting_url)
 
# 2. Guest login
client = httpx.Client(base_url=server_url)
resp = client.post("/api/auth/guest-login", json={"name": "Bot Name"})
token = resp.json()["token"]
 
# 3. Join room
client.headers["Authorization"] = f"Bearer {token}"
resp = client.post("/api/room/join", json={"roomName": room_name})
lk_token = resp.json()["token"]
 
# 4. Connect to LiveKit
room = rtc.Room()
await room.connect(livekit_url, lk_token)
 
# 5. Publish tracks
source = rtc.AudioSource(sample_rate=48000, num_channels=1)
track = rtc.LocalAudioTrack.create_audio_track("audio", source)
await room.local_participant.publish_track(track)
 
# 6. Stream frames
while has_data:
    frame = get_next_frame()
    await source.capture_frame(frame)

See also