Casparcg-connection documentation or examples

Hi, there!
I have one noob question regrading casparcg-connection library. I’m trying to make some simple web client and can’t find any documentation how to use this library. There is an example in github and it works fine for playing video:{ channel: 1, layer: 1, clip: ‘amb’ })

I’ve tried to copy this for cgAdd but I’m missing one parameter:

casparCG.cgAdd({ channel: 1, layer: 20, ???, template: “template” });

Can anybody share some info about this? Also how to send some data to casparcg server using casparcg-connection?

You need to add these as well:

cgLayer: 1,
playOnLoad: true

I’ve got a PR open so we’ll probably make those optional in a later version to make it easier to use.

1 Like

To answer myself about sending data using casparcg-connection, it might be useful for someone who like me is not a programmer. :slight_smile:

const { CasparCG } = require("casparcg-connection");
casparCG = new CasparCG();

let title = "ljubanve";
let subtitle = "UMP";

let data = `"<templateData><componentData id=\\"f0\\"><data id=\\"text\\" value=\\"${title}\\"/></componentData><componentData id=\\"f1\\"><data id=\\"text\\" value=\\"${subtitle}\\"/></componentData></templateData>"`
    channel: 1,
    layer: 22,
    cgLayer: 1,
    template: "your_template_name",
    playOnLoad: true,

In this example your app is going to send a command to CasparCG that will play graphic template on layer 22.
Template filename is: your_template_name and if it is not in the root folder then it should look like this: “folder/your_template_name”.

Data is the text value that you want to send to CasparCG and in this example I’m using f0 and f1 to assign title and subtitle. You should define title and subtitle first or use some text input.

Hope this helps someone.

Privacy Policy   Terms of Service