Stream video and audio into Discord voice channels (Go Live / webcam) using Python.
Project description
discord-video-stream-py
Stream video and audio directly into Discord voice channels (Go Live / webcam) using Python. No Node.js required.
Inspired by the TypeScript @dank074/discord-video-stream, built from the ground up for Python developers.
Features
- ๐ฌ H264 & VP8 video streaming via Discord Go Live
- ๐๏ธ Opus audio (48 kHz stereo, 20 ms frames)
- ๐ Full SRTP encryption โ XSalsa20-Poly1305, XChaCha20-Poly1305, and AES-256-GCM
- ๐บ Webcam mode (non-Go Live) and Go Live streaming
- ๐ Online sources via
yt-dlp(YouTube, Twitch, 1000+ sites) - โฏ๏ธ Full playback controls: pause, resume, seek, stop
- ๐ Auto-reconnect with exponential backoff on voice gateway drops
- ๐๏ธ Events system โ
on_start,on_finish,on_error,on_progress - ๐ Resolution presets โ 480p, 720p, 1080p, or source quality
- ๐ Familiar
discord.py-style async API
System Requirements
- Python 3.10+
- (Optional)
ffmpegandyt-dlpinstalled in your system PATH.
[!NOTE] Zero Setup Required: The library automatically downloads and bundles cross-platform static binaries for
ffmpegandyt-dlp(supporting Windows x64, Linux x64/arm64, and macOS Intel/Apple Silicon). The library will fall back to your system'sffmpegoryt-dlpif the bundled binaries are not found.
Installation
pip install discord-video-stream-py
Quick Start
Stream a local file
import discord
from discord_video_stream import Streamer, VideoPlayer
client = discord.Client()
streamer = Streamer(client)
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
await streamer.join_voice(guild_id=123456789, channel_id=987654321)
udp = await streamer.create_stream(resolution="720p", fps=30, codec="h264")
player = VideoPlayer("movie.mp4", udp)
await player.play()
client.run("YOUR_USER_TOKEN")
Stream from YouTube
player = VideoPlayer("https://www.youtube.com/watch?v=dQw4w9WgXcQ", udp)
await player.play()
VP8 & Webcam mode
udp = await streamer.create_stream(
resolution="480p", fps=30,
codec="vp8", stream_type="webcam"
)
player = VideoPlayer("video.mp4", udp, codec="vp8")
await player.play()
Playback Controls
player.pause()
await player.seek(120) # seek to 2:00
player.resume()
player.stop()
Events
@player.on("start")
async def on_start():
print("Streaming started!")
@player.on("finish")
async def on_finish():
await streamer.stop_stream()
@player.on("error")
async def on_error(exc):
print(f"Stream error: {exc}")
API Reference
Streamer(client)
Wraps a discord.py-self Client and manages the stream lifecycle.
| Method | Description |
|---|---|
await join_voice(guild_id, channel_id) |
Join a voice channel |
await create_stream(resolution, fps, codec, stream_type) |
Start streaming, returns MediaUdp |
await stop_stream() |
Stop the stream and clean up |
await leave_voice(guild_id) |
Leave the voice channel |
VideoPlayer(source, udp, **kwargs)
High-level media player with events.
| Method | Description |
|---|---|
await play() |
Start playback |
pause() |
Pause (FFmpeg keeps running) |
resume() |
Resume playback |
await seek(seconds) |
Seek to position (restarts FFmpeg) |
stop() |
Stop playback |
on(event)(callback) |
Register event callback |
Enums
| Enum | Values |
|---|---|
Codec |
"h264", "vp8" |
StreamType |
"go_live", "webcam" |
Resolution |
"480p", "720p", "1080p", "source" |
Development Status
| Phase | Status | Description |
|---|---|---|
| 1 โ Foundation | โ Complete | Voice Gateway + Audio streaming |
| 2 โ Video (H264) | โ Complete | H264 Go Live streaming + FU-A fragmentation |
| 3 โ VP8 + Webcam | โ Complete | VP8 codec + webcam mode |
| 4 โ yt-dlp + DX | โ Complete | Online sources + player events + seek |
| 5 โ Release | ๐ง In Progress | PyPI publish + docs + tests |
Architecture
discord_video_stream/
โโโ __init__.py # Public API: Streamer, VideoPlayer, enums
โโโ streamer.py # Main entry point โ wraps discord.py-self client
โโโ bin/ # Bundled cross-platform binaries (FFmpeg & yt-dlp)
โ โโโ windows-x64/
โ โโโ linux-x64/
โ โโโ linux-arm64/
โ โโโ macos-x64/
โ โโโ macos-arm64/
โโโ voice/
โ โโโ gateway.py # Voice WebSocket (all OPs, heartbeat, resume)
โ โโโ udp.py # MediaUdp โ UDP socket, RTP dispatch, keepalive
โ โโโ rtp.py # RTP packet builder (audio + video + extension)
โ โโโ encryption.py # XSalsa20 / XChaCha20 / AES-256-GCM encryption
โโโ codecs/
โ โโโ h264.py # NAL unit packetizer (FU-A fragmentation, SPS/PPS)
โ โโโ vp8.py # VP8 RTP packetizer (RFC 7741)
โ โโโ opus.py # Opus audio framer (48kHz, 20ms)
โโโ media/
โ โโโ player.py # MediaPlayer + VideoPlayer โ FFmpeg โ RTP pipeline
โ โโโ ffmpeg.py # FFmpeg subprocess builder (H264/VP8/Opus)
โ โโโ ytdlp.py # yt-dlp URL resolver
โโโ utils/
โโโ ssrc.py # SSRC generation + video/RTX offsets
โโโ binaries.py # Cross-platform binary helper/resolver
Contributing
PRs welcome! See docs/getting-started.md for a development setup guide.
git clone https://github.com/subhobhai943/discord-video-stream-py.git
cd discord-video-stream-py
python -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
pytest
License
MIT โ see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file discord_video_stream_py-0.1.1.tar.gz.
File metadata
- Download URL: discord_video_stream_py-0.1.1.tar.gz
- Upload date:
- Size: 729.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1de3a2b0cb151df80aecd5b71f5b5b8690938885b1dd69847af2e318f368b5c
|
|
| MD5 |
f704b64b2d4e7eed3f5f2c8082716785
|
|
| BLAKE2b-256 |
7ea6f4ffac58fcea425155858cdd4abef8340b302534b832c74379ef74ece3e9
|
Provenance
The following attestation bundles were made for discord_video_stream_py-0.1.1.tar.gz:
Publisher:
publish.yml on subhobhai943/discord-video-stream-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
discord_video_stream_py-0.1.1.tar.gz -
Subject digest:
f1de3a2b0cb151df80aecd5b71f5b5b8690938885b1dd69847af2e318f368b5c - Sigstore transparency entry: 1930879116
- Sigstore integration time:
-
Permalink:
subhobhai943/discord-video-stream-py@10eac80f510d0d930ca120e2f8afea71fce30dd3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/subhobhai943
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@10eac80f510d0d930ca120e2f8afea71fce30dd3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file discord_video_stream_py-0.1.1-py3-none-any.whl.
File metadata
- Download URL: discord_video_stream_py-0.1.1-py3-none-any.whl
- Upload date:
- Size: 41.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef81685b8d1d00e738bcb6f62929af720b1e5924a9d34222c5334c5e0bb8d6f9
|
|
| MD5 |
820de4aa71e5348f4c4a4e31d8e1ebc6
|
|
| BLAKE2b-256 |
ef0b79623965e6840a3d4822e1eb033b22b1b51190c7816db6ffa26bd5ec7d18
|
Provenance
The following attestation bundles were made for discord_video_stream_py-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on subhobhai943/discord-video-stream-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
discord_video_stream_py-0.1.1-py3-none-any.whl -
Subject digest:
ef81685b8d1d00e738bcb6f62929af720b1e5924a9d34222c5334c5e0bb8d6f9 - Sigstore transparency entry: 1930879253
- Sigstore integration time:
-
Permalink:
subhobhai943/discord-video-stream-py@10eac80f510d0d930ca120e2f8afea71fce30dd3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/subhobhai943
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@10eac80f510d0d930ca120e2f8afea71fce30dd3 -
Trigger Event:
release
-
Statement type: