пятница, 2 января 2015 г.

twitch stream ffmpeg

#! /bin/bash

#ffmpeg -f x11grab -show_region 1 -s 1280x720 -r " 25" -i :0.0+0,0 -f alsa -ac 1 -i pulse -vcodec libx264 -s 1280x720 -preset medium -acodec libmp3lame -ar 44100 -threads 1 -qscale 3 -b 400k -g 50 -minrate 400k -maxrate 400k -bufsize 400k -pix_fmt yuv420p -f flv "rtmp://live-lhr.twitch.tv/app/$twitch_key"

#exit 0

# streaming on Ubuntu via ffmpeg.
# see http://ubuntuguide.org/wiki/Screencasts for full documentation
# see http://www.thegameengine.org/miscellaneous/streaming-twitch-tv-ubuntu/
# for instructions on how to use this gist

if [ ! -f .twitch_key ]; then
    echo "Error: Could not find file: .twitch_key"
    echo "Please create this file and copy past your stream key into it. Open this script for more details."
    exit 1;
fi



# input resolution, currently fullscreen.
# you can set it manually in the format "WIDTHxHEIGHT" instead.
#INRES=$(xwininfo -root | awk '/geometry/ {print $2}'i)
INRES="1920x1080"

# output resolution.
# keep the aspect ratio the same or your stream will not fill the display.
#OUTRES="1280x720"
OUTRES="640x480"

# input audio. You can use "/dev/dsp" for your primary audio input.
INAUD="pulse"

# target fps
FPS="30"

# video preset quality level.
# more FFMPEG presets avaiable in /usr/share/ffmpeg
# According to trac.ffmpeg.org/wiki/x264EncodingGuide the presets are ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
QUAL="superfast"

# stream key. You can set this manually, or reference it from a hidden file like what is done here.
STREAM_KEY=$(cat .twitch_key)

# stream url. Note the formats for twitch.tv and justin.tv
# twitch:"rtmp://live.twitch.tv/app/$STREAM_KEY"
# justin:"rtmp://live.justin.tv/app/$STREAM_KEY"
STREAM_URL="rtmp://live-lhr.twitch.tv/app/$STREAM_KEY"

#not work
#ffmpeg \
#-f alsa -ac 2 -i "$INAUD" \
#-f x11grab -s "$INRES" -r "$FPS" -i :0.0 \
#-vcodec libx264 -s "$OUTRES" -preset ultrafast \
#-acodec libmp3lame -threads 6 -qscale 5 -b 64KB \
#-f flv -ar 44100 "$STREAM_URL"

#work
#ffmpeg \
#-f x11grab -show_region 1 -s 1280x720 \
#-r " $FPS" -i :0.0+0,0 -f alsa -ac 1 -i pulse -vcodec libx264 -s 1280x720 -preset medium -acodec libmp3lame -ar 44100 -threads 1 -qscale 3 -b 400k -g 50 -minrate 400k -maxrate 400k -bufsize 400k -pix_fmt yuv420p \
#-f flv "$STREAM_URL"

ffmpeg \
-i ~/Downloads/Разведка\ с\ воздуха\ -\ Arma\ 2\ CO\ ACE\ TFAR\ -\ TvT\ HARD.mp4 \
-f alsa -ac 1 -i pulse -vcodec libx264 -s 1280x720 -preset medium -acodec libmp3lame -ar 44100 -threads 1 -qscale 3 -b 400k -g 50 -minrate 400k -maxrate 400k -bufsize 400k -pix_fmt yuv420p \
-f flv "$STREAM_URL"

Комментариев нет:

Отправить комментарий