Created
December 4, 2022 08:08
-
-
Save XdoctorwhoZ/ba097c5a202f8e13372d42b9cc834c5e to your computer and use it in GitHub Desktop.
To start a stream on twitch with ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ========================================================= | |
# Input resolution | |
# INRES="320x200" | |
INRES="640x360" | |
# INRES="1920x1080" | |
# ========================================================= | |
# Output resolution | |
# OUTRES="320x200" | |
OUTRES="640x360" | |
# OUTRES="1920x1080" | |
# ========================================================= | |
# Target FPS (but FFMEPG will choose one for you anyway) | |
TARGET_FPS="25" | |
# ========================================================= | |
# One of the many FFMPEG preset | |
QUALITY="ultrafast" | |
# QUALITY="superfast" | |
# QUALITY="veryfast" | |
# QUALITY="fast" | |
# QUALITY="medium" | |
# ========================================================= | |
# Max 6 | |
THREADS="6" | |
# ========================================================= | |
# constant bitrate (should be between 1000k - 3000k) | |
CBR="1000k" | |
# ========================================================= | |
# Twitch STREAM KEY (go your account) | |
STREAM_KEY="live_xxxxxxxxxxxxxxxxxxxxxxxx" | |
# Twitch server (depend of your location) | |
SERVER="live-fra" | |
# ========================================================= | |
# Output format | |
# ffmpeg -formats | |
OUTFORMAT=h264 | |
# ========================================================= | |
# Pixel format | |
# ffmpeg -h encoder=libx264 | grep "Supported pixel" | |
PIW_FMT=yuv420p | |
# PIW_FMT=gray | |
# ========================================================= | |
ffmpeg \ | |
-s "$INRES" \ | |
-r "$TARGET_FPS" \ | |
-f v4l2 \ | |
-i /dev/video0 \ | |
\ | |
\ | |
-c:v $OUTFORMAT \ | |
-pix_fmt $PIW_FMT \ | |
-preset $QUALITY \ | |
-threads $THREADS \ | |
-s $OUTRES \ | |
-f flv \ | |
"rtmp://$SERVER.twitch.tv/app/$STREAM_KEY" | |
# ========================================================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment