-
-
Save onekopaka/f7ae14372fcdc64d627aca0eae40d878 to your computer and use it in GitHub Desktop.
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/ruby | |
| require 'net/http' | |
| # Streamer thing originally made for streaming Stargate. | |
| epsSource = Array.new | |
| #playlistFile = "stargate-sg1-playlist-plain.txt" | |
| playlistFile = "stargate-playlist.txt" | |
| File.open(playlistFile, "r").readlines.each do |line| | |
| epsSource.push(line[0..line.length-2]) | |
| end | |
| epsPool = epsSource.shuffle | |
| numEps = epsPool.length | |
| running = true | |
| while running do | |
| currentEpisode = epsPool.pop | |
| if currentEpisode != nil | |
| matchData = /(Stargate [a-zA-Z\-0-9]+ .+) - (.+)\.avi$/.match(currentEpisode) | |
| showAndEpisode = matchData[1] | |
| episodeName = matchData[2] | |
| matchData = /(Stargate [a-zA-Z\-0-9]+ .+)\.avi$/.match(currentEpisode) | |
| titlePart = matchData[1] | |
| titleToSet = "24/7 Stargate Stream | " + titlePart | |
| Net::HTTP.post_form(URI('http://172.16.3.18/custom-streams-player/update_title.php'), | |
| 'streamkey' => 'testsg', 'streamsecret' => 'CENSORED', 'streamtitle' => titleToSet) | |
| puts "Starting to play " + currentEpisode | |
| # Run ffmpeg | |
| system 'ffmpeg -re -i "' + currentEpisode + '" -f flv -ac 2 -ar 44100 -acodec aac -vcodec libx264 -g 50 -keyint_min 25 -b:a 128k -b:v 1100k -minrate 500k -maxrate 1200k -pix_fmt yuv420p -preset veryfast -tune film -threads 2 -strict experimental -bufsize 1300k "rtmp://172.16.3.18/live/testsg"' | |
| # ffmpeg completed. | |
| puts "Finished playing " + currentEpisode | |
| else | |
| open('streamer-restarts.txt', 'a') do |f| | |
| f.puts "Streamer has reached end of playlist at " + Time.now.asctime | |
| end | |
| epsPool = epsSource.shuffle | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment