Now playing title and up next at ##:##:## script for obs

Mitchstein443

New Member
So I've been running a 24/7 streaming channel under vmix for ell over 8 years now. I just made the switch over to OBS.

For the record, I have exactly 72 hours of running OBS so far, but feel it is stable enough to do what I need it to do. The one rule of thumb for ny complex mission critical software package is DEDICATED SERVER! WHat I mean is, if your running OBS on a computer that also runs editing software, a bunch of other stuff and your using it to play games or daily net browsing, your simply doing it wrong. a computer nd 90% of the software out there will run perfectly if it is the only software your running.. in my 45+ years of computer experience I have always said "one mission, one computer".

With that being said.

I am running OBS now, it's working perfectly on a 2019 windows server, 8 core xenon processor, cheap onboard video card and has no sound card (which is why vmix won't run on it, but OBS has no problem).

So I had a powershell script for vmix that puts a title at the bottom of the screen showing the title NOW PLAYING and a title at the top of the screen that Shows a clock and UP NEXT at ##:##:##... the clock is to show the viewer te servers time since everyone is not in my time zone, lol..

Anyway it's using the built in lua clock script and tuna as addins..

and then this powershell script. I'll also post a screen shot that shows the sources.
you can view the channel at www.tvbydemand.com and no the website is not modernized I wrote it completely in classic asp back in 1992 long before anyone else was streaming video and other then some graphics has ot really been modernized much but works great and has been since 1992. So don't going acting like it won't work, it does and has proven itself to work better longer then most people have been on the web..

Here is the script:

while($foreverloop -lt 9999)
{

cls
$xmlurl = "http://127.0.0.1"+":1607"

#get current tile and info and save as current.txt
$data = (New-Object System.Net.WebClient).DownloadString($xmlurl)
Out-File -FilePath c:\livetv\current.txt -InputObject $data -Encoding ASCII



#inport contents of current.txt to variables
$duration = (Get-Content -Path c:\livetv\current.txt -TotalCount 2)[-1]
$progress = (Get-Content -Path c:\livetv\current.txt -TotalCount 3)[-1]
$status = (Get-Content -Path c:\livetv\current.txt -TotalCount 4)[-1]
$time_left = (Get-Content -Path c:\livetv\current.txt -TotalCount 5)[-1]
$titlepath = (Get-Content -Path c:\livetv\current.txt -TotalCount 6)[-1]

#cleanup variables end

$duration = $duration.TrimEnd(",")
$progress = $progress.TrimEnd(",")
$status = $status.TrimEnd(""",")
$time_left = $time_left.TrimEnd(",")
$titlepath = $titlepath.TrimEnd("""")

#cleanup variables start

$duration = $duration.TrimStart("""duration"": ")
$progress = $progress.TrimStart("""progress"": ")
$status = $status.TrimStart("""status"": """)
$time_left = $time_left.TrimStart("""time_left"": ")
$titlepath = $titlepath.TrimStart("""title"": """)

#just get title name
$title = Split-Path $titlePath -leaf

$title = $title.Substring(0,$title.Length-4) #removes the extension i.e. .mp4

#write title to file
$a = $title
If ($a.Length -gt 70) {

$b = $a.length - 70
$a = $a.Substring(0,$a.Length-$b)
}

Out-File -FilePath c:\livetv\nowplaying.txt -InputObject $a -Encoding ASCII

#figureout time left in time not milliseconds
$EpochStart = Get-Date 00:00:00
$myDateTime = $EpochStart.Addmilliseconds($time_left)

$seconds_left = [math]::Round($time_left/1000)
$minutes_left = [math]::Round(($time_left/1000)/60)
$hours_left = [math]::Round((($time_left/1000)/60)/60)


$d=Get-Date
$next_time = $d.AddSeconds($seconds_left)
$next_time = Get-Date -Date $next_time -Format "hh:mm:ss"



#find curent file in the playlist and read the next line
$titlepath1 = ($titlepath).Replace("\\","\")

[System.IO.StreamReader]$sr = [System.IO.File]::Open("c:\livetv\filelist.m3u8", [System.IO.FileMode]::Open)
while (-not $sr.EndOfStream){
$line = $sr.ReadLine()

If ($line -eq $titlepath1) {

$nextline = $sr.ReadLine()

}
}
$sr.Close()

#trim $nextline down to jut the title
$nexttitle = Split-Path $nextline -leaf
$nexttitle = $nexttitle.Substring(0,$nexttitle.Length-4) #removes the extension i.e. .mp4

#updte upnext file
$up_next_line1 = "Up Next @" + $next_time
Out-File -FilePath c:\livetv\upnext.txt -InputObject $up_next_line1 -Encoding ASCII
Out-File -FilePath c:\livetv\upnext.txt -InputObject $nexttitle -Encoding ASCII -Append

Write-Host $duration
Write-Host $progress
Write-Host $status
Write-Host $time_left
Write-Host $titlepath
Write-Host $title
Write-Host seconds = $seconds_left
write-host minutes left $minutes_left
write-host hours left $hours_left
write-host net time = $next_time
write-host next title = $nexttitle

sleep 5
}

:end of script

obs2.JPG
 

Attachments

  • obs2.JPG
    obs2.JPG
    147.4 KB · Views: 50

Mitchstein443

New Member
I hope this can help some people. if there are any questions send me a pm I'll help you out as best i can.. The more people getting onboard streaming the longer we can continue to have free streams, eventully the big corporations will shut us out, but if we hve big enough numbers it will take them that much longer!!
 

Mitchstein443

New Member
Now I am trying to figure out where the api is and how to use it to create sources, switch sources/scenes etc etc etc.. if anyone knows of a quick tutorial please let me know.. as I said, OBS newbie, streaming expert though and long time programmer.. anything I write I will post and never chrge anyone for it.
 

bcoyle

Member
Wow! I went to your site and was blown away. I can read enough of your code to see that you have a m3u8 playlist, that you ingest. Do you have an editor for that. Anyway, I'm writing a 24/7 unattended broadcast tv app. I was a producer at our local public access tv station before it got defunded. I inherited all the local historical content and decide to do my own station. I was a longtime programmer and started programming in 1970 on minicomputers (Hewlett Packard). Ah the days of paper tape and teletypes.

You seemed a little stressed about big Corps taking over. Anyway, here is a couple of my test outputs from my program. Thought you might enjoy them. One is just a bunch of trailers and one is a Lucy show.

https://www.youtube.com/watch?v=g27skiQ075E <- trailers
https://www.youtube.com/watch?v=z7pN53v0HJM <- lucy show
 

bcoyle

Member
Now I am trying to figure out where the api is and how to use it to create sources, switch sources/scenes etc etc etc.. if anyone knows of a quick tutorial please let me know.. as I said, OBS newbie, streaming expert though and long time programmer.. anything I write I will post and never chrge anyone for it.
Basically there is a websocket-obs that is a plugin that listens and has an api connecting into obs. This is what I use. There are also a bunch of command line apps avaialble also.

Here is the url for github - and this websocket.:
 

Mitchstein443

New Member
Basically there is a websocket-obs that is a plugin that listens and has an api connecting into obs. This is what I use. There are also a bunch of command line apps avaialble also.

Here is the url for github - and this websocket.:
Ok, I loaded the websocket into OBS. I am at at a loss though on how to communicate with it.
I tried using firefox http://pasword@127.0.0.1:4444 I get a a blank screen..
http://pasword@127.0.0.1:4444/version also returns a blank screen and I read somewhere version was a keyword..
How do you communicate with it?
I've spent severl hours scouring around and can not even find a place to start, like some docs or examples or even a keyword list. seems I'm just running aroud in circles finding nothing but other peoples addons for websockets and nothing on how it actually works..
 

bcoyle

Member
Talking to obs requires that you send it json strings like so:

1618011590369.png

Sort of like xml. {"request-type":"version","message-id":"3025"} would probable get you the version. All obs commands start with {"request-type":"something in the api"}. It is case sensitive .The commands come in pairs with a colon in between Pairs and a comma separating pairs groups. Answers are returned in the same json format. The commans are in the websocket-obs api.
 
Last edited:

bcoyle

Member
For example: here is an api command:
SetFilenameFormatting
  • Added in v4.3.0
Set the filename formatting string

Request Fields:

Name
Type​
Description
filename-formatting
String
Filename formatting string to set.
Response Items:



You would send
{"request-type":"SetFilenameFormatting", "filename-formatting":" The request"}

you would get back

{"status" : "ok"} or something similar

hope that helps
 
Top