Scheduling KiPro recording using Apple iCal

The pressure towards automation in our industry is a constant which beats at a more rapid pace every day. It is now a part of every broadcast facility on the planet. Whenever there is more to do with less people, scheduling of recorded content can be advantageous. Small market stations often times cannot afford complex automation systems. Larger market facility has some form of scheduling available, adding additional channels to expensive embedded systems can be cost prohibitive for special events or temporary ingest expansion.

AJA’s KiPro professional video recorder is an ideal tool for handling manual capture and playback. However, AJA has provided an API to allow other products to control the KiPro, so enabling automation is capable out of the box. Whether it is capturing multi-cam ISO feeds for special events or simply adding additional expansion, it can easily record video feeds directly to Apple ProRes to be immediately copied to central storage or edited directly from the record drive.

Apple’s iCal calendar software is a cost effective way to accomplish this task as it comes with very basic script tools and is included free of charge with every version of MacOS X dating all the way back to the beginning. The user interface is simple and can be understood by untrained operators.

Apple’s iCal software has the capability to run Applescripts using its “alarm” function. This workflow involves saving very simple one line Applescripts (two scripts per KiPro, one for stop, one for record) as well as one primary host script that interacts with the KiPro via the *nix CLI application cURL. This is just one example of control automation using the KiPro.

Below is a basic overview of the process in action.

Lets break down how to write our primary shell script.

#!/bin/sh

#grab the IP or DNS name of our KiPro as the first CLI argument
mykipro=$1

#grab the transport command as the first CLI argument
transport=$2

#define what to set our transport command to if "start" is selected
if [ $transport = "start" ]; then
	trigger=3
fi

#define what to set our transport command to if "stop" is selected
if [ $transport = "stop" ]; then
	trigger=4
fi

#set the value of our transport command for our cURL command
valuestring="newValue=$trigger"

#set the KiPro function to be transport control
paramstring="paramName=eParamID_TransportCommand"

#run cURL
# -s makes for silent output
# -d allows us to use HTTP POST commands to send individual fields

/usr/bin/curl -s -d $paramstring -d $valuestring http://$mykipro/options

We can save this script anywhere on our system, I’d recommend /usr/local/bin, /Library/Scripts, /usr/local/scripts. I have called this script kipro_trigger. We need to make sure it is executable.

shell> chmod +x /path/to/script/kipro_trigger

We can save this script anywhere on our system, I’d recommend /usr/local/bin, /Library/Scripts, /usr/local/scripts. I have called this script kipro_trigger. We need to make sure it is executable.

shell> /path/to/script/kipro_trigger ip.of.my.kipro start

and

shell> /path/to/script/kipro_trigger ip.of.my.kipro stop

If all is working, we should be starting/stopping our KiPro records each time we run this tool.

Now we need to set up our Applescripts so iCal can be used to trigger our KiPro. We are going to create two one-line Applescripts per KiPro we want to use. Since iCal has no way to include variables in its alarm options, we need to hardcode one script for record and one script for stop for each KiPro we want to use. For this example, my IP address is 192.168.3.168 and my script is /usr/local/scripts/kipro_trigger

Start script:

do shell script "/usr/local/scripts/kipro_trigger 192.168.3.168 start"

Stop script:

do shell script "/usr/local/scripts/kipro_trigger 192.168.3.168 stop"

Save as many script pairs as necessary into /Library/Scripts/Applescript.

Name them based on your KiPro naming. If the system at 192.168.3.168 is called “News”, name your scripts “News Start” and “News Stop”. In this example, my system is simply called “KiPro”, but we can save as many script pairs as we have KiPros.

The last step is setting up iCal to call these scripts for your scheduled timeframe. We need to make a new event in our calendar for the name of the recording we want to do. Set our from/to time to the event time and then add two alarms to the event. First alarm should “Run Script” for our Start event and should be set “on date” to the same time as the start date. Second alarm should “Run Script” for our Stop event and be set to “on date” for the end time.

The first script we ran could be used with any scheduling toolkit as well, including Apple’s launchd or linux cron. Since the software to run this scheduler is fairly light weight, just about any Macintosh system running OS X with a network connection will work, enabling re-use of aging systems and providing budget efficiencies while adding functionality to the plant.

Currently the scripts do not return any information regarding clip naming, so you will have to look at create dates/modified dates on the files and line them up to your scheduled records.