Streams a local file or live source to Twitch using Enhanced Broadcasting (multitrack / adaptive bitrate) via a single RTMP connection and FFmpeg.
- Windows (tested), Linux/macOS (untested)
- Python 3.x — use the Python Launcher (
py) ifpythonis not on your PATH - MSYS2 — required on Windows to supply runtime DLLs for the FFmpeg binary
- A Twitch account with Enhanced Broadcasting enabled at https://dashboard.twitch.tv/stream-manager
py -m pip install requests
If
pyis not found, install Python from https://www.python.org/downloads/ and ensure "Add Python to PATH" is checked.
Standard FFmpeg builds do not support multiple video tracks in a single FLV/RTMP connection. You must build the enhanced-flv branch.
Run:
py teb_stream.py --build-ffmpeg
This requires MSYS2 installed at C:\msys64. The script will install MinGW toolchain packages and build FFmpeg into the FFmpeg\ subfolder automatically.
After building, copy the required runtime DLLs from C:\msys64\mingw64\bin\ into the FFmpeg\ folder alongside ffmpeg.exe:
libbz2-1.dll
libgcc_s_seh-1.dll
libiconv-2.dll
liblzma-5.dll
libwinpthread-1.dll
libx264-165.dll
libx265-215.dll
libva.dll
libva_win32.dll
SDL2.dll
zlib1.dll
You can copy them all at once in a Command Prompt:
for %f in (libbz2-1.dll libgcc_s_seh-1.dll libiconv-2.dll liblzma-5.dll libwinpthread-1.dll SDL2.dll libva.dll libva_win32.dll libx264-165.dll libx265-215.dll zlib1.dll) do copy "C:\msys64\mingw64\bin\%f" "FFmpeg\%f"Why? The build uses
--enable-staticfor FFmpeg's internal libraries but the MinGW toolchain runtime (GCC, pthreads) and encoder libraries (x264, x265) are still dynamically linked. Without these DLLs,ffmpeg.exeexits immediately with error code3221225781(0xC0000135— DLL not found).
FFmpeg\ffmpeg.exe -version
You should see version info. If you still get exit code 3221225781, a DLL is missing — re-check step 3.
py teb_stream.py --key live_XXXX_YYYY --input "C:\path\to\video.mp4"
py teb_stream.py --key live_XXXX_YYYY --input rtmp://localhost/live/stream
py teb_stream.py --key live_XXXX_YYYY --input "video.mp4" --dry-run
py teb_stream.py --key live_XXXX_YYYY --input "video.mp4" --debug
- Calls the Twitch TEB API to fetch your personalised encoder configuration (resolutions, bitrates, frame rates).
- Builds an FFmpeg filter graph that splits the input into N video tracks (up to 5), scales/fps-converts each one, and encodes them all with libx264.
- Muxes all tracks into a single enhanced FLV stream and pushes it to the Twitch ingest over RTMP.
Twitch then distributes the appropriate quality to each viewer automatically.
| Symptom | Cause | Fix |
|---|---|---|
Exit code 3221225781 |
Missing MSYS2 runtime DLLs | Copy DLLs per step 3 |
Fatal error in launcher running pip |
Python 3.12 install is broken | Use py -m pip instead |
ffmpeg not found |
ffmpeg.exe not built yet |
Run --build-ffmpeg |
| TEB API error | Enhanced Broadcasting not enabled | Enable at twitch.tv/stream-manager |
invalid number of streams |
Wrong ffmpeg build (standard, not enhanced-flv) | Rebuild with --build-ffmpeg |