Skip to content

Instantly share code, notes, and snippets.

@streamer45
Created December 27, 2012 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save streamer45/4390335 to your computer and use it in GitHub Desktop.
Save streamer45/4390335 to your computer and use it in GitHub Desktop.
HelloWorld for Krad in Python!
#!/usr/bin/env python
# Hello Krad World Video in Python
from time import sleep
from kradradio_client import Kradradio
# Station name
station_name = "hellokrad"
station = Kradradio(station_name)
# Video resolution and frame rate
width = 640
height = 360
fps = 30
# Video filename
recording = "/home/admin/hello_krad_world.webm"
# Station startup
station.cmd("launch")
# Setting resolution
station.cmd("res "+str(width)+" "+str(height))
# Setting framerate
station.cmd("fps "+str(fps))
# Add Text
station.cmd("addtext 'Hello Krad World' 120 150 0 4 40 0 0 244 2 2 Helvetica")
# Start Recording
station.cmd("record video "+recording)
# Show Text
station.cmd("settext 0 120 150 0 4 40 1 0")
# Wait
sleep(3)
# Fade Text
station.cmd("settext 0 120 150 0 4 40 0 0")
# Wait
sleep(3)
# Shutdown
station.cmd("kill")
from time import sleep
import shlex
import subprocess
KRAD = "krad_radio"
class Kradradio:
def __init__(self, sysname):
self.sysname = sysname
def cmd(self, cmd):
fullcmd = KRAD+" "+self.sysname+" "+cmd
print(fullcmd)
subprocess.call(shlex.split(fullcmd))
sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment