2017 © Pedro Peláez
 

library caspar-cg

CasparCG PHP Library

image

cosmonova-rnd/caspar-cg

CasparCG PHP Library

  • Thursday, February 22, 2018
  • by Besedin86
  • Repository
  • 1 Watchers
  • 1 Stars
  • 37 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 12 % Grown

The README.md

CasparCG PHP Library

Is an implementation of CasparCG 2.0 AMCP Protocol and OSC Protocol, (*1)

Requirements

  • CasparCG v2.0.7|v2.3.0
  • PHP 7.0

Installation

Install using Composer, (*2)

php composer.phar require cosmonova-rnd/caspar-cg, (*3)

Usage

AMCP

The easiest way to use AMCP protocol is to send handwritten command through Caspar CG connection, (*4)

$client = new \CosmonovaRnD\CasparCG\Client();

$response = $client->send('play 1-1 test');

if($response->success()) {
    echo 'OK';
} else {
    echo 'Failed';
}

But you can use one of existing command builders., (*5)

For example, we want to send play content 'test' on channel 1 and layer 10 in loop, (*6)

$client = new \CosmonovaRnD\CasparCG\Client();

$playCmdBuilder = new \CosmonovaRnD\CasparCG\Command\Basic\Builder\PlayBuilder();
$playCmdBuilder->channel(1);
$playCmdBuilder->layer(10);
$playCmdBuilder->clip('test');
$playCmdBuilder->loop();

$response = $client->send($playCmdBuilder->build());

if($response->success()) {
    echo 'OK';
} else {
    echo 'Failed';
}

OSC

OSC works over the UDP protocol., (*7)

I'll try to show how to catch messages in small simple example, (*8)


$server = new \CosmonovaRnD\CasparCG\Server('127.0.0.1', 6250); $server->start(); $parser = new \CosmonovaRnD\CasparCG\OSC\Parser(); // You can use simple built-in event manager to handle messages $eventManager = new \CosmonovaRnD\CasparCG\EventManager(); $listener = new MyTestFrameMsgListener(); // Must implement \CosmonovaRnD\CasparCG\ListenerInterface // Listen all \CosmonovaRnD\CasparCG\OSC\Message\Producer\FFmpeg\Frame messages $eventManager->listen(\CosmonovaRnD\CasparCG\OSC\Message\Producer\FFmpeg\Frame::class, $listener); while (false !== $msg = $server->read()) { $rawMsg = $parser->parse($msg); if ($rawMsg instanceof Bundle) { foreach ($rawMsg->getMessages() as $bundleMsg) { \CosmonovaRnD\CasparCG\OSC\Message\Producer\FFmpeg\Frame::create($bundleMsg, $eventManager); } } else { \CosmonovaRnD\CasparCG\OSC\Message\Producer\FFmpeg\Frame::create($rawMsg, $eventManager); } } $server->stop();

The Versions

22/02 2018

dev-master

9999999-dev

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

22/02 2018

v1.0.0

1.0.0.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

16/11 2017

v0.3.1

0.3.1.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

13/10 2017

v0.3.0

0.3.0.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

13/10 2017

v0.2.2

0.2.2.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

10/10 2017

v0.2.1

0.2.1.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

10/10 2017

v0.2.0

0.2.0.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

01/08 2017

v0.1.2

0.1.2.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

31/07 2017

v0.1.1

0.1.1.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

25/07 2017

v0.1.0

0.1.0.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

24/07 2017

v0.0.4

0.0.4.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

24/07 2017

v0.0.3

0.0.3.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

20/07 2017

v0.0.2

0.0.2.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin

19/07 2017

v0.0.1

0.0.1.0

CasparCG PHP Library

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Aleksandr Besedin