Completed
Pull Request — master (#57)
by
unknown
01:56
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/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.
src/activities/transcoders/ImageTranscoder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             $this->cpeLogger->log_out(
45 45
                 "INFO", 
46 46
                 basename(__FILE__), 
47
-                "Input Video metadata: " . print_r($metadata, true),
47
+                "Input Video metadata: ".print_r($metadata, true),
48 48
                 $this->activityLogKey
49 49
             );
50 50
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $this->cpeLogger->log_out(
118 118
                 "ERROR", 
119 119
                 basename(__FILE__), 
120
-                "Execution of command '".$convertCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(),
120
+                "Execution of command '".$convertCmd."' failed: ".print_r($metadata, true).". ".$e->getMessage(),
121 121
                 $this->activityLogKey
122 122
             );
123 123
             return false;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         
162 162
         // Append output filename to path
163 163
         $pathToOutputFiles .=
164
-            "/" . $outputWanted->{'output_file_info'}['basename'];
164
+            "/".$outputWanted->{'output_file_info'}['basename'];
165 165
         
166 166
         $convertCmd = "convert $convertArgs $pathToOutputFiles";
167 167
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
             $pathToInputFile, $convertCmd);
185 185
 
186 186
         // Append output filename to path
187
-        $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename'];
187
+        $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename'];
188 188
         // Replace ${output_file} by output filename and path to local disk
189 189
         $convertCmd = preg_replace('/\$\{output_file\}/',
190 190
             $pathToOutputFiles, $convertCmd);
Please login to merge, or discard this patch.
src/activities/BasicActivity.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@
 block discarded – undo
109 109
         else if (isset($this->input->{'input_asset'}->{'http'}))
110 110
         {
111 111
             // Pad HTTP input so it is cached in case of full encodes
112
-            $this->pathToInputFile = 'cache:' . $this->input->{'input_asset'}->{'http'};
112
+            $this->pathToInputFile = 'cache:'.$this->input->{'input_asset'}->{'http'};
113 113
         }
114 114
     }
115 115
     
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
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
         // Determine file type
52 52
         file_put_contents($tmpFile, (string) $obj['Body']);
53 53
         $mime = trim((new CommandExecuter($this->cpeLogger))->execute(
54
-                'file -b --mime-type ' . escapeshellarg($tmpFile))['out']);
54
+                'file -b --mime-type '.escapeshellarg($tmpFile))['out']);
55 55
         $type = substr($mime, 0, strpos($mime, '/'));
56 56
 
57 57
         $this->cpeLogger->log_out(
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
@@ -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
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             $this->cpeLogger->log_out(
70 70
                 "INFO", 
71 71
                 basename(__FILE__), 
72
-                "Input Video metadata: " . print_r($metadata, true),
72
+                "Input Video metadata: ".print_r($metadata, true),
73 73
                 $this->activityLogKey
74 74
             );
75 75
         
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             $this->cpeLogger->log_out(
144 144
                 "ERROR", 
145 145
                 basename(__FILE__), 
146
-                "Execution of command '".$ffmpegCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(),
146
+                "Execution of command '".$ffmpegCmd."' failed: ".print_r($metadata, true).". ".$e->getMessage(),
147 147
                 $this->activityLogKey
148 148
             );
149 149
             return false;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         }
187 187
         
188 188
         // Append output filename to path
189
-        $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename'];
189
+        $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename'];
190 190
         // Replace ${output_file} by output filename and path to local disk
191 191
         $ffmpegCmd = preg_replace('/\$\{output_file\}/', $pathToOutputFiles, $ffmpegCmd);
192 192
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         }
247 247
         
248 248
         // Create FFMpeg arguments
249
-        $ffmpegArgs =  " -i $pathToInputFile -y -threads 0";
249
+        $ffmpegArgs = " -i $pathToInputFile -y -threads 0";
250 250
         $ffmpegArgs .= " -vf scale=$size";
251 251
         $ffmpegArgs .= " -vcodec $videoCodec";
252 252
         $ffmpegArgs .= " -acodec $audioCodec";
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
         $ffmpegArgs .= " $watermarkOptions";
258 258
         
259 259
         // Append output filename to path
260
-        $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename'];
260
+        $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename'];
261 261
         // Final command
262
-        $ffmpegCmd  = "ffmpeg $ffmpegArgs $pathToOutputFiles";
262
+        $ffmpegCmd = "ffmpeg $ffmpegArgs $pathToOutputFiles";
263 263
             
264 264
         return ($ffmpegCmd);
265 265
     }
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
                 $snapshot_sec = $outputWanted->{'snapshot_sec'};
287 287
             }
288 288
                 
289
-            $time = gmdate("H:i:s", $snapshot_sec) . ".000";
290
-            $pathToOutputFiles .= "/" . $outputFileInfo['basename'];
289
+            $time = gmdate("H:i:s", $snapshot_sec).".000";
290
+            $pathToOutputFiles .= "/".$outputFileInfo['basename'];
291 291
             $frameOptions = " -ss $time -vframes 1";
292 292
         }
293 293
         else if ($outputWanted->{'mode'} == 'intervals')
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
                 $intervals = $outputWanted->{'intervals'};
299 299
             }
300 300
             
301
-            $pathToOutputFiles .= "/" . $outputFileInfo['filename'] . "%06d." 
301
+            $pathToOutputFiles .= "/".$outputFileInfo['filename']."%06d." 
302 302
                 . $outputFileInfo['extension'];
303 303
             $frameOptions = " -vf fps=fps=1/$intervals";
304 304
         }
305 305
 
306 306
         // Create FFMpeg arguments
307
-        $ffmpegArgs  =  " -i $pathToInputFile -y -threads 0";
308
-        $ffmpegArgs .= " -vf scale=" . $outputWanted->{'size'};
307
+        $ffmpegArgs  = " -i $pathToInputFile -y -threads 0";
308
+        $ffmpegArgs .= " -vf scale=".$outputWanted->{'size'};
309 309
         $ffmpegArgs .= " $frameOptions -f image2 -q:v 8";
310 310
 
311 311
         // Final command
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             $this->activityLogKey);
337 337
 
338 338
         // Transform watermark for opacity
339
-        $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply " . $watermarkOptions->{'opacity'} . " +channel $newWatermarkPath";
339
+        $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply ".$watermarkOptions->{'opacity'}." +channel $newWatermarkPath";
340 340
 
341 341
         try {
342 342
             $out = $this->executer->execute($convertCmd, 1, 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
         // Format options for FFMpeg
366 366
         $size      = $watermarkOptions->{'size'};
367 367
         $positions = $this->get_watermark_position($watermarkOptions);
368
-        $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=" . $positions['x'] . ':' . $positions['y'] . " [out]\"";
368
+        $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=".$positions['x'].':'.$positions['y']." [out]\"";
369 369
         
370 370
         return ($formattedOptions);
371 371
     }
@@ -382,10 +382,10 @@  discard block
 block discarded – undo
382 382
             $positions['y'] = $watermarkOptions->{'y'};
383 383
         }
384 384
         if ($watermarkOptions->{'x'} < 0) {
385
-            $positions['x'] = 'main_w-overlay_w' . $watermarkOptions->{'x'};
385
+            $positions['x'] = 'main_w-overlay_w'.$watermarkOptions->{'x'};
386 386
         }
387 387
         if ($watermarkOptions->{'y'} < 0) {
388
-            $positions['y'] = 'main_h-overlay_h' . $watermarkOptions->{'y'};
388
+            $positions['y'] = 'main_h-overlay_h'.$watermarkOptions->{'y'};
389 389
         }
390 390
 
391 391
         return ($positions);
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
             }
461 461
         }
462 462
 
463
-        return (str_replace("x",":", $size));
463
+        return (str_replace("x", ":", $size));
464 464
     }
465 465
     
466 466
     // REad ffmpeg output and calculate % progress
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 
497 497
         // # finally, progress is easy
498 498
         if ($done && $duration) {
499
-            $progress = round(($done/$duration)*100);
499
+            $progress = round(($done / $duration) * 100);
500 500
         }
501 501
         
502 502
         $this->cpeLogger->log_out(
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         }
532 532
         
533 533
         $preset     = $output_wanted->{"preset"};
534
-        $presetPath = __DIR__ . '/../../../presets/';
534
+        $presetPath = __DIR__.'/../../../presets/';
535 535
 
536 536
         if (!($presetContent = file_get_contents($presetPath.$preset.".json"))) {
537 537
             throw new CpeSdk\CpeException("Can't open preset file !",
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
         }
556 556
 
557 557
         $preset     = $output->{"preset"};
558
-        $presetPath = __DIR__ . '/../../../presets/';
558
+        $presetPath = __DIR__.'/../../../presets/';
559 559
         
560 560
         if (!($files = scandir($presetPath))) {
561 561
             throw new CpeSdk\CpeException("Unable to open preset directory '$presetPath' !",
@@ -611,22 +611,22 @@  discard block
 block discarded – undo
611 611
         }
612 612
 
613 613
         $analyse = [
614
-            'duration' => isset($metadata->format->duration) ? (float)$metadata->format->duration : 0,
614
+            'duration' => isset($metadata->format->duration) ? (float) $metadata->format->duration : 0,
615 615
             'video' => empty($videoStreams) ? null : [
616 616
                 'codec' => $videoStreams->codec_name,
617 617
                 'color' => $videoStreams->color_space,
618
-                'resolution' => $videoStreams->width . 'x' . $videoStreams->height,
618
+                'resolution' => $videoStreams->width.'x'.$videoStreams->height,
619 619
                 'sar' => $videoStreams->sample_aspect_ratio,
620 620
                 'dar' => $videoStreams->display_aspect_ratio,
621 621
                 'framerate' => $videoStreams->r_frame_rate,
622
-                'bitrate' => isset($videoStreams->bit_rate) ? (int)$videoStreams->bit_rate : null
622
+                'bitrate' => isset($videoStreams->bit_rate) ? (int) $videoStreams->bit_rate : null
623 623
             ],
624 624
             'audio' => empty($audioStreams) ? null : [
625 625
                 'codec' => $audioStreams->codec_name,
626 626
                 'frequency' => $audioStreams->sample_rate,
627
-                'channels' => (int)$audioStreams->channels,
627
+                'channels' => (int) $audioStreams->channels,
628 628
                 'depth' => $audioStreams->bits_per_sample,
629
-                'bitrate' => (int)$audioStreams->bit_rate
629
+                'bitrate' => (int) $audioStreams->bit_rate
630 630
             ]
631 631
         ];
632 632
 
Please login to merge, or discard this patch.
src/utils/CommandExecuter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
             }
81 81
 
82 82
             // If callback only after N turns
83
-            if ( !$callbackTurns || in_array($i, array(0, $callbackTurns)) ) 
83
+            if (!$callbackTurns || in_array($i, array(0, $callbackTurns))) 
84 84
             {
85 85
                 if ($showProgress) {
86 86
                     echo ".\n";
Please login to merge, or discard this patch.