Skip to content

Commit

Permalink
Merge branch 'video-sync'
Browse files Browse the repository at this point in the history
  • Loading branch information
agrandiere committed May 28, 2018
2 parents f024b9c + eb5e74e commit 5d1eb8a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,32 @@ $output = $client->check(['nudity', 'type', 'properties', 'wad', 'face'])->set_b
```

# Video and Stream Moderation
The first step to detect nudity in a video stream is to submit the video stream to the API.

You can perform either _synchronous_ or _asynchronous_ Video Moderation.

* Synchronous Moderation is simple and easy: the Moderation result is provided directly in the reponse to your API request. Synchronous Moderation is only available for videos that are less than 1 minute long.
* Asynchronous Moderation is available for any video or stream. Moderation results are provided through a so-called callback mechanism. You define a callback URL and the Moderation Engine will send back moderation events to that URL in realtime.

## Synchronous Video Moderation

Beware: this is only for videos that have a duration below 1 minute.

```php
$client->check(['nudity', 'wad'])->video('http://www.quirksmode.org/html5/videos/big_buck_bunny.webm', 'https://example.com/yourcallback')
$client->check(['nudity', 'wad'])->video_sync('https://sightengine.com/assets/stream/examples/funfair.mp4')
```

## Asynchronous Video Moderation

The first step to moderate a video stream is to submit the video stream to the API, along with a callback URL.

```php
$client->check(['nudity', 'wad'])->video('https://sightengine.com/assets/stream/examples/funfair.mp4', 'https://example.com/yourcallback')
```

Once you have submitted the video, the API will start POSTing moderation updates to your callback URL.

Please see our [Documentation](https://sightengine.com/docs) for more details.

# Feedback
In order to report a misclassification, you need to report the image that was misclassified, the model that was run on this image (models are nudity, face, type, wad), and the correct class of the image.

Expand Down
7 changes: 7 additions & 0 deletions src/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ public function video($videoUrl, $callbackUrl) {

return json_decode($r->getBody());
}

public function video_sync($videoUrl) {
$url = '1.0/video/check-sync.json';
$r = $this->http->request('GET', $url, ['query' => ['api_user' => $this->api_user, 'api_secret' => $this->api_secret, 'stream_url' => $videoUrl, 'models' => $this->models]]);

return json_decode($r->getBody());
}
}
8 changes: 8 additions & 0 deletions tests/StackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,13 @@ public function test_video()

$this->assertEquals('success', $output->status);
}

public function test_video_sync()
{
$client = new SightengineClient('1234', 'test');
$output = $client->check(['nudity','wad','properties','type','faces', 'celebrities'])->video_sync('https://sightengine.com/assets/stream/examples/funfair.mp4');

$this->assertEquals('success', $output->status);
}
}
?>

0 comments on commit 5d1eb8a

Please sign in to comment.