Skip to content

Commit 65cff8a

Browse files
authored
Merge pull request #43 from Capstone-Projects-2023-Spring/obs29
added stream function and boot.sh to launch obs
2 parents f6411cc + 30ba3f0 commit 65cff8a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Raspberry Pi/boot.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MESA_GL_VERSION_OVERRIDE=3.3 obs &
2+
sleep 5
3+
python stream.py

Raspberry Pi/stream.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import logging
2+
logging.basicConfig(level=logging.DEBUG)
3+
import asyncio
4+
import simpleobsws
5+
6+
7+
def stream(server, key):
8+
parameters = simpleobsws.IdentificationParameters(ignoreNonFatalRequestChecks = False) # Create an IdentificationParameters object (optional for connecting)
9+
10+
ws = simpleobsws.WebSocketClient(url = 'ws://localhost:4455', password = 'NaIf6BF33LEjtpgY', identification_parameters = parameters) # Every possible argument has been passed, but none are required. See lib code for defaults.
11+
12+
async def make_request():
13+
await ws.connect() # Make the connection to obs-websocket
14+
await ws.wait_until_identified() # Wait for the identification handshake to complete
15+
#set stream url and key
16+
rdata = {
17+
"streamServiceType" : "rtmp_custom",
18+
"streamServiceSettings" : {
19+
"server" : str(server),
20+
"key" : str(key),
21+
}
22+
}
23+
request = simpleobsws.Request(requestType='SetStreamServiceSettings', requestData=rdata) # Build a Request object
24+
25+
ret = await ws.call(request) # Perform the request
26+
if ret.ok(): # Check if the request succeeded
27+
print("Request succeeded! Response data: {}".format(ret.responseData))
28+
#start stream
29+
request = simpleobsws.Request(requestType='StartStream') # Build a Request object
30+
ret = await ws.call(request) # Perform the request
31+
if ret.ok(): # Check if the request succeeded
32+
print("Request succeeded! Response data: {}".format(ret.responseData))
33+
await ws.disconnect() # Disconnect from the websocket server cleanly
34+
35+
loop = asyncio.get_event_loop()
36+
loop.run_until_complete(make_request())
37+
38+
stream("rtmps://1958e2d97d88.global-contribute.live-video.net:443/app/", "sk_us-east-1_tD4nNlTH1VCn_sqAmVP50G6GaafLWIrB4zfl8tvaFnv")

0 commit comments

Comments
 (0)