Direct MKV streaming is not supported in many browsers (like Safari). This Flask application transcodes MKV files to HLS format on-the-fly as users request them, making MKV videos playable in any browser.
# Clone the repository
git clone https://github.com/kevinnadar22/mkvstreamer.git
cd mkvstreamer
# Install dependencies using uv
uv sync
# Install FFmpeg (required)
# Ubuntu/Debian:
sudo apt update && sudo apt install ffmpeg
# macOS:
brew install ffmpeg
# Windows:
# Download from https://ffmpeg.org/download.html or use chocolatey:
choco install ffmpeg
# Run the application
python main.py- Uses FFmpeg for real-time MKV to HLS transcoding
- Flask backend server handles requests
- Supports HTTP range requests for video seeking
- Works great on Safari and Chrome
You can customize the segment duration in config.py:
SEGMENT_DURATION = 6 Set the PORT environment variable to change the default port (5000):
export PORT=8080
python main.py# Install FFmpeg first (see Quick Start above)
python main.pydocker build -t mkvstreamer .
docker run -p 5000:5000 mkvstreamer# Add FFmpeg buildpack (required)
heroku buildpacks:add --index 1 https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
heroku buildpacks:add heroku/python
# Deploy
git push heroku masterVisit http://localhost:5000/index.html for the web interface.
GET /transcode?url=<mkv_url>
Example:
curl "http://localhost:5000/transcode?url=https://example.com/video.mkv"- Website: https://mariakevin.in
- GitHub: https://github.com/kevinnadar22/mkvstreamer
