Remocon API, enterprise documentation
Welcome to our enterprise documentation. It's best if you reach out to us directly so we can work together to implement your solution.
You will need:
- an API key from your account on https://remocon.tv, going forward <api_key> is to be replaced with your API key
Streaming video to Remocon service:
Video can be streamed to the service using ffmpeg to our https://stream.remocon.tv server
ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 \
-f mpegts -codec:v mpeg1video -s 640x480 -b:v 1000k -bf 0 \
https://stream.remocon.tv/<api_key>
Controlling devices from Remocon service:
Commands come through websockets, so just open a websocket connection to our https://control.remocon.tv server with your API key in the domain and wait for input. We also use the json package to help parse the data.
import websockets # for web sockets
import asyncio
import json # sending data in json format lets us send as much data
# as we want and in any order
apiKey = "<api_key>"
domain = "ws://control.remocon.tv/"
async def connectSocket():
url = domain+apiKey
async with websockets.connect(url) as websocket:
print('websocket connected to ' + url)
while True:
input = await websocket.recv()
try:
interpretData(input)
except:
pass
def interpretData(message):
print(message) # comment this out if you don't want to see every single message
data = json.loads(message)
if (data["type"] == 'keydown' and data["key"] == 87):
print('w key pressed')
# add what you want to be done when the w key is pressed
elif (data["type"] == 'keyup' and data["key"] == 87):
print('w key released')
# add what you want to be done when the w key is released
elif (data["type"] == 'keydown' and data["key"] == 83):
print('s key pressed')
# add what you want to be done when the w key is pressed
elif (data["type"] == 'keyup' and data["key"] == 83):
print('s key released')
# add what you want to be done when the w key is released
asyncio.get_event_loop().run_until_complete(connectSocket())
asyncio.get_event_loop().run_forever()
Why is this on Neocities rather than on some other documentation site?
It's because it's very easy to use and FOSS and ideologically good.
Last edited on 2021-01-21