Skip to main content

tgrtmp

Version Python versions Downloads Docs

Buy me a Cup of TON

tgrtmp is a high-performance RTMP(S) publishing client for Telegram livestreams.

Features

tgrtmp offers numerous advantages, including:

  • Easy to Use: One call to go live; a worker thread does the rest
  • High Performance: Demuxing, pacing, and sending run in a fast native engine
  • Zero Transcoding: H.264/AAC frames pass through untouched
  • Player Controls: Pause, play, mute, and a live position, VLC-style, from any thread
  • Playlists: Queue files, skip, reorder, and chain episodes while live; it all plays on one connection
  • Endless Channels: Looping restarts a file on the same timeline: one uninterrupted stream, forever
  • DVR for Live Sources: Any growing .read(n) handle, with an opt-in rolling window (buffer_size) that lets pause hold its point

Requirements

  • Python 3.10+
  • A Telegram livestream RTMP URL and stream key
  • Media in H.264 + AAC (MPEG-TS, MP4, or MKV); other codecs are rejected, not transcoded

Installation

pip install --upgrade tgrtmp

tgrtmp builds from source on install, so it needs a C++ compiler and the OpenSSL development headers; the installation guide has the one command for your system.

Examples

Publish a file and hold the last frame when it ends:

import time
import tgrtmp

player = tgrtmp.publish(
    "movie.mp4",
    "rtmps://dc4-1.rtmp.t.me/s/",
    "STREAM_KEY",
    log=print,
)

# The file plays in real time; at the end the last frame is held
# so the stream stays live until you stop it.
while not player.stopped:
    time.sleep(1)

Control it while it runs; every call is thread-safe:

player.pause()       # viewers see a still frame; the connection stays alive
player.play()
player.mute()
player.position      # seconds into the source
player.stats         # one dict: bitrate, frames, loops, state
player.stop()

Turn it into a 24/7 channel:

player = tgrtmp.publish("movie.mp4", url, key, loop=True)

Queue a playlist and edit it while live:

player = tgrtmp.publish("intro.mp4", url, key, playlist=["a.mp4", "b.mp4"])

player.next()            # skip the intro
player.add("c.mp4")      # append to the queue

Not sure about a file? Ask before you stream:

tgrtmp.needs_transcode("clip.mkv")   # True means: transcode it first

For more examples, check the examples folder.

Documentation

The full documentation (quick start, guides, and API reference) lives at tgrtmp.pages.dev.

Thanks to

  • You for viewing or using this project.

  • MadelineProto for documenting the RTMP behavior of Telegram's servers

License

MIT License

Metadata

Release files for tgrtmp 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tgrtmp 0.6.0
File Size Uploaded Provenance Actions
tgrtmp-0.6.0.tar.gz 115.9 kB With provenance Details for tgrtmp-0.6.0.tar.gz

Release files / tgrtmp-0.6.0.tar.gz

Download URL tgrtmp-0.6.0.tar.gz
Size 115.9 kB
Tags Source
SHA-256 checksum
How to use checksums
69e51da7fb86ce039379bdd9f8f603ec7513c9ce42dcd991d051149a622c30bc
BLAKE2b-256 checksum
How to use checksums
e41814e6cb9b35dac35ff2b6a260ccd4c213347c17027f5f01fcc9e6337c81a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for tgrtmp 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

1 file in this release has been uploaded with provenance metadata.

Attestation for tgrtmp-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page