Skip to content

mitchcl/ffmpeg_teb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitch Enhanced Broadcasting (TEB) Streamer

Streams a local file or live source to Twitch using Enhanced Broadcasting (multitrack / adaptive bitrate) via a single RTMP connection and FFmpeg.


Requirements

  • Windows (tested), Linux/macOS (untested)
  • Python 3.x — use the Python Launcher (py) if python is 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

Setup

1. Install Python dependency

py -m pip install requests

If py is not found, install Python from https://www.python.org/downloads/ and ensure "Add Python to PATH" is checked.

2. Build FFmpeg (enhanced-flv branch)

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.

3. Copy MSYS2 runtime DLLs (Windows only)

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-static for FFmpeg's internal libraries but the MinGW toolchain runtime (GCC, pthreads) and encoder libraries (x264, x265) are still dynamically linked. Without these DLLs, ffmpeg.exe exits immediately with error code 3221225781 (0xC0000135 — DLL not found).

4. Verify FFmpeg works

FFmpeg\ffmpeg.exe -version

You should see version info. If you still get exit code 3221225781, a DLL is missing — re-check step 3.


Usage

Stream a local file

py teb_stream.py --key live_XXXX_YYYY --input "C:\path\to\video.mp4"

Stream a live source (e.g. OBS virtual camera, capture card)

py teb_stream.py --key live_XXXX_YYYY --input rtmp://localhost/live/stream

Preview the FFmpeg command without streaming

py teb_stream.py --key live_XXXX_YYYY --input "video.mp4" --dry-run

Debug the Twitch API response

py teb_stream.py --key live_XXXX_YYYY --input "video.mp4" --debug

How it works

  1. Calls the Twitch TEB API to fetch your personalised encoder configuration (resolutions, bitrates, frame rates).
  2. 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.
  3. 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.


Troubleshooting

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

About

Streams a local file or live source to Twitch using Enhanced Broadcasting (multitrack / adaptive bitrate) via a single RTMP connection and FFmpeg.

Resources

Stars

Watchers

Forks

Contributors

Languages