Created
April 26, 2020 22:53
-
-
Save gatlin/986a5610b0b4cd6c0ba0ea00d536dead to your computer and use it in GitHub Desktop.
Stream arbitrary video files to twitch via gstreamer
This file contains hidden or 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
#!/usr/bin/env bash | |
### | |
# Usage | |
### | |
# twitch <path-to-file> | |
PATH_TO_TWITCH_KEY="$HOME/.config/twitch.key" | |
if [ ! -f "$HOME/.config/twitch.key" ]; then | |
echo "Please write your twitch key to $PATH_TO_TWITCH_KEY" | |
exit 1 | |
fi | |
TWITCH_KEY=$(cat $PATH_TO_TWITCH_KEY) | |
FILE_PATH="$1" | |
if [ -z "$FILE_PATH" ]; then | |
echo "Please specify a file to stream." | |
exit 1 | |
fi | |
gst-launch-1.0 --gst-debug-level=2 \ | |
filesrc location="$FILE_PATH" ! \ | |
qtdemux name=demux \ | |
demux.video_0 ! \ | |
queue ! \ | |
decodebin ! \ | |
videoconvert ! \ | |
x264enc threads=0 bitrate=400 tune=zerolatency key-int-max=30 ! \ | |
queue ! \ | |
flvmux name=flvmux ! \ | |
queue ! \ | |
rtmpsink location="rtmp://live-fra.twitch.tv/app/$TWITCH_KEY" \ | |
demux.audio_0 ! \ | |
queue ! \ | |
decodebin ! \ | |
audioconvert ! \ | |
audioresample ! \ | |
avenc_aac ! \ | |
flvmux. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment