@@ -1,6 +1,6 @@ |
||
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 | { |
@@ -281,7 +281,7 @@ |
||
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"); |
@@ -22,7 +22,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -29,12 +29,12 @@ |
||
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"; |
@@ -58,7 +58,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -53,8 +53,8 @@ discard block |
||
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 |
||
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"); |
@@ -27,9 +27,9 @@ discard block |
||
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 |
||
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'})) |
@@ -4,11 +4,11 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -4,11 +4,11 @@ discard block |
||
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 |
||
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 |
||
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"; |