Introduction
This guide will help you set up a 24/7 live stream using FFmpeg and PyLivestream, a Python package that facilitates streaming to multiple platforms.
Prerequisites
- Python 3.9 or higher
- FFmpeg 4.2 or higher (required for Facebook Live)
Installation
Install FFmpeg
FFmpeg is a complete, cross-platform solution to record, convert, and stream audio and video.
# Windows
winget install ffmpeg
# Linux
sudo apt install ffmpeg
# MacOS
brew install ffmpeg
Install PyLivestream
PyLivestream can be installed via pip. For the latest release:
python3 -m pip install PyLivestream
For the development version:
git clone https://github.com/scivision/PyLivestream
cd PyLivestream
python3 -m pip install -e .
Configuration
Create and configure the pylivestream.json
file with parameters relevant to your live stream.
{
"screencap_origin": [0, 0],
"screencap_size": [1920, 1080],
"screencap_fps": 30,
"video_kbps": 2500,
"audio_rate": 44100,
"audio_bps": 128,
"preset": "veryfast",
"exe": "/path/to/ffmpeg"
}
Running the Stream
Once configured, you can start streaming using one of the following commands:
python -m pylivestream.screen youtube ./pylivestream.json
python -m pylivestream.screen facebook ./pylivestream.json
python -m pylivestream.screen twitch ./pylivestream.json
Authentication
Ensure you have the stream URL and stream key from your streaming service and include them in your pylivestream.json
file.
YouTube Live
- Configure your YouTube Live stream.
- Edit
pylivestream.json
to include your YouTube stream ID. - Run the following command:
python -m pylivestream.screen youtube ./pylivestream.json
Facebook Live
- Configure your Facebook Live stream.
- Edit
pylivestream.json
to include your Facebook stream ID. - Run the following command:
python -m pylivestream.screen facebook ./pylivestream.json
Twitch
- Configure your Twitch stream.
- Edit
pylivestream.json
to include your Twitch stream URL and stream ID. - Run the following command:
python -m pylivestream.screen twitch ./pylivestream.json
Additional Information
For detailed information on configuration, troubleshooting, and advanced usage, visit the PyLivestream GitHub repository.