Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -x
- IFS=$'
- '
- USER=$(whoami)
- REGION_="0.0+0,0"
- INRES_="1920x1080"
- OUTRES_="1280x720"
- FPS_="30"
- QUAL_="fast"
- STREAMKEY_="live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
- URL_="rtmp://live.justin.tv/app/$STREAMKEY_" #flashver=FMLE/3.0\20(compatible;\20FMSc/1.0)"
- THREADS_="1"
- # ------------------------------------------------------------------
- _launchMenu ()
- {
- while true; do
- _launchMenu=$(zenity --width="400" \
- --height="200" \
- --list --column "Options" --column "Description" --title="Argee to use?" \
- --text="Choose Your Destiny?" \
- "Run" "Agree to use this script." \
- "Exit" "Disagree to use and exit.")
- if [ "$_launchMenu" = "Run" ]; then
- _fullscreenMenu
- elif [ "$_launchMenu" = "Exit" ]; then
- exit
- else
- exit
- fi
- done
- }
- # ------------------------------------------------------------------
- _fullscreenMenu ()
- {
- while true; do
- _fullscreenMenu=$(zenity --width="550" \
- --height="375" \
- --list --column "Options" --column "Description" --column "Root" --title="If a Genie granted you three wishes, what would you wish for?" \
- --text="What would you like to do $USER? Your wish is my command." \
- "xwininfo" "Enter x_offset and y_offset value." "(NO)" \
- "res" "Set input & output resolution values." "(NO)" \
- "fps" "Select FPS value for your screen capture." "(NO)" \
- "qual" "Select FFMPEG capture quallity settings." "(NO)" \
- "streamkey" "Enter your Twitch.tv stream key." "(NO)" \
- "threads" "Enter the ammount of threads to allocate." "(NO)" \
- "stream" "Start streaming to Twitch.tv" "(NO)" \
- "exit")
- if [ "$_fullscreenMenu" = "xwininfo" ]; then
- _xwinInfo
- elif [ "$_fullscreenMenu" = "res" ]; then
- _resMenu
- elif [ "$_fullscreenMenu" = "fps" ]; then
- _selectFPS
- elif [ "$_fullscreenMenu" = "qual" ]; then
- _selectQual
- elif [ "$_fullscreenMenu" = "streamkey" ]; then
- _streamKey
- elif [ "$_fullscreenMenu" = "threads" ]; then
- _selectThreads
- elif [ "$_fullscreenMenu" = "stream" ]; then
- _startStream
- elif [ "$_fullscreenMenu" = "exit" ]; then
- exit
- else
- exit
- fi
- done
- }
- # ------------------------------------------------------------------
- _resMenu ()
- {
- while true; do
- _resMenu=$(zenity --width="475" \
- --height="210" \
- --list --column "Options" --column "Description" --title="Resolution options." \
- --text="Choose the input and output resolution values." \
- "inres" "Input resolution value." \
- "outres" "Output resolution value." \
- "Back" "")
- if [ "$_resMenu" = "inres" ]; then
- _inRes
- elif [ "$_resMenu" = "outres" ]; then
- _outRes
- elif [ "$_resMenu" = "Back" ]; then
- _fullscreenMenu
- else
- exit
- fi
- done
- }
- # ------------------------------------------------------------------
- _xwinInfo ()
- (
- xwininfo -frame &&
- REGION_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Enter x_offset and y_offset." \
- --text="Example: 0.0+0,0")
- _fullscreenMenu
- )
- # ------------------------------------------------------------------
- _inRes ()
- (
- while true; do
- _inRes=$(zenity --width="400" --height="325" --list --column "Option" --column "Description" --title="Please select an input resolution" \
- --text "Which input resolution would you like to use $USER?" \
- "240p" "Input resolution of 320×240 pixels." \
- "360p" "Input resolution of 640×360 pixels." \
- "480p" "Input resolution of 720x480 pixels." \
- "720p" "Input resolution of 1280x720 pixels." \
- "1080p" "Input resolution of 1920x1080 pixels." \
- "Custom" "Enter any value for your input resolution." \
- "Back")
- if [ "$_inRes" = "240p" ]; then
- INRES_='320X240' &&
- _fullscreenMenu
- elif [ "$_inRes" = "360p" ]; then
- INRES_='640X360' &&
- _fullscreenMenu
- elif [ "$_inRes" = "480p" ]; then
- INRES_='720X480' &&
- _fullscreenMenu
- elif [ "$_inRes" = "720p" ]; then
- INRES_='1280X720' &&
- _fullscreenMenu
- elif [ "$_inRes" = "1080p" ]; then
- INRES_='1920X1080' &&
- _fullscreenMenu
- elif [ "$_inRes" = "Custom" ]; then
- INRES_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter a value." \
- --text="Example: 704X396")
- _fullscreenMenu
- elif [ "$_fullscreenMenu" = "Back" ]; then
- _fullscreenMenu
- else
- exit
- fi
- done
- )
- # ------------------------------------------------------------------
- _outRes ()
- (
- while true; do
- _outRes=$(zenity --width="400" --height="325" --list --column "Option" --column "Description" --title="Please select an input resolution" \
- --text "Which input resolution would you like to use $USER?" \
- "240p" "Output resolution of 320×240 pixels." \
- "360p" "Output resolution of 640×360 pixels." \
- "480p" "Output resolution of 720x480 pixels." \
- "720p" "Output resolution of 1280x720 pixels." \
- "1080p" "Output resolution of 1920x1080 pixels." \
- "Custom" "Enter any value for your output resolution." \
- "Back")
- if [ "$_outRes" = "240p" ]; then
- OUTRES_='320X240' &&
- _fullscreenMenu
- elif [ "$_outRes" = "360p" ]; then
- OUTRES_='640X360' &&
- _fullscreenMenu
- elif [ "$_outRes" = "480p" ]; then
- OUTRES_='720X480' &&
- _fullscreenMenu
- elif [ "$_outRes" = "720p" ]; then
- OUTRES_='1280X720' &&
- _fullscreenMenu
- elif [ "$_outRes" = "1080p" ]; then
- OUTRES_='1920X1080' &&
- _fullscreenMenu
- elif [ "$_outRes" = "Custom" ]; then
- OUTRES_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter a value." \
- --text="Example: 704X396")
- _fullscreenMenu
- elif [ "$_fullscreenMenu" = "Back" ]; then
- _fullscreenMenu
- else
- exit
- fi
- done
- )
- # ------------------------------------------------------------------
- _selectFPS ()
- (
- while true; do
- _selectFPS=$(zenity --width="400" --height="300" --list --column "Option" --column "Description" --title="Please select your target FPS." \
- --text "Please select an option $USER." \
- "15" "Set the target FPS to 15." \
- "30" "Set the target FPS to 30." \
- "60" "Set the target FPS to 60." \
- "120" "Set the target FPS to 120." \
- "Custom" "Enter any value for the target FPS." \
- "Back")
- if [ "$_selectFPS" = "15" ]; then
- FPS_='15' &&
- _fullscreenMenu
- elif [ "$_selectFPS" = "30" ]; then
- FPS_='30' &&
- _fullscreenMenu
- elif [ "$_selectFPS" = "60" ]; then
- FPS_='60' &&
- _fullscreenMenu
- elif [ "$_selectFPS" = "120" ]; then
- FPS_='120' &&
- _fullscreenMenu
- elif [ "$_selectFPS" = "Custom" ]; then
- FPS_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter your target FPS." \
- --text="Example: 35")
- _fullscreenMenu
- elif [ "$_selectFPS" = "Back" ]; then
- _fullscreenMenu
- else
- exit
- fi
- done
- )
- # ------------------------------------------------------------------
- _selectQual ()
- (
- while true; do
- _selectQual=$(zenity --width="475" --height="450" --list --column "Option" --column "Description" --title="Select the FFMPEG preset." \
- --text "FFMPEG preset configs for the x264 video encoder." \
- "Ultrafast" "Select ultrafast FFMPEG encoder preset." \
- "Superfast" "Select superfast FFMPEG encoder preset." \
- "Veryfast" "Select veryfast FFMPEG encoder preset." \
- "Faster" "Select faster FFMPEG encoder preset." \
- "Fast" "Select fast FFMPEG encoder preset." \
- "Medium" "Select medium FFMPEG encoder preset." \
- "Slow" "Select slow FFMPEG encoder preset." \
- "Slower" "Select slower FFMPEG encoder preset." \
- "Veryslow" "Select veryslow FFMPEG encoder preset." \
- "Custom" "Enter another preset value for the FFMPEG encoder." \
- "Back")
- if [ "$_selectQual" = "Ultrafast" ]; then
- QUAL_='ultrafast' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Superfast" ]; then
- QUAL_='superfast' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Veryfast" ]; then
- QUAL_='veryfast' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Faster" ]; then
- QUAL_='faster' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Fast" ]; then
- QUAL_='fast' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Medium" ]; then
- QUAL_='medium' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Slow" ]; then
- QUAL_='slow' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Slower" ]; then
- QUAL_='slower' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Veryslow" ]; then
- QUAL_='veryslow' &&
- _fullscreenMenu
- elif [ "$_selectQual" = "Custom" ]; then
- QUAL_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter a FFMPEG preset." \
- --text="Example: baseline")
- _fullscreenMenu
- elif [ "$_selectQual" = "Back" ]; then
- _fullscreenMenu
- else
- exit
- fi
- done
- )
- # ------------------------------------------------------------------
- _streamKey ()
- {
- while true; do
- _streamKey=$(zenity --width="475" \
- --height="210" \
- --list --column "Options" --column "Description" --title="Please select an option." \
- --text="Choose Your Destiny?" \
- "Get Key" "Obtain your streamkey from http://www.justin.tv" \
- "Enter" "Enter you Twitch.tv streamkey." \
- "Back" "")
- if [ "$_streamKey" = "Get Key" ]; then
- exec firefox http://www.twitch.tv/broadcast
- elif [ "$_streamKey" = "Enter" ]; then
- STREAMKEY_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter your Twitch.tv streamkey." \
- --text='Example: live_XXXX_XXXX')
- _fullscreenMenu
- elif [ "$_streamKey" = "Back" ]; then
- _fullscreenMenu
- else
- exit
- fi
- done
- }
- # ------------------------------------------------------------------
- _selectThreads ()
- {
- THREADS_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Set the -threads value." \
- --text='Example: 2')
- _fullscreenMenu
- }
- # ------------------------------------------------------------------
- _startStream ()
- {
- echo ffmpeg -f x11grab -show_region 1 -s "$INRES_" -r "$FPS_" -i :"$REGION_" -ab 96k -f alsa -ac 2 -i pulse -vcodec libx264 \
- -crf 30 -preset "$QUAL_" -s "$OUTRES_" -acodec libmp3lame -ar 44100 -threads "$THREADS_" -f flv "$URL_"
- _fullscreenMenu
- }
- # ------------------------------------------------------------------
- _launchMenu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement