This script allows you to record twitch streams live to .mp4 files.
It is an improved version of junian's twitch-recorder, migrated to helix - the new twitch API. It uses OAuth2.
- python3.8 or higher
- streamlink
- ffmpeg
-
Check if you have latest version of streamlink:
streamlink --versionshows current versionstreamlink --version-checkshows available upgradesudo pip install --upgrade streamlinkdo upgrade
-
Install
requestsmodule if you don't have it- Windows:
python -m pip install requests - Linux:
python3.8 -m pip install requests
- Windows:
-
Create
config.pyfile in the same directory astwitch-recorder.pywith:
root_path = "/home/abathur/Videos/twitch"
username = "forsen"
client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client_secret = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"root_path - path to a folder where you want your VODs to be saved to
username - name of the streamer you want to record by default
client_id - you can grab this from here once you register your application
client_secret - you generate this here as well, for your registered application
The script will be logging to a console and to a file twitch-recorder.log
Run the script
python3.8 twitch-recorder.pyTo record a specific streamer use -u or --username
python3.8 twitch-recorder.py --username forsenTo specify quality use -q or --quality
python3.8 twitch-recorder.py --quality 720pTo change default logging use -l, --log or --logging
python3.8 twitch-recorder.py --log warnTo disable ffmpeg processing (fixing errors in recorded file) use --disable-ffmpeg
python3.8 twitch-recorder.py --disable-ffmpegIf you want to run the script as a job in the background and be able to close the terminal:
nohup python3.8 twitch-recorder.py >/dev/null 2>&1 &In order to kill the job, you first list them all:
jobsThe output should show something like this:
[1]+ Running nohup python3.8 twitch-recorder > /dev/null 2>&1 &And now you can just kill the job:
kill %1You can run the scipt from cmd or terminal, by simply going to the directory where the script is located at and using command:
python twitch-recorder.pyThe optional parameters should work exactly the same as on Linux.