forked from muxinc/mux-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingest.php
26 lines (19 loc) · 893 Bytes
/
ingest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
require_once 'vendor/autoload.php';
// Authentication Setup
$config = MuxPhp\Configuration::getDefaultConfiguration()
->setUsername(getenv('MUX_TOKEN_ID'))
->setPassword(getenv('MUX_TOKEN_SECRET'));
// API Client Initialization
$assetsApi = new MuxPhp\Api\AssetsApi(
new GuzzleHttp\Client(),
$config
);
// Create Asset Request
$input = new MuxPhp\Models\InputSettings(["url" => "https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4"]);
$createAssetRequest = new MuxPhp\Models\CreateAssetRequest(["input" => $input, "playback_policy" => [MuxPhp\Models\PlaybackPolicy::PUBLIC_PLAYBACK_POLICY] ]);
// Ingest
$result = $assetsApi->createAsset($createAssetRequest);
// Print URL
print "Playback URL: https://stream.mux.com/" . $result->getData()->getPlaybackIds()[0]->getId() . ".m3u8\n"
?>