Skip to content

Commit 5d1eb8a

Browse files
author
agrandiere
committed
Merge branch 'video-sync'
2 parents f024b9c + eb5e74e commit 5d1eb8a

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,32 @@ $output = $client->check(['nudity', 'type', 'properties', 'wad', 'face'])->set_b
5959
```
6060

6161
# Video and Stream Moderation
62-
The first step to detect nudity in a video stream is to submit the video stream to the API.
62+
63+
You can perform either _synchronous_ or _asynchronous_ Video Moderation.
64+
65+
* 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.
66+
* 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.
67+
68+
## Synchronous Video Moderation
69+
70+
Beware: this is only for videos that have a duration below 1 minute.
6371

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

76+
## Asynchronous Video Moderation
77+
78+
The first step to moderate a video stream is to submit the video stream to the API, along with a callback URL.
79+
80+
```php
81+
$client->check(['nudity', 'wad'])->video('https://sightengine.com/assets/stream/examples/funfair.mp4', 'https://example.com/yourcallback')
82+
```
83+
84+
Once you have submitted the video, the API will start POSTing moderation updates to your callback URL.
85+
86+
Please see our [Documentation](https://sightengine.com/docs) for more details.
87+
6888
# Feedback
6989
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.
7090

src/Check.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,11 @@ public function video($videoUrl, $callbackUrl) {
4141

4242
return json_decode($r->getBody());
4343
}
44+
45+
public function video_sync($videoUrl) {
46+
$url = '1.0/video/check-sync.json';
47+
$r = $this->http->request('GET', $url, ['query' => ['api_user' => $this->api_user, 'api_secret' => $this->api_secret, 'stream_url' => $videoUrl, 'models' => $this->models]]);
48+
49+
return json_decode($r->getBody());
50+
}
4451
}

tests/StackTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,13 @@ public function test_video()
6464

6565
$this->assertEquals('success', $output->status);
6666
}
67+
68+
public function test_video_sync()
69+
{
70+
$client = new SightengineClient('1234', 'test');
71+
$output = $client->check(['nudity','wad','properties','type','faces', 'celebrities'])->video_sync('https://sightengine.com/assets/stream/examples/funfair.mp4');
72+
73+
$this->assertEquals('success', $output->status);
74+
}
6775
}
6876
?>

0 commit comments

Comments
 (0)