@@ -102,7 +102,7 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -48,7 +48,7 @@ |
||
| 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( |
@@ -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 | { |
@@ -4,13 +4,13 @@ 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 | 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 |
||
| 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 |
||
| 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 | } |
@@ -4,13 +4,13 @@ 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 | 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 |
||
| 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 |
||
| 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 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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"; |
@@ -7,7 +7,7 @@ discard block |
||
| 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 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $this->cpeLogger->log_out( |
| 106 | 106 | "INFO", |
| 107 | 107 | basename(__FILE__), |
| 108 | - "Input Video metadata: " . print_r($metadata, true), |
|
| 108 | + "Input Video metadata: ".print_r($metadata, true), |
|
| 109 | 109 | $this->activityLogKey |
| 110 | 110 | ); |
| 111 | 111 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $this->cpeLogger->log_out( |
| 143 | 143 | "ERROR", |
| 144 | 144 | basename(__FILE__), |
| 145 | - "Execution of command '".$ffmpegCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(), |
|
| 145 | + "Execution of command '".$ffmpegCmd."' failed: ".print_r($metadata, true).". ".$e->getMessage(), |
|
| 146 | 146 | $this->activityLogKey |
| 147 | 147 | ); |
| 148 | 148 | return false; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // Append output filename to path |
| 188 | - $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename']; |
|
| 188 | + $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename']; |
|
| 189 | 189 | // Replace ${output_file} by output filename and path to local disk |
| 190 | 190 | $ffmpegCmd = preg_replace('/\$\{output_file\}/', $pathToOutputFiles, $ffmpegCmd); |
| 191 | 191 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // Create FFMpeg arguments |
| 248 | - $ffmpegArgs = " -i $pathToInputFile -y -threads 0"; |
|
| 248 | + $ffmpegArgs = " -i $pathToInputFile -y -threads 0"; |
|
| 249 | 249 | $ffmpegArgs .= " -s $size"; |
| 250 | 250 | $ffmpegArgs .= " -vcodec $videoCodec"; |
| 251 | 251 | $ffmpegArgs .= " -acodec $audioCodec"; |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | $ffmpegArgs .= " $watermarkOptions"; |
| 257 | 257 | |
| 258 | 258 | // Append output filename to path |
| 259 | - $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename']; |
|
| 259 | + $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename']; |
|
| 260 | 260 | // Final command |
| 261 | - $ffmpegCmd = "ffmpeg $ffmpegArgs $pathToOutputFiles"; |
|
| 261 | + $ffmpegCmd = "ffmpeg $ffmpegArgs $pathToOutputFiles"; |
|
| 262 | 262 | |
| 263 | 263 | return ($ffmpegCmd); |
| 264 | 264 | } |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | $snapshot_sec = $outputWanted->{'snapshot_sec'}; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - $time = gmdate("H:i:s", $snapshot_sec) . ".000"; |
|
| 289 | - $pathToOutputFiles .= "/" . $outputFileInfo['basename']; |
|
| 288 | + $time = gmdate("H:i:s", $snapshot_sec).".000"; |
|
| 289 | + $pathToOutputFiles .= "/".$outputFileInfo['basename']; |
|
| 290 | 290 | $frameOptions = " -ss $time -vframes 1"; |
| 291 | 291 | } |
| 292 | 292 | else if ($outputWanted->{'mode'} == 'intervals') |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | $intervals = $outputWanted->{'intervals'}; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - $pathToOutputFiles .= "/" . $outputFileInfo['filename'] . "%06d." |
|
| 300 | + $pathToOutputFiles .= "/".$outputFileInfo['filename']."%06d." |
|
| 301 | 301 | . $outputFileInfo['extension']; |
| 302 | 302 | $frameOptions = " -vf fps=fps=1/$intervals"; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Create FFMpeg arguments |
| 306 | - $ffmpegArgs = " -i $pathToInputFile -y -threads 0"; |
|
| 307 | - $ffmpegArgs .= " -vf scale=" . $outputWanted->{'size'}; |
|
| 306 | + $ffmpegArgs = " -i $pathToInputFile -y -threads 0"; |
|
| 307 | + $ffmpegArgs .= " -vf scale=".$outputWanted->{'size'}; |
|
| 308 | 308 | $ffmpegArgs .= " $frameOptions -f image2 -q:v 8"; |
| 309 | 309 | |
| 310 | 310 | // Final command |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | $this->activityLogKey); |
| 336 | 336 | |
| 337 | 337 | // Transform watermark for opacity |
| 338 | - $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply " . $watermarkOptions->{'opacity'} . " +channel $newWatermarkPath"; |
|
| 338 | + $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply ".$watermarkOptions->{'opacity'}." +channel $newWatermarkPath"; |
|
| 339 | 339 | |
| 340 | 340 | try { |
| 341 | 341 | $out = $this->executer->execute($convertCmd, 1, |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | // Format options for FFMpeg |
| 365 | 365 | $size = $watermarkOptions->{'size'}; |
| 366 | 366 | $positions = $this->get_watermark_position($watermarkOptions); |
| 367 | - $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=" . $positions['x'] . ':' . $positions['y'] . " [out]\""; |
|
| 367 | + $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=".$positions['x'].':'.$positions['y']." [out]\""; |
|
| 368 | 368 | |
| 369 | 369 | return ($formattedOptions); |
| 370 | 370 | } |
@@ -381,10 +381,10 @@ discard block |
||
| 381 | 381 | $positions['y'] = $watermarkOptions->{'y'}; |
| 382 | 382 | } |
| 383 | 383 | if ($watermarkOptions->{'x'} < 0) { |
| 384 | - $positions['x'] = 'main_w-overlay_w' . $watermarkOptions->{'x'}; |
|
| 384 | + $positions['x'] = 'main_w-overlay_w'.$watermarkOptions->{'x'}; |
|
| 385 | 385 | } |
| 386 | 386 | if ($watermarkOptions->{'y'} < 0) { |
| 387 | - $positions['y'] = 'main_h-overlay_h' . $watermarkOptions->{'y'}; |
|
| 387 | + $positions['y'] = 'main_h-overlay_h'.$watermarkOptions->{'y'}; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | return ($positions); |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | // # finally, progress is easy |
| 494 | 494 | $progress = 0; |
| 495 | 495 | if ($done) { |
| 496 | - $progress = round(($done/$duration)*100); |
|
| 496 | + $progress = round(($done / $duration) * 100); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | $this->cpeLogger->log_out( |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | $preset = $output_wanted->{"preset"}; |
| 531 | - $presetPath = __DIR__ . '/../../../presets/'; |
|
| 531 | + $presetPath = __DIR__.'/../../../presets/'; |
|
| 532 | 532 | |
| 533 | 533 | if (!($presetContent = file_get_contents($presetPath.$preset.".json"))) { |
| 534 | 534 | throw new CpeSdk\CpeException("Can't open preset file !", |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | $preset = $output->{"preset"}; |
| 555 | - $presetPath = __DIR__ . '/../../../presets/'; |
|
| 555 | + $presetPath = __DIR__.'/../../../presets/'; |
|
| 556 | 556 | |
| 557 | 557 | if (!($files = scandir($presetPath))) { |
| 558 | 558 | throw new CpeSdk\CpeException("Unable to open preset directory '$presetPath' !", |
@@ -608,22 +608,22 @@ discard block |
||
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | $analyse = [ |
| 611 | - 'duration' => isset($metadata->format->duration) ? (float)$metadata->format->duration : 0, |
|
| 611 | + 'duration' => isset($metadata->format->duration) ? (float) $metadata->format->duration : 0, |
|
| 612 | 612 | 'video' => empty($videoStreams) ? null : [ |
| 613 | 613 | 'codec' => $videoStreams->codec_name, |
| 614 | 614 | 'color' => $videoStreams->color_space, |
| 615 | - 'resolution' => $videoStreams->width . 'x' . $videoStreams->height, |
|
| 615 | + 'resolution' => $videoStreams->width.'x'.$videoStreams->height, |
|
| 616 | 616 | 'sar' => $videoStreams->sample_aspect_ratio, |
| 617 | 617 | 'dar' => $videoStreams->display_aspect_ratio, |
| 618 | 618 | 'framerate' => $videoStreams->r_frame_rate, |
| 619 | - 'bitrate' => isset($videoStreams->bit_rate) ? (int)$videoStreams->bit_rate : null |
|
| 619 | + 'bitrate' => isset($videoStreams->bit_rate) ? (int) $videoStreams->bit_rate : null |
|
| 620 | 620 | ], |
| 621 | 621 | 'audio' => empty($audioStreams) ? null : [ |
| 622 | 622 | 'codec' => $audioStreams->codec_name, |
| 623 | 623 | 'frequency' => $audioStreams->sample_rate, |
| 624 | - 'channels' => (int)$audioStreams->channels, |
|
| 624 | + 'channels' => (int) $audioStreams->channels, |
|
| 625 | 625 | 'depth' => $audioStreams->bits_per_sample, |
| 626 | - 'bitrate' => (int)$audioStreams->bit_rate |
|
| 626 | + 'bitrate' => (int) $audioStreams->bit_rate |
|
| 627 | 627 | ] |
| 628 | 628 | ]; |
| 629 | 629 | |