-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmagicvideo_transcoder.php
More file actions
92 lines (70 loc) · 2.14 KB
/
magicvideo_transcoder.php
File metadata and controls
92 lines (70 loc) · 2.14 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
require 'aws.phar';
use Aws\ElasticTranscoder\ElasticTranscoderClient;
$aws_elastictranscoder_pipeline = '';
$aws_elastictranscoder_preset_sd = '';
$aws_elastictranscoder_preset_hd = '';
$aws_iam_access_key = '';
$aws_iam_access_secret = '';
$aws_region = '';
$elasticTranscoder = ElasticTranscoderClient::factory([
'key' => $aws_iam_access_key,
'secret' => $aws_iam_access_secret,
'region' => $aws_region ]);
$id = time();
$src_path = 'uploaded/';
$src_file = 'uservideo.mp4';
$dst_path = "encoded/$src_file/$id/";
$jobSetting = [
'PipelineId' => $aws_elastictranscoder_pipeline,
'Input' => [
'Key' => $src_path.$src_file,
'FrameRate' => 'auto',
'Resolution' => 'auto',
'AspectRatio' => 'auto',
'Interlaced' => 'auto',
'Container' => 'auto',
],
'OutputKeyPrefix' => $dst_path,
'Outputs' => [
[
'Key' => 'sd/encoded',
'Rotate' => 'auto',
'PresetId' => $aws_elastictranscoder_preset_sd,
'ThumbnailPattern' => 'sd/encoded_{resolution}_{count}',
'SegmentDuration' => 10,
],
[
'Key' => 'hd/encoded',
'Rotate' => 'auto',
'PresetId' => $aws_elastictranscoder_preset_hd,
'ThumbnailPattern' => 'hd/encoded_{resolution}_{count}',
'SegmentDuration' => 10,
],
],
'Playlists' => [
[
"Format" => "HLSv3",
"Name" => "encoded",
"OutputKeys" => [
'sd/encoded',
'hd/encoded',
]
]
],
'UserMetadata' => [
'Key' => 'Value',
],
];
$job = $elasticTranscoder->createJob($jobSetting);
// get the job data as array
$jobData = $job->get('Job');
// you can save the job ID somewhere, so you can check the status from time to time.
$jobId = $jobData['Id'];
// Checking a jobs status
$response = $elasticTranscoder->readJob( [ 'Id' => $jobId ] );
$jobData = $response->get('Job');
if ($jobData['Status'] !== 'progressing' && $jobData['Status'] !== 'submitted')
{
print_r($jobData);
}