PHPackages                             safestream/safestream-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. safestream/safestream-php-sdk

ActiveLibrary[Image &amp; Media](/categories/media)

safestream/safestream-php-sdk
=============================

PHP SDK for SafeStream: On Demand Video Watermarking

1.2.5(9y ago)41.1k2MITPHP

Since Mar 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/safestream/safestream-php-sdk)[ Packagist](https://packagist.org/packages/safestream/safestream-php-sdk)[ RSS](/packages/safestream-safestream-php-sdk/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (2)Versions (24)Used By (0)

[![SafeStream logo](https://camo.githubusercontent.com/a12dc29da1e604aeeda117e78dfb7e23a7089b32131b1c0b2f23d7d4ea53ea70/68747470733a2f2f7777772e66696c657069636b65722e696f2f6170692f66696c652f346b756235636256524c6d66746554337671464b)](https://camo.githubusercontent.com/a12dc29da1e604aeeda117e78dfb7e23a7089b32131b1c0b2f23d7d4ea53ea70/68747470733a2f2f7777772e66696c657069636b65722e696f2f6170692f66696c652f346b756235636256524c6d66746554337671464b)

Installing the SafeStream SDK
-----------------------------

[](#installing-the-safestream-sdk)

The recommended way to install the SDK is through [Composer](http://getcomposer.org).

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next, run the Composer command to install the latest stable version of Guzzle:

```
composer.phar require safestream/safestream-php-sdk
```

After installing, you need to require Composer's autoloader:

```
require 'vendor/autoload.php';
```

You can then later update the SDK using composer:

```
composer.phar update
```

Getting Started
---------------

[](#getting-started)

#### SafeStreamClient

[](#safestreamclient)

First, you'll need to instantiate a new SafeStreamClient. Through the client, you can access all of SafeStream's functionality. Creating the client is simple.

```
$safeStreamClient = new \SafeStream\SafeStreamClient(["apiKey" => "YOUR API KEY", "clientId" => "YOUR CLIENT ID"]);
```

Some of our API integrations span multiple accounts. The SafeStream API allows a single API key pair to access multiple accounts through the domain ID. If you have multiple accounts you can create the SafeStream client with the domain ID. This way all requests that you make will be within the context of the account you intend them to be. Here's how:

```
$safeStreamClient = new \SafeStream\SafeStreamClient(["apiKey" => "YOUR API KEY", "clientId" => "YOUR CLIENT ID", "domainId" => "YOUR DOMAIN ID"]);
```

#### Videos

[](#videos)

Before SafeStream can watermark your videos you first need create them. When you create a video in SafeStream your video gets downloaded and encoded so it is ready for your future watermarking requests. Creating a video typically takes half of real time. Meaning that a 5 minute video would take 2-3 minutes.

\#####Functions ######create(Video $video, $waitForIngest = 0)

ArgumentTypeDescriptionvideoVideoThe video to be ingestedwaitForIngestlongThe time (in millis) to wait for ingest to complete before returning. Video ingest typically takes approxamately half of realtime. Meaning, a 5 minute video would finish in 2-3 minutes\######createFromSourceUrl($sourceUrl, $waitForIngest = 0)

ArgumentTypeDescriptionsourceUrlstringThe URL of the video to be ingestedwaitForIngestlongThe time (in millis) to wait for ingest to complete before returning. Video ingest typically takes approxamately half of realtime. Meaning, a 5 minute video would finish in 2-3 minutes\######find($svideoKey)

ArgumentTypeDescriptionvideoKeystringThe video key that you gave when creating the video. If no key was given then the key value is the same as the videos sourceUrl##### Examples

[](#examples)

###### Here's a simple example of creating a video:

[](#heres-a-simple-example-of-creating-a-video)

```
$safeStreamClient.video().createFromSourceUrl("https://example.com/my-video.mp4");
```

You can also give your video's custom keys to make it easier to find them later. For example, if you have a video in your own system that you've named "red-carpet-reel-20" you can give SafeStream this key and will store it with the video. This way, you don't have to store SafeStream id's if you don't want to.

###### Here's a simple example of creating a video with a custom key:

[](#heres-a-simple-example-of-creating-a-video-with-a-custom-key)

```
$safeStreamClient.video().create(["sourceUrl" => "https://example.com/my-video.mp4", "key" => "red-carpet-reel-20"]);
```

#### Watermarking Videos

[](#watermarking-videos)

##### Functions

[](#functions)

###### create($videoKey, $watermarkConfiguration, $timeout = 90000)

[](#createvideokey-watermarkconfiguration-timeout--90000)

ArgumentTypeDescriptionvideoKeystringThe video key that you gave when creating the video. If no key was given then the key value is the same as the videos sourceUrlwatermarkConfigurationWatermarkConfiguration OR Array of WatermarkConfigurationSee [Watermark Configuration Properties](#watermark-configuration-properties)timeoutlongTime (in millis) to wait for watermarking to complete. Most watermarking will be complete in &lt; 30 seconds###### createFromTemplate($videoKey, $templateId, $templateMapping, $timeout = 90000)

[](#createfromtemplatevideokey-templateid-templatemapping-timeout--90000)

ArgumentTypeDescriptionvideoKeystringThe video key that you gave when creating the video. If no key was given then the key value is the same as the videos sourceUrltemplateIdstringSee [Watermarking Templates](#watermarking-templates)templateMappingMap (Key / Values)See [Templates](#watermarking-templates)timeoutlongTime (in millis) to wait for watermarking to complete. Most watermarking will be complete in &lt; 30 seconds##### Examples

[](#examples-1)

###### Basic Watermark

[](#basic-watermark)

```
$watermarkConfiguration = new \SafeStream\Watermark\WatermarkConfiguration(["content" => "YOUR NAME"]);
$safeStreamClient->watermark()->create("YOUR VIDEO KEY", $watermarkConfiguration, 90000);
```

###### Watermarking Videos from a Template

[](#watermarking-videos-from-a-template)

Instead of passing in the watermark configuration each time you watermark a video you can use templates. Templates are stored watermark configuration with varible text in the content field. See blah for more on creating templates.

```
$watermarkConfiguration = new \SafeStream\Watermark\WatermarkConfiguration(["content" => "YOUR NAME"]);
$safeStreamClient->watermark()->createFromTemplate("YOUR VIDEO KEY", "TEMPLATE ID", array("first_name", "Joe"));
```

The above example assumes you have a template with a variable place holder, "first\_name" which might look something like:

```
 {
  "settings": [
    {
      "content": "First Name [%first_name%]",
      "horizontalAlignment": "CENTER",
      "verticalAlignment": "MIDDLE",
      "fontColor": "0xffffff",
      "shadowOpacity": 0.1,
      "fontOpacity": 0.3,
      "type": "TEXT",
      "shadowOffsetX": 0.08,
      "fontSize": 0.05,
      "shadowColor": "0x000000",
      "y": 0.5,
      "x": 0.5,
      "shadowOffsetY": 0.08
    }
  ]
}
```

#### Watermark Configuration Properties

[](#watermark-configuration-properties)

NameDescriptioncontentThe text string to watermark onto the video.typeCurrently `TEXT` is supporthorizontalAlignmentSpecifies the horizontal anchor point on the watermark. A value of LEFT will anchor the watermark on it's right most point. A value of RIGHT will anchor the watermark on it's left most pixel. A value of CENTER will anchor the watermark in it's center most pixel.verticalAlignmentSpecifies the vertical anchor point on the watermark. A value of TOP will anchor the watermark on it's top most point. A value of MIDDLE will anchor the watermark on it's middle most pixel. A value of BOTTOM will anchor the watermark in it's bottom most pixel.xThe relative x position of the anchor. The position is relative to the width of the video. So, a video with a width of 1080 and an x value of .5 will put the anchor point at 540 pixels. The anchor position is defined by the horizontal and vertical alignment.yThe relative y position of the anchor. The position is relative to the height of the video. So, a video with a height of 720 and an y value of .5 will put the anchor point at 360 pixels. The anchor position is defined by the horizontal and vertical alignment.fontSizeSize of the watermark text relative to the height of the video. For example, a video with a height of 720 and a font size of .05 will produce a watermark with a text font size of 36.fontOpacityValues from 0 (totally transparent) to 1 (totally opaque)fontColorHex value of font color (ex 0xffffff)shadowOpacityOpacity of the drop shadow of the watermark text. 0 (totally transparent) to 1 (totally opaque)shadowColorHex value of watermark text drop shadow color (ex 0xffffff)shadowOffsetXHorizontal offset of the drop shadowshadowOffsetYVertical offset of the drop shadowanimationConfiguration object for specifying the movement of the watermark. See [Animation](#animation)#### Animation

[](#animation)

Text and image watermarks can be animated to move from one coordinate to another. Adding movement to your watermark is simple. You specify the start and end positions as well as the start and end times for the animation to take place and your done.

##### Examples

[](#examples-2)

###### Moving a text watermark from left to right

[](#moving-a-text-watermark-from-left-to-right)

```
$watermarkConfiguration = new \SafeStream\Watermark\WatermarkConfiguration();
$watermarkConfiguration
    .withContent("YOUR NAME")
    .withX(0.0)
    .withY(0.0)
    .move(1, 0, 0, 20);

$safeStreamClient->watermark()->create("YOUR VIDEO KEY", $watermarkConfiguration, 90000);
```

The above example will move the text "YOUR NAME" across the top of the video over a period of 20 seconds. Breaking the `move` function call down, it will move the text to the x coordiate, 1, and will make no movement along the y axis. It will start at 0 seconds and move to 20 seconds `move(1, 2, 2, 20)`

#### Animation Configuration Properties

[](#animation-configuration-properties)

NameDescriptionxThe x coordinate where the animation should endyThe y coordinate where the animation should endstartTimeThe time that the animation should beginendTimeThe time that the animation should end#### Watermarking Templates

[](#watermarking-templates)

Watermarking templates allow you to store pre-configured watermark settings in SafeStream. This allows you to avoid having to send watermark configurations with each watermarking request. The Templates allow you to set all of the watermark configuration properties but also allow you to set the content field to contain variable content which would be hydrated during subsequent watermark requests.

##### Functions

[](#functions-1)

###### save(Template $template)

[](#savetemplate-template)

ArgumentTypeDescriptiontemplateTemplateThe template to save for future watermarkingtemplateIdstringSee [Watermarking Templates](#watermarking-templates)templateMappingMap (Key / Values)See [Templates](#watermarking-templates)timeoutlongTime (in millis) to wait for watermarking to complete. Most watermarking will be complete in &lt; 30 seconds##### Examples

[](#examples-3)

Creating a new watermarking template:

```
$watermarkConfiguration = new \SafeStream\Watermark\WatermarkConfiguration(["content" => "[%first_name%]"]);
$template = new \SafeStream\Watermark\Template\Template();
$template->addWatermarkConfiguration($watermarkConfiguration);
$safeStreamClient->watermark()->template()->save($template);
```

And then to use if for watermarking:

```
$watermarkClient->watermark()->createFromTemplate("YOUR VIDEO KEY", "YOUR TEMPLATE ID", array("first_name" => "Joe"));
```

Example PHP page
----------------

[](#example-php-page)

```

```

Tests
-----

[](#tests)

```
export SAFESTREAM_CLIENT_ID=YOUR_CLIENT_ID
export SAFESTREAM_API_KEY=YOUR_API_KEY
phpunit tests/SafeStreamClientTests.php

```

##### [License](LICENSE.md)

[](#license)

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 94% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Recently: every ~39 days

Total

23

Last Release

3364d ago

Major Versions

0.1.1 → 1.0.02016-04-01

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1042408?v=4)[Mike Delano](/maintainers/mdelano)[@mdelano](https://github.com/mdelano)

---

Top Contributors

[![mdelano](https://avatars.githubusercontent.com/u/1042408?v=4)](https://github.com/mdelano "mdelano (47 commits)")[![kaipradel](https://avatars.githubusercontent.com/u/2529221?v=4)](https://github.com/kaipradel "kaipradel (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/safestream-safestream-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/safestream-safestream-php-sdk/health.svg)](https://phpackages.com/packages/safestream-safestream-php-sdk)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
