Completed
Push — master ( 07decf...816d2c )
by Nicolas
02:19
created
src/activities/BasicActivity.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             isset($this->input->{'input_asset'}->{'file'}))
103 103
         {
104 104
             // Make pre-signed URL so ffmpeg has access to file
105
-            $this->pathToInputFile = 'cache:' .
105
+            $this->pathToInputFile = 'cache:'.
106 106
                 $this->s3->getCommand('GetObject', [
107 107
                     'Bucket' => $this->input->{'input_asset'}->{'bucket'},
108 108
                     'Key' => $this->input->{'input_asset'}->{'file'}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         else if ($this->input->{'input_asset'}->{'http'})
112 112
         {
113 113
             // Pad HTTP input so it is cached in case of full encodes
114
-            $this->pathToInputFile = 'cache:' . $this->input->{'input_asset'}->{'http'};
114
+            $this->pathToInputFile = 'cache:'.$this->input->{'input_asset'}->{'http'};
115 115
         }
116 116
     }
117 117
     
Please login to merge, or discard this patch.
src/activities/ValidateAssetActivity.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
         $tmpFile = tempname(sys_get_temp_dir(), 'ct');
49 49
         file_put_contents($tmpFile, $obj['Body']);
50 50
         $mime = trim((new CommandExecuter($this->cpeLogger))->execute(
51
-            'file -b --mime-type ' . escapeshellarg($tmpFile))['out']);
51
+            'file -b --mime-type '.escapeshellarg($tmpFile))['out']);
52 52
         $type = substr($mime, 0, strpos($mime, '/'));
53 53
 
54 54
         $this->cpeLogger->log_out(
Please login to merge, or discard this patch.
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/transcoders/VideoTranscoder.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * We use ffprobe, ffmpeg and convert to analyse, transcode and manipulate videos and images (watermark)
8 8
  */
9 9
 
10
-require_once __DIR__ . '/BasicTranscoder.php';
10
+require_once __DIR__.'/BasicTranscoder.php';
11 11
 
12 12
 use SA\CpeSdk;
13 13
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             $this->cpeLogger->log_out(
102 102
                 "INFO", 
103 103
                 basename(__FILE__), 
104
-                "Input Video metadata: " . print_r($metadata, true),
104
+                "Input Video metadata: ".print_r($metadata, true),
105 105
                 $this->activityLogKey
106 106
             );
107 107
         
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             $this->cpeLogger->log_out(
139 139
                 "ERROR", 
140 140
                 basename(__FILE__), 
141
-                "Execution of command '".$ffmpegCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(),
141
+                "Execution of command '".$ffmpegCmd."' failed: ".print_r($metadata, true).". ".$e->getMessage(),
142 142
                 $this->activityLogKey
143 143
             );
144 144
             return false;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         }
182 182
         
183 183
         // Append output filename to path
184
-        $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename'];
184
+        $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename'];
185 185
         // Replace ${output_file} by output filename and path to local disk
186 186
         $ffmpegCmd = preg_replace('/\$\{output_file\}/', $pathToOutputFiles, $ffmpegCmd);
187 187
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         }
242 242
         
243 243
         // Create FFMpeg arguments
244
-        $ffmpegArgs =  " -i $pathToInputFile -y -threads 0";
244
+        $ffmpegArgs = " -i $pathToInputFile -y -threads 0";
245 245
         $ffmpegArgs .= " -s $size";
246 246
         $ffmpegArgs .= " -vcodec $videoCodec";
247 247
         $ffmpegArgs .= " -acodec $audioCodec";
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
         $ffmpegArgs .= " $watermarkOptions";
253 253
         
254 254
         // Append output filename to path
255
-        $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename'];
255
+        $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename'];
256 256
         // Final command
257
-        $ffmpegCmd  = "ffmpeg $ffmpegArgs $pathToOutputFiles";
257
+        $ffmpegCmd = "ffmpeg $ffmpegArgs $pathToOutputFiles";
258 258
             
259 259
         return ($ffmpegCmd);
260 260
     }
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
                 $snapshot_sec = $outputWanted->{'snapshot_sec'};
282 282
             }
283 283
                 
284
-            $time = gmdate("H:i:s", $snapshot_sec) . ".000";
285
-            $pathToOutputFiles .= "/" . $outputFileInfo['basename'];
284
+            $time = gmdate("H:i:s", $snapshot_sec).".000";
285
+            $pathToOutputFiles .= "/".$outputFileInfo['basename'];
286 286
             $frameOptions = " -ss $time -vframes 1";
287 287
         }
288 288
         else if ($outputWanted->{'mode'} == 'intervals')
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
                 $intervals = $outputWanted->{'intervals'};
294 294
             }
295 295
             
296
-            $pathToOutputFiles .= "/" . $outputFileInfo['filename'] . "%06d." 
296
+            $pathToOutputFiles .= "/".$outputFileInfo['filename']."%06d." 
297 297
                 . $outputFileInfo['extension'];
298 298
             $frameOptions = " -vf fps=fps=1/$intervals";
299 299
         }
300 300
 
301 301
         // Create FFMpeg arguments
302
-        $ffmpegArgs  =  " -i $pathToInputFile -y -threads 0";
303
-        $ffmpegArgs .= " -vf scale=" . $outputWanted->{'size'};
302
+        $ffmpegArgs  = " -i $pathToInputFile -y -threads 0";
303
+        $ffmpegArgs .= " -vf scale=".$outputWanted->{'size'};
304 304
         $ffmpegArgs .= " $frameOptions -f image2 -q:v 8";
305 305
 
306 306
         // Final command
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
             $this->activityLogKey);
332 332
 
333 333
         // Transform watermark for opacity
334
-        $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply " . $watermarkOptions->{'opacity'} . " +channel $newWatermarkPath";
334
+        $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply ".$watermarkOptions->{'opacity'}." +channel $newWatermarkPath";
335 335
 
336 336
         try {
337 337
             $out = $this->executer->execute($convertCmd, 1, 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
         // Format options for FFMpeg
361 361
         $size      = $watermarkOptions->{'size'};
362 362
         $positions = $this->get_watermark_position($watermarkOptions);
363
-        $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=" . $positions['x'] . ':' . $positions['y'] . " [out]\"";
363
+        $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=".$positions['x'].':'.$positions['y']." [out]\"";
364 364
         
365 365
         return ($formattedOptions);
366 366
     }
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
             $positions['y'] = $watermarkOptions->{'y'};
378 378
         }
379 379
         if ($watermarkOptions->{'x'} < 0) {
380
-            $positions['x'] = 'main_w-overlay_w' . $watermarkOptions->{'x'};
380
+            $positions['x'] = 'main_w-overlay_w'.$watermarkOptions->{'x'};
381 381
         }
382 382
         if ($watermarkOptions->{'y'} < 0) {
383
-            $positions['y'] = 'main_h-overlay_h' . $watermarkOptions->{'y'};
383
+            $positions['y'] = 'main_h-overlay_h'.$watermarkOptions->{'y'};
384 384
         }
385 385
 
386 386
         return ($positions);
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         // # finally, progress is easy
488 488
         $progress = 0;
489 489
         if ($done) {
490
-            $progress = round(($done/$duration)*100);
490
+            $progress = round(($done / $duration) * 100);
491 491
         }
492 492
         
493 493
         $this->cpeLogger->log_out(
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         }
523 523
         
524 524
         $preset     = $output_wanted->{"preset"};
525
-        $presetPath = __DIR__ . '/../../../presets/';
525
+        $presetPath = __DIR__.'/../../../presets/';
526 526
 
527 527
         if (!($presetContent = file_get_contents($presetPath.$preset.".json"))) {
528 528
             throw new CpeSdk\CpeException("Can't open preset file !",
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
         }
547 547
 
548 548
         $preset     = $output->{"preset"};
549
-        $presetPath = __DIR__ . '/../../../presets/';
549
+        $presetPath = __DIR__.'/../../../presets/';
550 550
         
551 551
         if (!($files = scandir($presetPath))) {
552 552
             throw new CpeSdk\CpeException("Unable to open preset directory '$presetPath' !",
Please login to merge, or discard this patch.
src/scripts/getFromS3.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  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
 use Aws\S3\S3Client;
10 10
 
11 11
 function usage()
12 12
 {
13
-    echo("Usage: php ". basename(__FILE__) . " [-h] [--force] --bucket <s3 bucket> --file <filename> --to <filepath>\n");
13
+    echo("Usage: php ".basename(__FILE__)." [-h] [--force] --bucket <s3 bucket> --file <filename> --to <filepath>\n");
14 14
     echo("--help, -h: Print this help\n");
15 15
     echo("--bucket <s3 bucket>: Name of the S3 bucket\n");
16 16
     echo("--file <filename>: Name of the file in the S3 bucket\n");
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
     file_exists($options['to']) &&
42 42
     filesize($options['to']))
43 43
 {
44
-    print json_encode([ "status" => "SUCCESS",
45
-            "msg" => "[".__FILE__."] Using local copy: '" . $options['to']  . "'" ]);
44
+    print json_encode(["status" => "SUCCESS",
45
+            "msg" => "[".__FILE__."] Using local copy: '".$options['to']."'"]);
46 46
     exit(0);
47 47
 }
48 48
 
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
         ));
59 59
 
60 60
     // Print JSON error output
61
-    print json_encode([ "status" => "SUCCESS",
62
-            "msg" => "[".__FILE__."] Download '" . $options['bucket'] . "/" . $options['file'] . "' successful !" ]);
61
+    print json_encode(["status" => "SUCCESS",
62
+            "msg" => "[".__FILE__."] Download '".$options['bucket']."/".$options['file']."' successful !"]);
63 63
 } 
64 64
 catch (Exception $e) {
65
-    $err = "Unable to get '" . $options['bucket'] . "/" . $options['file'] . "' file from S3 ! " . $e->getMessage();
65
+    $err = "Unable to get '".$options['bucket']."/".$options['file']."' file from S3 ! ".$e->getMessage();
66 66
     // Print JSON error output
67
-    print json_encode([ "status" => "ERROR",
68
-            "msg" => "[".__FILE__."] $err" ]);
67
+    print json_encode(["status" => "ERROR",
68
+            "msg" => "[".__FILE__."] $err"]);
69 69
     
70 70
     die("[".__FILE__."] $err");
71 71
 }
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,13 +4,13 @@  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
 use Aws\S3\S3Client;
10 10
 
11 11
 function usage()
12 12
 {
13
-    echo("Usage: php ". basename(__FILE__) . " [-h] [--rrs::] [--encrypt::] --bucket <s3 bucket> --file <filename> --from <filepath>\n");
13
+    echo("Usage: php ".basename(__FILE__)." [-h] [--rrs::] [--encrypt::] --bucket <s3 bucket> --file <filename> --from <filepath>\n");
14 14
     echo("--help, -h: Print this help\n");
15 15
     echo("--bucket <s3 bucket>: Name of the S3 bucket\n");
16 16
     echo("--file <filename>: Name of the file to create in bucket. You can override local filename.\n");
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         usage();
34 34
     }
35 35
 
36
-    $options['bucket'] = rtrim( $options['bucket'], "/");
36
+    $options['bucket'] = rtrim($options['bucket'], "/");
37 37
 }
38 38
 
39 39
 $options = getopt("h", [
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
     $s3->putObject($params); 
67 67
     
68 68
     // Print JSON error output
69
-    print json_encode([ "status" => "SUCCESS",
70
-            "msg" => "[".__FILE__."] Upload '" . $options['from'] . "' to '" . $options['bucket'] . "/" . $options['file']  . "' successful !" ]);
69
+    print json_encode(["status" => "SUCCESS",
70
+            "msg" => "[".__FILE__."] Upload '".$options['from']."' to '".$options['bucket']."/".$options['file']."' successful !"]);
71 71
 } 
72 72
 catch (Exception $e) {
73
-    $err = "Unable to put file '" . $options['from']  . "' into S3: '" . $options['bucket'] . "/" . $options['file']  . "'! " . $e->getMessage();
73
+    $err = "Unable to put file '".$options['from']."' into S3: '".$options['bucket']."/".$options['file']."'! ".$e->getMessage();
74 74
     
75 75
     // Print JSON error output
76
-    print json_encode([ "status" => "ERROR",
77
-            "msg" => "[".__FILE__."] $err" ]);
76
+    print json_encode(["status" => "ERROR",
77
+            "msg" => "[".__FILE__."] $err"]);
78 78
 
79 79
     die("[".__FILE__."] $err");
80 80
 }
Please login to merge, or discard this patch.
src/utils/S3Utils.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * The scripts are executed using the CommandExecuter
6 6
   */
7 7
 
8
-require_once __DIR__ . '/CommandExecuter.php';
8
+require_once __DIR__.'/CommandExecuter.php';
9 9
 
10 10
 use SA\CpeSdk;
11 11
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $callback = null, 
36 36
         $callbackParams = null)
37 37
     {   
38
-        $cmd = "php " . __DIR__ . self::GET_FROM_S3;
38
+        $cmd = "php ".__DIR__.self::GET_FROM_S3;
39 39
         $cmd .= " --bucket $bucket";
40 40
         $cmd .= " --file $filename";
41 41
         $cmd .= " --to $saveFileTo";
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $callback = null, 
58 58
         $callbackParams = null)
59 59
     {
60
-        $cmd  = "php " . __DIR__ . self::PUT_IN_S3;
60
+        $cmd  = "php ".__DIR__.self::PUT_IN_S3;
61 61
         $cmd .= " --bucket $bucket";
62 62
         $cmd .= " --file $filename";
63 63
         $cmd .= " --from $pathToFileToSend";
Please login to merge, or discard this patch.