Completed
Push — master ( d0121a...036b67 )
by Nicolas
02:10
created
src/activities/transcoders/AudioTranscoder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/BasicTranscoder.php';
3
+require_once __DIR__.'/BasicTranscoder.php';
4 4
 
5 5
 class AudioTranscoder extends BasicTranscoder
6 6
 {
Please login to merge, or discard this patch.
src/activities/TranscodeAssetActivity.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -281,7 +281,7 @@
 block discarded – undo
281 281
 // Usage
282 282
 function usage()
283 283
 {
284
-    echo("Usage: php ". basename(__FILE__) . " -A <Snf ARN> [-C <client class path>] [-N <activity name>] [-h] [-d] [-l <log path>]\n");
284
+    echo("Usage: php ".basename(__FILE__)." -A <Snf ARN> [-C <client class path>] [-N <activity name>] [-h] [-d] [-l <log path>]\n");
285 285
     echo("-h: Print this help\n");
286 286
     echo("-d: Debug mode\n");
287 287
     echo("-l <log_path>: Location where logs will be dumped in (folder).\n");
Please login to merge, or discard this patch.
src/activities/transcoders/VideoTranscoder.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 23
  */
24 24
 
25
-require_once __DIR__ . '/BasicTranscoder.php';
25
+require_once __DIR__.'/BasicTranscoder.php';
26 26
 
27 27
 use SA\CpeSdk;
28 28
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $this->cpeLogger->logOut(
85 85
                 "INFO",
86 86
                 basename(__FILE__),
87
-                "Input Video metadata: " . print_r($metadata, true),
87
+                "Input Video metadata: ".print_r($metadata, true),
88 88
                 $this->logKey
89 89
             );
90 90
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             $this->cpeLogger->logOut(
171 171
                 "ERROR",
172 172
                 basename(__FILE__),
173
-                "Execution of command '".$ffmpegCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(),
173
+                "Execution of command '".$ffmpegCmd."' failed: ".print_r($metadata, true).". ".$e->getMessage(),
174 174
                 $this->logKey
175 175
             );
176 176
             throw $e;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         }
217 217
 
218 218
         // Append output filename to path
219
-        $outputFilesPath .= "/" . $outputWanted->{'output_file_info'}['basename'];
219
+        $outputFilesPath .= "/".$outputWanted->{'output_file_info'}['basename'];
220 220
         // Replace ${output_file} by output filename and path to local disk
221 221
         $ffmpegCmd = preg_replace('/\$\{output_file\}/', $outputFilesPath, $ffmpegCmd);
222 222
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         }
277 277
 
278 278
         // Create FFMpeg arguments
279
-        $ffmpegArgs =  " -i $inputFilePath -y -threads 0";
279
+        $ffmpegArgs = " -i $inputFilePath -y -threads 0";
280 280
         $ffmpegArgs .= " -vf scale=$size";
281 281
         $ffmpegArgs .= " -vcodec $videoCodec";
282 282
         $ffmpegArgs .= " -acodec $audioCodec";
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
         $ffmpegArgs .= " $watermarkOptions";
288 288
 
289 289
         // Append output filename to path
290
-        $outputFilesPath .= "/" . $outputWanted->{'output_file_info'}['basename'];
290
+        $outputFilesPath .= "/".$outputWanted->{'output_file_info'}['basename'];
291 291
         // Final command
292
-        $ffmpegCmd  = "ffmpeg $ffmpegArgs $outputFilesPath";
292
+        $ffmpegCmd = "ffmpeg $ffmpegArgs $outputFilesPath";
293 293
 
294 294
         return ($ffmpegCmd);
295 295
     }
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
                 $snapshot_sec = $outputWanted->{'snapshot_sec'};
317 317
             }
318 318
 
319
-            $time = gmdate("H:i:s", $snapshot_sec) . ".000";
320
-            $outputFilesPath .= "/" . $outputFileInfo['basename'];
319
+            $time = gmdate("H:i:s", $snapshot_sec).".000";
320
+            $outputFilesPath .= "/".$outputFileInfo['basename'];
321 321
             $frameOptions = " -ss $time -vframes 1";
322 322
         }
323 323
         else if ($outputWanted->{'mode'} == 'intervals')
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
                 $intervals = $outputWanted->{'intervals'};
329 329
             }
330 330
 
331
-            $outputFilesPath .= "/" . $outputFileInfo['filename'] . "%06d."
331
+            $outputFilesPath .= "/".$outputFileInfo['filename']."%06d."
332 332
                              . $outputFileInfo['extension'];
333 333
             $frameOptions = " -vf fps=fps=1/$intervals";
334 334
         }
335 335
 
336 336
         // Create FFMpeg arguments
337
-        $ffmpegArgs  =  " -i $inputFilePath -y -threads 0";
338
-        $ffmpegArgs .= " -vf scale=" . $outputWanted->{'size'};
337
+        $ffmpegArgs  = " -i $inputFilePath -y -threads 0";
338
+        $ffmpegArgs .= " -vf scale=".$outputWanted->{'size'};
339 339
         $ffmpegArgs .= " $frameOptions -f image2 -q:v 8";
340 340
 
341 341
         // Final command
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                                  $this->logKey);
367 367
 
368 368
         // Transform watermark for opacity
369
-        $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply " . $watermarkOptions->{'opacity'} . " +channel $newWatermarkPath";
369
+        $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply ".$watermarkOptions->{'opacity'}." +channel $newWatermarkPath";
370 370
 
371 371
         try {
372 372
             $out = $this->executer->execute($convertCmd, 1,
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         // Format options for FFMpeg
396 396
         $size      = $watermarkOptions->{'size'};
397 397
         $positions = $this->get_watermark_position($watermarkOptions);
398
-        $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=" . $positions['x'] . ':' . $positions['y'] . " [out]\"";
398
+        $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=".$positions['x'].':'.$positions['y']." [out]\"";
399 399
 
400 400
         return ($formattedOptions);
401 401
     }
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
             $positions['y'] = $watermarkOptions->{'y'};
413 413
         }
414 414
         if ($watermarkOptions->{'x'} < 0) {
415
-            $positions['x'] = 'main_w-overlay_w' . $watermarkOptions->{'x'};
415
+            $positions['x'] = 'main_w-overlay_w'.$watermarkOptions->{'x'};
416 416
         }
417 417
         if ($watermarkOptions->{'y'} < 0) {
418
-            $positions['y'] = 'main_h-overlay_h' . $watermarkOptions->{'y'};
418
+            $positions['y'] = 'main_h-overlay_h'.$watermarkOptions->{'y'};
419 419
         }
420 420
 
421 421
         return ($positions);
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             }
491 491
         }
492 492
 
493
-        return (str_replace("x",":", $size));
493
+        return (str_replace("x", ":", $size));
494 494
     }
495 495
 
496 496
     // REad ffmpeg output and calculate % progress
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 
525 525
         // # finally, progress is easy
526 526
         if ($done && $duration) {
527
-            $progress = round(($done/$duration)*100);
527
+            $progress = round(($done / $duration) * 100);
528 528
         }
529 529
 
530 530
         $this->cpeLogger->logOut(
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
         }
560 560
 
561 561
         $preset     = $output_wanted->{"preset"};
562
-        $presetPath = __DIR__ . '/../../../presets/';
562
+        $presetPath = __DIR__.'/../../../presets/';
563 563
 
564 564
         if (!($presetContent = file_get_contents($presetPath.$preset.".json"))) {
565 565
             throw new CpeSdk\CpeException("Can't open preset file !",
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
         }
584 584
 
585 585
         $preset     = $output->{"preset"};
586
-        $presetPath = __DIR__ . '/../../../presets/';
586
+        $presetPath = __DIR__.'/../../../presets/';
587 587
 
588 588
         if (!($files = scandir($presetPath))) {
589 589
             throw new CpeSdk\CpeException("Unable to open preset directory '$presetPath' !",
@@ -633,22 +633,22 @@  discard block
 block discarded – undo
633 633
         }
634 634
 
635 635
         $analyse = [
636
-            'duration' => isset($metadata->format->duration) ? (float)$metadata->format->duration : 0,
636
+            'duration' => isset($metadata->format->duration) ? (float) $metadata->format->duration : 0,
637 637
             'video' => empty($videoStreams) ? null : [
638 638
                 'codec' => $videoStreams->codec_name,
639 639
                 'color' => @$videoStreams->color_space,
640
-                'resolution' => $videoStreams->width . 'x' . $videoStreams->height,
640
+                'resolution' => $videoStreams->width.'x'.$videoStreams->height,
641 641
                 'sar' => $videoStreams->sample_aspect_ratio,
642 642
                 'dar' => $videoStreams->display_aspect_ratio,
643 643
                 'framerate' => $videoStreams->r_frame_rate,
644
-                'bitrate' => isset($videoStreams->bit_rate) ? (int)$videoStreams->bit_rate : null
644
+                'bitrate' => isset($videoStreams->bit_rate) ? (int) $videoStreams->bit_rate : null
645 645
             ],
646 646
             'audio' => empty($audioStreams) ? null : [
647 647
                 'codec' => $audioStreams->codec_name,
648 648
                 'frequency' => $audioStreams->sample_rate,
649
-                'channels' => (int)$audioStreams->channels,
649
+                'channels' => (int) $audioStreams->channels,
650 650
                 'depth' => $audioStreams->bits_per_sample,
651
-                'bitrate' => (int)$audioStreams->bit_rate
651
+                'bitrate' => (int) $audioStreams->bit_rate
652 652
             ]
653 653
         ];
654 654
 
Please login to merge, or discard this patch.
src/activities/transcoders/BasicTranscoder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
 class BasicTranscoder 
30 30
 {
31 31
     public $activityObj; // Calling activity object
32
-    public $task;        // Activity TASK
33
-    public $logKey;      // Valling activity loggin key
32
+    public $task; // Activity TASK
33
+    public $logKey; // Valling activity loggin key
34 34
 
35
-    public $cpeLogger;   // Logger
36
-    public $s3Utils;     // Used to manipulate S3
37
-    public $executer;    // Executer obj
35
+    public $cpeLogger; // Logger
36
+    public $s3Utils; // Used to manipulate S3
37
+    public $executer; // Executer obj
38 38
 
39 39
     const EXEC_VALIDATE_FAILED  = "EXEC_VALIDATE_FAILED";
40 40
     const TRANSCODE_FAIL        = "TRANSCODE_FAIL";
Please login to merge, or discard this patch.
src/activities/transcoders/ImageTranscoder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             $this->cpeLogger->logOut(
59 59
                 "INFO", 
60 60
                 basename(__FILE__), 
61
-                "Input Video metadata: " . print_r($metadata, true),
61
+                "Input Video metadata: ".print_r($metadata, true),
62 62
                 $this->activityLogKey
63 63
             );
64 64
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             $this->cpeLogger->logOut(
133 133
                 "ERROR", 
134 134
                 basename(__FILE__), 
135
-                "Execution of command '".$convertCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(),
135
+                "Execution of command '".$convertCmd."' failed: ".print_r($metadata, true).". ".$e->getMessage(),
136 136
                 $this->activityLogKey
137 137
             );
138 138
             return false;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         
185 185
         // Append output filename to path
186 186
         $pathToOutputFiles .=
187
-            "/" . $outputWanted->{'output_file_info'}['basename'];
187
+            "/".$outputWanted->{'output_file_info'}['basename'];
188 188
         
189 189
         $convertCmd = "convert $convertArgs $pathToOutputFiles";
190 190
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             $pathToInputFile, $convertCmd);
208 208
 
209 209
         // Append output filename to path
210
-        $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename'];
210
+        $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename'];
211 211
         // Replace ${output_file} by output filename and path to local disk
212 212
         $convertCmd = preg_replace('/\$\{output_file\}/',
213 213
             $pathToOutputFiles, $convertCmd);
Please login to merge, or discard this patch.
src/activities/ValidateAssetActivity.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
         static $limit = 1024; // 500 bytes, it's only a test
54 54
         
55 55
         $len = strlen($this->curl_data) + strlen($chunk);
56
-        if ($len >= $limit ) {
57
-            $this->curl_data .= substr($chunk, 0, $limit-strlen($this->curl_data));
56
+        if ($len >= $limit) {
57
+            $this->curl_data .= substr($chunk, 0, $limit - strlen($this->curl_data));
58 58
             return -1;
59 59
         }
60 60
         
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 // Usage
170 170
 function usage()
171 171
 {
172
-    echo("Usage: php ". basename(__FILE__) . " -A <Snf ARN> [-C <client class path>] [-N <activity name>] [-h] [-d] [-l <log path>]\n");
172
+    echo("Usage: php ".basename(__FILE__)." -A <Snf ARN> [-C <client class path>] [-N <activity name>] [-h] [-d] [-l <log path>]\n");
173 173
     echo("-h: Print this help\n");
174 174
     echo("-d: Debug mode\n");
175 175
     echo("-l <log_path>: Location where logs will be dumped in (folder).\n");
Please login to merge, or discard this patch.
src/activities/BasicActivity.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 
28 28
 class BasicActivity extends CpeSdk\CpeActivity
29 29
 {
30
-    public $tmpInputPath;    // Path to directory containing TMP file
31
-    public $inputFilePath;   // Path to input file locally
32
-    public $s3Utils;         // Used to manipulate S3. Download/Upload
30
+    public $tmpInputPath; // Path to directory containing TMP file
31
+    public $inputFilePath; // Path to input file locally
32
+    public $s3Utils; // Used to manipulate S3. Download/Upload
33 33
   
34 34
     // Constants
35 35
     const TMP_FOLDER_FAIL      = "TMP_FOLDER_FAIL";
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         if (isset($this->input->{'input_asset'}->{'http'}))
93 93
         {
94 94
             // Pad HTTP input so it is cached in case of full encodes
95
-            $this->inputFilePath = 'cache:' . $this->input->{'input_asset'}->{'http'};
95
+            $this->inputFilePath = 'cache:'.$this->input->{'input_asset'}->{'http'};
96 96
         }
97 97
         else if (isset($this->input->{'input_asset'}->{'bucket'}) &&
98 98
                  isset($this->input->{'input_asset'}->{'file'}))
Please login to merge, or discard this patch.
src/scripts/putInS3.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  * Script used to put a file in AWS S3
5 5
  **/
6 6
 
7
-require __DIR__ . "/../../vendor/autoload.php";
7
+require __DIR__."/../../vendor/autoload.php";
8 8
 
9 9
 function usage()
10 10
 {
11
-    echo("Usage: php ". basename(__FILE__) . " [-h] [--rrs::] [--encrypt::] --bucket <s3 bucket> --file <filename> --from <filepath>\n");
11
+    echo("Usage: php ".basename(__FILE__)." [-h] [--rrs::] [--encrypt::] --bucket <s3 bucket> --file <filename> --from <filepath>\n");
12 12
     echo("--help, -h: Print this help\n");
13 13
     echo("--bucket <s3 bucket>: Name of the S3 bucket\n");
14 14
     echo("--file <filename>: Name of the file to create in bucket. You can override local filename.\n");
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         usage();
32 32
     }
33 33
 
34
-    $options['bucket'] = rtrim( $options['bucket'], "/");
34
+    $options['bucket'] = rtrim($options['bucket'], "/");
35 35
 }
36 36
 
37 37
 $options = getopt("h", [
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
     $s3->putObject($params); 
72 72
     
73 73
     // Print JSON error output
74
-    print json_encode([ "status" => "SUCCESS",
75
-            "msg" => "[".__FILE__."] Upload '" . $options['from'] . "' to '" . $options['bucket'] . "/" . $options['file']  . "' successful !" ]);
74
+    print json_encode(["status" => "SUCCESS",
75
+            "msg" => "[".__FILE__."] Upload '".$options['from']."' to '".$options['bucket']."/".$options['file']."' successful !"]);
76 76
 } 
77 77
 catch (Exception $e) {
78
-    $err = "Unable to put file '" . $options['from']  . "' into S3: '" . $options['bucket'] . "/" . $options['file']  . "'! " . $e->getMessage();
78
+    $err = "Unable to put file '".$options['from']."' into S3: '".$options['bucket']."/".$options['file']."'! ".$e->getMessage();
79 79
     
80 80
     // Print JSON error output
81
-    print json_encode([ "status" => "ERROR",
82
-            "msg" => "[".__FILE__."] $err" ]);
81
+    print json_encode(["status" => "ERROR",
82
+            "msg" => "[".__FILE__."] $err"]);
83 83
 
84 84
     die("[".__FILE__."] $err");
85 85
 }
Please login to merge, or discard this patch.
src/scripts/getFromS3.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  * Script used to get a file in AWS S3
5 5
  **/
6 6
 
7
-require __DIR__ . "/../../vendor/autoload.php";
7
+require __DIR__."/../../vendor/autoload.php";
8 8
 
9 9
 function usage()
10 10
 {
11
-    echo("Usage: php ". basename(__FILE__) . " [-h] [--force] --bucket <s3 bucket> --file <filename> --to <filepath>\n");
11
+    echo("Usage: php ".basename(__FILE__)." [-h] [--force] --bucket <s3 bucket> --file <filename> --to <filepath>\n");
12 12
     echo("--help, -h: Print this help\n");
13 13
     echo("--bucket <s3 bucket>: Name of the S3 bucket\n");
14 14
     echo("--file <filename>: Name of the file in the S3 bucket\n");
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
     file_exists($options['to']) &&
37 37
     filesize($options['to']))
38 38
 {
39
-    $out = [ "status" => "SUCCESS",
40
-             "msg" => "[".__FILE__."] Using local copy: '" . $options['to']  . "'" ];
39
+    $out = ["status" => "SUCCESS",
40
+             "msg" => "[".__FILE__."] Using local copy: '".$options['to']."'"];
41 41
     print json_encode($out)."\n";
42 42
     exit(0);
43 43
 }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     'SaveAs' => $options['to']
60 60
 ));
61 61
 
62
-$out = [ "status" => "SUCCESS",
63
-         "msg" => "[".__FILE__."] Download '" . $options['bucket'] . "/" . $options['file'] . "' successful !" ];
62
+$out = ["status" => "SUCCESS",
63
+         "msg" => "[".__FILE__."] Download '".$options['bucket']."/".$options['file']."' successful !"];
64 64
 
65 65
 print json_encode($out)."\n";
Please login to merge, or discard this patch.