Advertisement
TehCAKE

Untitled

May 23rd, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.83 KB | None | 0 0
  1. #!/bin/bash -x
  2. IFS=$'
  3. '
  4. USER=$(whoami)
  5. REGION_="0.0+0,0"
  6. INRES_="1920x1080"
  7. OUTRES_="1280x720"
  8. FPS_="30"
  9. QUAL_="fast"
  10. STREAMKEY_="live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  11. URL_="rtmp://live.justin.tv/app/$STREAMKEY_" #flashver=FMLE/3.0\20(compatible;\20FMSc/1.0)"
  12. THREADS_="1"
  13. # ------------------------------------------------------------------
  14. _launchMenu ()
  15. {
  16. while true; do
  17.  
  18. _launchMenu=$(zenity --width="400" \
  19. --height="200" \
  20. --list --column "Options" --column "Description" --title="Argee to use?" \
  21. --text="Choose Your Destiny?" \
  22. "Run" "Agree to use this script." \
  23. "Exit" "Disagree to use and exit.")
  24.  
  25. if [ "$_launchMenu" = "Run" ]; then
  26. _fullscreenMenu
  27. elif [ "$_launchMenu" = "Exit" ]; then
  28. exit
  29. else
  30. exit
  31.  
  32. fi
  33. done
  34. }
  35. # ------------------------------------------------------------------
  36. _fullscreenMenu ()
  37. {
  38. while true; do
  39.  
  40. _fullscreenMenu=$(zenity --width="550" \
  41. --height="375" \
  42. --list --column "Options" --column "Description" --column "Root" --title="If a Genie granted you three wishes, what would you wish for?" \
  43. --text="What would you like to do $USER? Your wish is my command." \
  44. "xwininfo" "Enter x_offset and y_offset value." "(NO)" \
  45. "res" "Set input & output resolution values." "(NO)" \
  46. "fps" "Select FPS value for your screen capture." "(NO)" \
  47. "qual" "Select FFMPEG capture quallity settings." "(NO)" \
  48. "streamkey" "Enter your Twitch.tv stream key." "(NO)" \
  49. "threads" "Enter the ammount of threads to allocate." "(NO)" \
  50. "stream" "Start streaming to Twitch.tv" "(NO)" \
  51. "exit")
  52.  
  53. if [ "$_fullscreenMenu" = "xwininfo" ]; then
  54. _xwinInfo
  55.  
  56. elif [ "$_fullscreenMenu" = "res" ]; then
  57. _resMenu
  58.  
  59. elif [ "$_fullscreenMenu" = "fps" ]; then
  60. _selectFPS
  61.  
  62. elif [ "$_fullscreenMenu" = "qual" ]; then
  63. _selectQual
  64.  
  65. elif [ "$_fullscreenMenu" = "streamkey" ]; then
  66. _streamKey
  67.  
  68. elif [ "$_fullscreenMenu" = "threads" ]; then
  69. _selectThreads
  70.  
  71. elif [ "$_fullscreenMenu" = "stream" ]; then
  72. _startStream
  73.  
  74. elif [ "$_fullscreenMenu" = "exit" ]; then
  75. exit
  76. else
  77. exit
  78.  
  79. fi
  80. done
  81. }
  82. # ------------------------------------------------------------------
  83. _resMenu ()
  84. {
  85. while true; do
  86.  
  87. _resMenu=$(zenity --width="475" \
  88. --height="210" \
  89. --list --column "Options" --column "Description" --title="Resolution options." \
  90. --text="Choose the input and output resolution values." \
  91. "inres" "Input resolution value." \
  92. "outres" "Output resolution value." \
  93. "Back" "")
  94.  
  95. if [ "$_resMenu" = "inres" ]; then
  96. _inRes
  97.  
  98. elif [ "$_resMenu" = "outres" ]; then
  99. _outRes
  100.  
  101. elif [ "$_resMenu" = "Back" ]; then
  102. _fullscreenMenu
  103. else
  104. exit
  105.  
  106. fi
  107. done
  108. }
  109. # ------------------------------------------------------------------
  110. _xwinInfo ()
  111. (
  112. xwininfo -frame &&
  113. REGION_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Enter x_offset and y_offset." \
  114. --text="Example: 0.0+0,0")
  115. _fullscreenMenu
  116. )
  117. # ------------------------------------------------------------------
  118. _inRes ()
  119. (
  120. while true; do
  121. _inRes=$(zenity --width="400" --height="325" --list --column "Option" --column "Description" --title="Please select an input resolution" \
  122. --text "Which input resolution would you like to use $USER?" \
  123. "240p" "Input resolution of 320×240 pixels." \
  124. "360p" "Input resolution of 640×360 pixels." \
  125. "480p" "Input resolution of 720x480 pixels." \
  126. "720p" "Input resolution of 1280x720 pixels." \
  127. "1080p" "Input resolution of 1920x1080 pixels." \
  128. "Custom" "Enter any value for your input resolution." \
  129. "Back")
  130.  
  131. if [ "$_inRes" = "240p" ]; then
  132. INRES_='320X240' &&
  133. _fullscreenMenu
  134.  
  135. elif [ "$_inRes" = "360p" ]; then
  136. INRES_='640X360' &&
  137. _fullscreenMenu
  138.  
  139. elif [ "$_inRes" = "480p" ]; then
  140. INRES_='720X480' &&
  141. _fullscreenMenu
  142.  
  143. elif [ "$_inRes" = "720p" ]; then
  144. INRES_='1280X720' &&
  145. _fullscreenMenu
  146.  
  147. elif [ "$_inRes" = "1080p" ]; then
  148. INRES_='1920X1080' &&
  149. _fullscreenMenu
  150.  
  151. elif [ "$_inRes" = "Custom" ]; then
  152. INRES_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter a value." \
  153. --text="Example: 704X396")
  154. _fullscreenMenu
  155.  
  156. elif [ "$_fullscreenMenu" = "Back" ]; then
  157. _fullscreenMenu
  158. else
  159. exit
  160.  
  161. fi
  162. done
  163. )
  164. # ------------------------------------------------------------------
  165. _outRes ()
  166. (
  167. while true; do
  168. _outRes=$(zenity --width="400" --height="325" --list --column "Option" --column "Description" --title="Please select an input resolution" \
  169. --text "Which input resolution would you like to use $USER?" \
  170. "240p" "Output resolution of 320×240 pixels." \
  171. "360p" "Output resolution of 640×360 pixels." \
  172. "480p" "Output resolution of 720x480 pixels." \
  173. "720p" "Output resolution of 1280x720 pixels." \
  174. "1080p" "Output resolution of 1920x1080 pixels." \
  175. "Custom" "Enter any value for your output resolution." \
  176. "Back")
  177.  
  178. if [ "$_outRes" = "240p" ]; then
  179. OUTRES_='320X240' &&
  180. _fullscreenMenu
  181.  
  182. elif [ "$_outRes" = "360p" ]; then
  183. OUTRES_='640X360' &&
  184. _fullscreenMenu
  185.  
  186. elif [ "$_outRes" = "480p" ]; then
  187. OUTRES_='720X480' &&
  188. _fullscreenMenu
  189.  
  190. elif [ "$_outRes" = "720p" ]; then
  191. OUTRES_='1280X720' &&
  192. _fullscreenMenu
  193.  
  194. elif [ "$_outRes" = "1080p" ]; then
  195. OUTRES_='1920X1080' &&
  196. _fullscreenMenu
  197.  
  198. elif [ "$_outRes" = "Custom" ]; then
  199. OUTRES_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter a value." \
  200. --text="Example: 704X396")
  201. _fullscreenMenu
  202.  
  203. elif [ "$_fullscreenMenu" = "Back" ]; then
  204. _fullscreenMenu
  205. else
  206. exit
  207.  
  208. fi
  209. done
  210. )
  211. # ------------------------------------------------------------------
  212. _selectFPS ()
  213. (
  214. while true; do
  215. _selectFPS=$(zenity --width="400" --height="300" --list --column "Option" --column "Description" --title="Please select your target FPS." \
  216. --text "Please select an option $USER." \
  217. "15" "Set the target FPS to 15." \
  218. "30" "Set the target FPS to 30." \
  219. "60" "Set the target FPS to 60." \
  220. "120" "Set the target FPS to 120." \
  221. "Custom" "Enter any value for the target FPS." \
  222. "Back")
  223.  
  224. if [ "$_selectFPS" = "15" ]; then
  225. FPS_='15' &&
  226. _fullscreenMenu
  227.  
  228. elif [ "$_selectFPS" = "30" ]; then
  229. FPS_='30' &&
  230. _fullscreenMenu
  231.  
  232. elif [ "$_selectFPS" = "60" ]; then
  233. FPS_='60' &&
  234. _fullscreenMenu
  235.  
  236. elif [ "$_selectFPS" = "120" ]; then
  237. FPS_='120' &&
  238. _fullscreenMenu
  239.  
  240. elif [ "$_selectFPS" = "Custom" ]; then
  241. FPS_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter your target FPS." \
  242. --text="Example: 35")
  243. _fullscreenMenu
  244.  
  245. elif [ "$_selectFPS" = "Back" ]; then
  246. _fullscreenMenu
  247.  
  248. else
  249. exit
  250.  
  251. fi
  252. done
  253. )
  254. # ------------------------------------------------------------------
  255. _selectQual ()
  256. (
  257. while true; do
  258. _selectQual=$(zenity --width="475" --height="450" --list --column "Option" --column "Description" --title="Select the FFMPEG preset." \
  259. --text "FFMPEG preset configs for the x264 video encoder." \
  260. "Ultrafast" "Select ultrafast FFMPEG encoder preset." \
  261. "Superfast" "Select superfast FFMPEG encoder preset." \
  262. "Veryfast" "Select veryfast FFMPEG encoder preset." \
  263. "Faster" "Select faster FFMPEG encoder preset." \
  264. "Fast" "Select fast FFMPEG encoder preset." \
  265. "Medium" "Select medium FFMPEG encoder preset." \
  266. "Slow" "Select slow FFMPEG encoder preset." \
  267. "Slower" "Select slower FFMPEG encoder preset." \
  268. "Veryslow" "Select veryslow FFMPEG encoder preset." \
  269. "Custom" "Enter another preset value for the FFMPEG encoder." \
  270. "Back")
  271.  
  272. if [ "$_selectQual" = "Ultrafast" ]; then
  273. QUAL_='ultrafast' &&
  274. _fullscreenMenu
  275.  
  276. elif [ "$_selectQual" = "Superfast" ]; then
  277. QUAL_='superfast' &&
  278. _fullscreenMenu
  279.  
  280. elif [ "$_selectQual" = "Veryfast" ]; then
  281. QUAL_='veryfast' &&
  282. _fullscreenMenu
  283.  
  284. elif [ "$_selectQual" = "Faster" ]; then
  285. QUAL_='faster' &&
  286. _fullscreenMenu
  287.  
  288. elif [ "$_selectQual" = "Fast" ]; then
  289. QUAL_='fast' &&
  290. _fullscreenMenu
  291.  
  292. elif [ "$_selectQual" = "Medium" ]; then
  293. QUAL_='medium' &&
  294. _fullscreenMenu
  295.  
  296. elif [ "$_selectQual" = "Slow" ]; then
  297. QUAL_='slow' &&
  298. _fullscreenMenu
  299.  
  300. elif [ "$_selectQual" = "Slower" ]; then
  301. QUAL_='slower' &&
  302. _fullscreenMenu
  303.  
  304. elif [ "$_selectQual" = "Veryslow" ]; then
  305. QUAL_='veryslow' &&
  306. _fullscreenMenu
  307.  
  308. elif [ "$_selectQual" = "Custom" ]; then
  309. QUAL_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter a FFMPEG preset." \
  310. --text="Example: baseline")
  311. _fullscreenMenu
  312.  
  313. elif [ "$_selectQual" = "Back" ]; then
  314. _fullscreenMenu
  315. else
  316. exit
  317.  
  318. fi
  319. done
  320. )
  321. # ------------------------------------------------------------------
  322. _streamKey ()
  323. {
  324. while true; do
  325.  
  326. _streamKey=$(zenity --width="475" \
  327. --height="210" \
  328. --list --column "Options" --column "Description" --title="Please select an option." \
  329. --text="Choose Your Destiny?" \
  330. "Get Key" "Obtain your streamkey from http://www.justin.tv" \
  331. "Enter" "Enter you Twitch.tv streamkey." \
  332. "Back" "")
  333.  
  334. if [ "$_streamKey" = "Get Key" ]; then
  335. exec firefox http://www.twitch.tv/broadcast
  336.  
  337. elif [ "$_streamKey" = "Enter" ]; then
  338. STREAMKEY_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Please enter your Twitch.tv streamkey." \
  339. --text='Example: live_XXXX_XXXX')
  340. _fullscreenMenu
  341.  
  342. elif [ "$_streamKey" = "Back" ]; then
  343. _fullscreenMenu
  344. else
  345. exit
  346.  
  347. fi
  348. done
  349. }
  350. # ------------------------------------------------------------------
  351. _selectThreads ()
  352. {
  353. THREADS_=$(zenity --width="350" --height="100" --entry --entry-text "" --title="Set the -threads value." \
  354. --text='Example: 2')
  355. _fullscreenMenu
  356. }
  357. # ------------------------------------------------------------------
  358. _startStream ()
  359. {
  360. echo ffmpeg -f x11grab -show_region 1 -s "$INRES_" -r "$FPS_" -i :"$REGION_" -ab 96k -f alsa -ac 2 -i pulse -vcodec libx264 \
  361. -crf 30 -preset "$QUAL_" -s "$OUTRES_" -acodec libmp3lame -ar 44100 -threads "$THREADS_" -f flv "$URL_"
  362. _fullscreenMenu
  363. }
  364. # ------------------------------------------------------------------
  365. _launchMenu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement