Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

casparcg-connection

SuperFlyTV17.1kMIT6.3.3TypeScript support: included

Node.js Javascript/Typescript library for CasparCG connection and commands.

casparcg, caspar, amcp, socket, tcp, broadcast, graphics, superfly, connection, middleware, remote

readme

casparcg-connection

GitHub license npm

API Docs Guide

Introduction

CasparCG Server is an open source graphics- and video server for broadcast and streaming productions. This library lets you connect and interact with CasparCG Servers from Node.js in Javascript. This library is also a part of the Sofie TV News Studio Automation System.

Features

  • CasparCG AMCP 2.3 protocol implemented
  • CasparCG AMCP 2.1 protocol largely implemented
  • Parsing of command parameters and response
  • Queueing of commands
  • Promise-based commands for easy chaining and sequences

Project

  • Node.js
  • npm package
  • TypeScript, strongly typed
  • ES2020 target
  • Linted with standard ESLint rules
  • API Docs
  • MIT license

Getting started

Installing with NPM

npm install casparcg-connection --save

This installs the full project with sourcecode and dependencies, typescript project files and the compiled .js output with typings.

In your code, include and use the CasparCG object from this library with a code similar to:

const { CasparCG } = require('casparcg-connection')

const connection = new CasparCG()
const { error, request } = await connection.play({ channel: 1, layer: 1, clip: 'amb' })
if (error) {
    console.log('Error when sending', error)
} else {
    const response = await request
    console.log(response)
}

Note: as of 6.0.0 the library has had a major rewrite with significant API changes and support for CasparCG 2.0 was dropped.

Build from source

Installing with yarn adds the dev-dependencies needed to compile TypeScript. A set of commands help you managing development and testing:

  • yarn clean Empties the /dist directory.
  • yarn build Runs a single build command without watching for changes.
  • yarn build -w Rebuilds on every change.
  • yarn lint Runs code linting. Pull Requests won't be accepted without lint compliance.
  • yarn test Runs code tests through Jest.

Doing a release

  • Run yarn changelog to generate the changelog, tags and commit.
  • Push these changes and the newly made tag.
  • Trigger a run of the Publish to NPM workflow in GitHub Actions.

Documentation

Visit https://superflytv.github.io/casparcg-connection/ for API documentation.

About

Created and published by SuperFly.tv

Acknowledgements:

changelog

Changelog

All notable changes to this project will be documented in this file. See Convential Commits for commit guidelines.

6.3.3 (Tue Nov 11 2025)

6.3.2 (Tue Nov 11 2025)

Fixes

  • CgUpdateParameters should support Record<string, any> | string 3d70e01f

6.3.1 (Thu May 22 2025)

Fixes

6.3.0 (Tue Jul 30 2024)

Features

6.2.1 (Thu Feb 01 2024)

Fixes

  • mixer tween parameters #199 (#200) cd573113

6.2.0 (Tue Jan 02 2024)

Fixes

Features

6.1.1 (Tue Oct 17 2023)

Fixes

  • bug fix in INFO CHANNEL deserializer 985417bd

6.1.0 (Mon Oct 16 2023)

Features

  • add INFO Config deserializer 9af33b11
  • add separate commands for INFO, INFO channel and INFO channel-layer, and handle return data properly 19997ce9
  • Add strict types for the deserialized return-data of some of the commands f1c67b4d

Fixes

  • set all default return-data to be unknown instead of undefined 7622c142

6.0.6 (Thu Oct 05 2023)

Fixes

  • aFilter and vFilter serialized incorrectly SOFIE-2706 0765fed5

6.0.5 (Tue Oct 03 2023)

6.0.4 (Tue Oct 03 2023)

Fixes

  • receiving fragmented message gets stuck SOFIE-2680 (#188) 15739ae7
  • allow lenght of 0 02d082da

6.0.3 (Wed May 03 2023)

Fixes

  • cgAdd didn't serialize data properly 60790958
  • make some parameters optional 23d3de2d

6.0.2 (Wed Mar 22 2023)

Fixes

6.0.1 (Thu Feb 16 2023)

Fixes

  • multi-token PLAY/LOADBG commands serialize incorrectly 2b1bc0cb

6.0.0 (Fri Nov 11 2022)

Breaking changes

Features

Fixes

Features

5.1.0 (2020-11-16)

Features

  • add ffmpeg filter options (1b81653)

5.0.1 (2020-09-29)

5.0.0 (2020-09-29)

⚠ BREAKING CHANGES

  • drop node 8 support

Features

  • drop node 8 support (44f6dae)
  • ci: use prerelease flow & optionally skip audit [skip ci] (bd32ef1)
  • update ci to run for node 8,10,12 (8e1de30)

4.9.0 (2019-11-18)

Features

  • clear_on_404 parameter for PLAY/LOAD/LOADBG (b8f0bd6)
  • FRAMES_DELAY parameter for PLAY/LOAD/LOADBG route (bceabce)

4.8.1 (2019-11-07)

4.8.0 (2019-11-07)

Bug Fixes

Features

  • call: Adds SEEK support to call (bad75ae), closes #5
  • sting audio fade parameters (9c64a9e)

4.7.0 (2019-04-11)

Bug Fixes

  • Validator: refactor of PositiveNumberValidatorBetween (1d6f41e)

Features

  • call: adds all ffmpeg producer calls (2edbe9d)
  • call: Adds SEEK support to call (1704912), closes #5
  • add support for IN property in PLAY command (9e059be)

4.6.1 (2019-01-15)

4.6.0 (2018-12-12)

Bug Fixes

  • add back overloads for play methods (40b12b4)

Features

  • channel_layout property (c66fcfb)

4.5.3 (2018-10-03)

Bug Fixes

  • sting: stingOverlayFilename can be the empty string (afe1143)

4.5.2 (2018-09-24)

4.5.1 (2018-09-11)

Bug Fixes

  • validation of transition paramters (d128f98)

4.5.0 (2018-08-14)

Features

4.4.0 (2018-08-07)

Bug Fixes

  • Commands: Rejects promise on invalid command (8632c79)

Features

  • Commands: Better promise handling with fallback to empty promises instead of mixing promise and null handling (8400194)

4.3.1 (2018-08-02)

Bug Fixes

  • Time command takes timecode parameter (858e2a4)

4.3.0 (2018-08-02)

Features

4.2.2 (2018-07-02)

Bug Fixes

  • use 'new' keyword instead of Object.create (27c6055)

4.2.1 (2018-07-02)

4.2.0 (2018-06-28)

Bug Fixes

  • refactor package.json, add circleCI badge and correct ssh fingerprint (37c5377)
  • ts lint errors (84e830c)
  • typescrit imrovements (3b8634e)

Features

  • initial convert to circleci (842de38)

4.1.1 (2018-06-27)

Bug Fixes

  • don't set queueMode on uninitialized socket (c6a8b06)

4.1.0 (2018-05-22)

4.0.3 (2018-05-07)

4.0.2 (2018-05-04)

4.0.1 (2018-04-29)

Bug Fixes

  • TemplateData): PR from Craig Sweaton escaping \r\n from template data. Prevents breaking the AMCP communication.

4.0.0 (2018-04-10)

Features

  • Asynchronous commands: refactor the internal command execution (7b10d43)
  • QueueMode: allow runtime configuration (f39f7ea)
  • Scheduled Commands: keep sequential mode for compatibility (48a760f)
  • Scheduled Commands: schedule and resolve scheduled commands (5a9f0fb)

BREAKING CHANGES

  • set default queue mode to SALVO, making the library fully asynchronous.

3.1.0 (2018-03-28)

Features

  • Add/Remove Commands: Merge branch 'Besedin86/master' into develop (ca772e6)

3.0.2 (2018-03-27)

Bug Fixes

  • CGAddCommand: playOnLoad is required (3fc9300), closes #93

3.0.1 (2017-10-22)

Bug Fixes

  • MixerCommands: Corrected copy/paste errors for several mixer commands, related to transitions. (29bc5a5), closes #89

3.0.0 (2017-10-16)

Bug Fixes

  • TemplateData: Correct double escaping of quotes xml strings (5bda229)

3.0.0-next.4 (2017-10-03)

Bug Fixes

  • Config: Correct cross-version-import between configVOs (bdcedfd)
  • onConnection: Bug with promise resolve and queue conducting on initial connection (4504cb9)

3.0.0-next.3 (2017-07-31)

Bug Fixes

  • Socket: Fixed bug with disposing socket clients before they are created (7a0a510)

3.0.0-next.2 (2017-07-24)

3.0.0-next.1 (2017-07-20)

Features

  • VirginServer: Report server's virgin-state on connected events (a8f3b61)

3.0.0-next.0 (2017-07-20)

Bug Fixes

  • Command: Critical error with command timeouts (6caeacb)
  • Config: Bugfix with manual operations parsing config XML (e80117b)
  • Events: Critical bug introduced in v1.0.0 (7dcd9fe)
  • Logging: Better handling of errors (d80c794)
  • Socket: Prevents timeout of extremely long responses (613c629)
  • Socket: Removed unused internal event (5eb343c)
  • Version: bugfix for setting manuel ServerVersion (8362a22)

Code Refactoring

  • Enum: Changed the public enum ServerVersion (b7aadea)

Features

  • Command: Planned for better timeout retry strategy (b0b5f19)
  • Config: Added members "vo" and "xml" as aliases to "VO" and "XML" on Config objects (65dffde)
  • Queue: Added prioritized queues (929e4ad), closes #15
  • Version: Added version promise to CasparCG (554ea41), closes #73

BREAKING CHANGES

  • Enum: enum ServerVersion is now CasparCGVersion, for consistency.

2.1.0 (2017-07-18)

Bug Fixes

  • CasparCG Connection events (a825a18)

Features

  • Commands: Better command timeout strategy (bd51c31)
  • Socket: (Re)connection strategy (3d04e5f), closes #66
  • Socket: Reconnection (90ca334)

2.0.3 (2017-07-12)

Bug Fixes

2.0.2 (2017-07-12)

2.0.1 (2017-07-12)

2.0.0 (2017-07-12)

Bug Fixes

BREAKING CHANGES

  • Reverted ES6 target back to ES5 due to Meteor compability

1.0.0 (2017-07-12)

build

Features

BREAKING CHANGES

  • build target ES2015 (ES6). This required Node.js version 6.4.0 or higher to fully function.

0.17.2 (2017-06-18)

Bug Fixes