@@ -155,7 +155,7 @@ |
||
155 | 155 | { |
156 | 156 | $result = ''; |
157 | 157 | $filePath = parse_url($url, PHP_URL_PATH); |
158 | - $filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath; |
|
158 | + $filePath = $_SERVER['DOCUMENT_ROOT'].$filePath; |
|
159 | 159 | if (file_exists($filePath)) { |
160 | 160 | $urlParams = [ |
161 | 161 | 'url' => $url, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | Event::on( |
150 | 150 | CraftVariable::class, |
151 | 151 | CraftVariable::EVENT_INIT, |
152 | - function (Event $event) { |
|
152 | + function(Event $event) { |
|
153 | 153 | /** @var CraftVariable $variable */ |
154 | 154 | $variable = $event->sender; |
155 | 155 | $variable->set('transcoder', [ |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | Event::on( |
171 | 171 | Assets::class, |
172 | 172 | Assets::EVENT_GET_THUMB_PATH, |
173 | - function (AssetThumbEvent $event) { |
|
173 | + function(AssetThumbEvent $event) { |
|
174 | 174 | Craft::debug( |
175 | 175 | 'Assets::EVENT_GET_THUMB_PATH', |
176 | 176 | __METHOD__ |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | Event::on( |
191 | 191 | ClearCaches::class, |
192 | 192 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
193 | - function (RegisterCacheOptionsEvent $event) { |
|
193 | + function(RegisterCacheOptionsEvent $event) { |
|
194 | 194 | $event->options[] = [ |
195 | 195 | 'key' => 'transcoder', |
196 | 196 | 'label' => Craft::t('transcoder', 'Transcoder caches'), |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | Event::on( |
204 | 204 | Plugins::class, |
205 | 205 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
206 | - function (PluginEvent $event) { |
|
206 | + function(PluginEvent $event) { |
|
207 | 207 | if ($event->plugin === $this) { |
208 | 208 | $request = Craft::$app->getRequest(); |
209 | 209 | if ($request->isCpRequest) { |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | Event::on( |
229 | 229 | UrlManager::class, |
230 | 230 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
231 | - function (RegisterUrlRulesEvent $event) { |
|
231 | + function(RegisterUrlRulesEvent $event) { |
|
232 | 232 | Craft::debug( |
233 | 233 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
234 | 234 | __METHOD__ |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $filePath = $this->getAssetPath($filePath); |
112 | 112 | |
113 | 113 | if (!empty($filePath)) { |
114 | - $destVideoPath = $settings['transcoderPaths']['video'] . $subfolder ?? $settings['transcoderPaths']['default']; |
|
114 | + $destVideoPath = $settings['transcoderPaths']['video'].$subfolder ?? $settings['transcoderPaths']['default']; |
|
115 | 115 | $destVideoPath = Craft::parseEnv($destVideoPath); |
116 | 116 | $videoOptions = $this->coalesceOptions('defaultVideoOptions', $videoOptions); |
117 | 117 | |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | |
124 | 124 | // Build the basic command for ffmpeg |
125 | 125 | $ffmpegCmd = $settings['ffmpegPath'] |
126 | - . ' -i ' . escapeshellarg($filePath) |
|
127 | - . ' -vcodec ' . $thisEncoder['videoCodec'] |
|
128 | - . ' ' . $thisEncoder['videoCodecOptions'] |
|
126 | + . ' -i '.escapeshellarg($filePath) |
|
127 | + . ' -vcodec '.$thisEncoder['videoCodec'] |
|
128 | + . ' '.$thisEncoder['videoCodecOptions'] |
|
129 | 129 | . ' -bufsize 1000k' |
130 | - . ' -threads ' . $thisEncoder['threads']; |
|
130 | + . ' -threads '.$thisEncoder['threads']; |
|
131 | 131 | |
132 | 132 | // Set the framerate if desired |
133 | 133 | if (!empty($videoOptions['videoFrameRate'])) { |
134 | - $ffmpegCmd .= ' -r ' . $videoOptions['videoFrameRate']; |
|
134 | + $ffmpegCmd .= ' -r '.$videoOptions['videoFrameRate']; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // Set the bitrate if desired |
138 | 138 | if (!empty($videoOptions['videoBitRate'])) { |
139 | - $ffmpegCmd .= ' -b:v ' . $videoOptions['videoBitRate'] . ' -maxrate ' . $videoOptions['videoBitRate']; |
|
139 | + $ffmpegCmd .= ' -b:v '.$videoOptions['videoBitRate'].' -maxrate '.$videoOptions['videoBitRate']; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // Adjust the scaling if desired |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | $ffmpegCmd .= ' -c:a copy'; |
155 | 155 | } else { |
156 | 156 | // Do audio transcoding based on the settings |
157 | - $ffmpegCmd .= ' -acodec ' . $thisEncoder['audioCodec']; |
|
157 | + $ffmpegCmd .= ' -acodec '.$thisEncoder['audioCodec']; |
|
158 | 158 | if (!empty($videoOptions['audioBitRate'])) { |
159 | - $ffmpegCmd .= ' -b:a ' . $videoOptions['audioBitRate']; |
|
159 | + $ffmpegCmd .= ' -b:a '.$videoOptions['audioBitRate']; |
|
160 | 160 | } |
161 | 161 | if (!empty($videoOptions['audioSampleRate'])) { |
162 | - $ffmpegCmd .= ' -ar ' . $videoOptions['audioSampleRate']; |
|
162 | + $ffmpegCmd .= ' -ar '.$videoOptions['audioSampleRate']; |
|
163 | 163 | } |
164 | 164 | if (!empty($videoOptions['audioChannels'])) { |
165 | - $ffmpegCmd .= ' -ac ' . $videoOptions['audioChannels']; |
|
165 | + $ffmpegCmd .= ' -ac '.$videoOptions['audioChannels']; |
|
166 | 166 | } |
167 | - $ffmpegCmd .= ' ' . $thisEncoder['audioCodecOptions']; |
|
167 | + $ffmpegCmd .= ' '.$thisEncoder['audioCodecOptions']; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // Create the directory if it isn't there already |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | $destVideoFile = $this->getFilename($filePath, $videoOptions); |
180 | 180 | |
181 | 181 | // File to store the video encoding progress in |
182 | - $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.progress'; |
|
182 | + $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.progress'; |
|
183 | 183 | |
184 | 184 | // Assemble the destination path and final ffmpeg command |
185 | 185 | $destVideoPath .= $destVideoFile; |
186 | 186 | $ffmpegCmd .= ' -f ' |
187 | 187 | . $thisEncoder['fileFormat'] |
188 | - . ' -y ' . escapeshellarg($destVideoPath) |
|
189 | - . ' 1> ' . $progressFile . ' 2>&1 & echo $!'; |
|
188 | + . ' -y '.escapeshellarg($destVideoPath) |
|
189 | + . ' 1> '.$progressFile.' 2>&1 & echo $!'; |
|
190 | 190 | |
191 | 191 | // Make sure there isn't a lockfile for this video already |
192 | - $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.lock'; |
|
192 | + $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.lock'; |
|
193 | 193 | $oldPid = @file_get_contents($lockFile); |
194 | 194 | if ($oldPid !== false) { |
195 | 195 | // See if the process is running, and empty result means the process is still running |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | |
206 | 206 | // If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding |
207 | 207 | if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) { |
208 | - $url = $settings['transcoderUrls']['video'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
209 | - $result = Craft::parseEnv($url) . $destVideoFile; |
|
208 | + $url = $settings['transcoderUrls']['video'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
209 | + $result = Craft::parseEnv($url).$destVideoFile; |
|
210 | 210 | // skip encoding |
211 | 211 | } elseif (!$generate) { |
212 | 212 | $result = ""; |
213 | 213 | } else { |
214 | 214 | // Kick off the transcoding |
215 | 215 | $pid = $this->executeShellCommand($ffmpegCmd); |
216 | - Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__); |
|
216 | + Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__); |
|
217 | 217 | |
218 | 218 | // Create a lockfile in tmp |
219 | 219 | file_put_contents($lockFile, $pid); |
@@ -248,14 +248,14 @@ discard block |
||
248 | 248 | $filePath = $this->getAssetPath($filePath); |
249 | 249 | |
250 | 250 | if (!empty($filePath)) { |
251 | - $destThumbnailPath = $settings['transcoderPaths']['thumbnail'] . $subfolder ?? $settings['transcoderPaths']['default']; |
|
251 | + $destThumbnailPath = $settings['transcoderPaths']['thumbnail'].$subfolder ?? $settings['transcoderPaths']['default']; |
|
252 | 252 | $destThumbnailPath = Craft::parseEnv($destThumbnailPath); |
253 | 253 | |
254 | 254 | $thumbnailOptions = $this->coalesceOptions('defaultThumbnailOptions', $thumbnailOptions); |
255 | 255 | |
256 | 256 | // Build the basic command for ffmpeg |
257 | 257 | $ffmpegCmd = $settings['ffmpegPath'] |
258 | - . ' -i ' . escapeshellarg($filePath) |
|
258 | + . ' -i '.escapeshellarg($filePath) |
|
259 | 259 | . ' -vcodec mjpeg' |
260 | 260 | . ' -vframes 1'; |
261 | 261 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | // Set the timecode to get the thumbnail from if desired |
269 | 269 | if (!empty($thumbnailOptions['timeInSecs'])) { |
270 | 270 | $timeCode = gmdate('H:i:s', $thumbnailOptions['timeInSecs']); |
271 | - $ffmpegCmd .= ' -ss ' . $timeCode . '.00'; |
|
271 | + $ffmpegCmd .= ' -ss '.$timeCode.'.00'; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | // Create the directory if it isn't there already |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | // Assemble the destination path and final ffmpeg command |
286 | 286 | $destThumbnailPath .= $destThumbnailFile; |
287 | - $ffmpegCmd .= ' -f image2 -y ' . escapeshellarg($destThumbnailPath) . ' >/dev/null 2>/dev/null &'; |
|
287 | + $ffmpegCmd .= ' -f image2 -y '.escapeshellarg($destThumbnailPath).' >/dev/null 2>/dev/null &'; |
|
288 | 288 | |
289 | 289 | // If the thumbnail file already exists, return it. Otherwise, generate it and return it |
290 | 290 | if (!file_exists($destThumbnailPath)) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | |
299 | 299 | return false; |
300 | 300 | } else { |
301 | - Craft::info('Thumbnail does not exist, but not asked to generate it: ' . $filePath, __METHOD__); |
|
301 | + Craft::info('Thumbnail does not exist, but not asked to generate it: '.$filePath, __METHOD__); |
|
302 | 302 | |
303 | 303 | // The file doesn't exist, and we weren't asked to generate it |
304 | 304 | return false; |
@@ -308,8 +308,8 @@ discard block |
||
308 | 308 | if ($asPath) { |
309 | 309 | $result = $destThumbnailPath; |
310 | 310 | } else { |
311 | - $url = $settings['transcoderUrls']['thumbnail'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
312 | - $result = Craft::parseEnv($url) . $destThumbnailFile; |
|
311 | + $url = $settings['transcoderUrls']['thumbnail'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
312 | + $result = Craft::parseEnv($url).$destThumbnailFile; |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $filePath = $this->getAssetPath($filePath); |
340 | 340 | |
341 | 341 | if (!empty($filePath)) { |
342 | - $destAudioPath = $settings['transcoderPaths']['audio'] . $subfolder ?? $settings['transcoderPaths']['default']; |
|
342 | + $destAudioPath = $settings['transcoderPaths']['audio'].$subfolder ?? $settings['transcoderPaths']['default']; |
|
343 | 343 | $destAudioPath = Craft::parseEnv($destAudioPath); |
344 | 344 | |
345 | 345 | $audioOptions = $this->coalesceOptions('defaultAudioOptions', $audioOptions); |
@@ -352,33 +352,33 @@ discard block |
||
352 | 352 | |
353 | 353 | // Build the basic command for ffmpeg |
354 | 354 | $ffmpegCmd = $settings['ffmpegPath'] |
355 | - . ' -i ' . escapeshellarg($filePath) |
|
356 | - . ' -acodec ' . $thisEncoder['audioCodec'] |
|
357 | - . ' ' . $thisEncoder['audioCodecOptions'] |
|
355 | + . ' -i '.escapeshellarg($filePath) |
|
356 | + . ' -acodec '.$thisEncoder['audioCodec'] |
|
357 | + . ' '.$thisEncoder['audioCodecOptions'] |
|
358 | 358 | . ' -bufsize 1000k' |
359 | 359 | . ' -vn' |
360 | - . ' -threads ' . $thisEncoder['threads']; |
|
360 | + . ' -threads '.$thisEncoder['threads']; |
|
361 | 361 | |
362 | 362 | // Set the bitrate if desired |
363 | 363 | if (!empty($audioOptions['audioBitRate'])) { |
364 | - $ffmpegCmd .= ' -b:a ' . $audioOptions['audioBitRate']; |
|
364 | + $ffmpegCmd .= ' -b:a '.$audioOptions['audioBitRate']; |
|
365 | 365 | } |
366 | 366 | // Set the sample rate if desired |
367 | 367 | if (!empty($audioOptions['audioSampleRate'])) { |
368 | - $ffmpegCmd .= ' -ar ' . $audioOptions['audioSampleRate']; |
|
368 | + $ffmpegCmd .= ' -ar '.$audioOptions['audioSampleRate']; |
|
369 | 369 | } |
370 | 370 | // Set the audio channels if desired |
371 | 371 | if (!empty($audioOptions['audioChannels'])) { |
372 | - $ffmpegCmd .= ' -ac ' . $audioOptions['audioChannels']; |
|
372 | + $ffmpegCmd .= ' -ac '.$audioOptions['audioChannels']; |
|
373 | 373 | } |
374 | - $ffmpegCmd .= ' ' . $thisEncoder['audioCodecOptions']; |
|
374 | + $ffmpegCmd .= ' '.$thisEncoder['audioCodecOptions']; |
|
375 | 375 | |
376 | 376 | if (!empty($audioOptions['seekInSecs'])) { |
377 | - $ffmpegCmd .= ' -ss ' . $audioOptions['seekInSecs']; |
|
377 | + $ffmpegCmd .= ' -ss '.$audioOptions['seekInSecs']; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | if (!empty($audioOptions['timeInSecs'])) { |
381 | - $ffmpegCmd .= ' -t ' . $audioOptions['timeInSecs']; |
|
381 | + $ffmpegCmd .= ' -t '.$audioOptions['timeInSecs']; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | // Create the directory if it isn't there already |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $destAudioFile = $this->getFilename($filePath, $audioOptions); |
394 | 394 | |
395 | 395 | // File to store the audio encoding progress in |
396 | - $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destAudioFile . '.progress'; |
|
396 | + $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destAudioFile.'.progress'; |
|
397 | 397 | |
398 | 398 | // Assemble the destination path and final ffmpeg command |
399 | 399 | $destAudioPath .= $destAudioFile; |
@@ -408,16 +408,16 @@ discard block |
||
408 | 408 | // Add the file format |
409 | 409 | $ffmpegCmd .= ' -f ' |
410 | 410 | . $thisEncoder['fileFormat'] |
411 | - . ' -y ' . escapeshellarg($destAudioPath); |
|
411 | + . ' -y '.escapeshellarg($destAudioPath); |
|
412 | 412 | // Handle the `synchronous` setting |
413 | 413 | $synchronous = false; |
414 | 414 | if (!empty($audioOptions['synchronous'])) { |
415 | 415 | $synchronous = $audioOptions['synchronous']; |
416 | 416 | } |
417 | 417 | if (!$synchronous) { |
418 | - $ffmpegCmd .= ' 1> ' . $progressFile . ' 2>&1 & echo $!'; |
|
418 | + $ffmpegCmd .= ' 1> '.$progressFile.' 2>&1 & echo $!'; |
|
419 | 419 | // Make sure there isn't a lockfile for this audio file already |
420 | - $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destAudioFile . '.lock'; |
|
420 | + $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destAudioFile.'.lock'; |
|
421 | 421 | $oldPid = @file_get_contents($lockFile); |
422 | 422 | if ($oldPid !== false) { |
423 | 423 | // See if the process is running, and empty result means the process is still running |
@@ -434,18 +434,18 @@ discard block |
||
434 | 434 | |
435 | 435 | // If the audio file already exists and hasn't been modified, return it. Otherwise, start it transcoding |
436 | 436 | if (file_exists($destAudioPath) && (@filemtime($destAudioPath) >= @filemtime($filePath))) { |
437 | - $url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
438 | - $result = Craft::parseEnv($url) . $destAudioFile; |
|
437 | + $url = $settings['transcoderUrls']['audio'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
438 | + $result = Craft::parseEnv($url).$destAudioFile; |
|
439 | 439 | } else { |
440 | 440 | // Kick off the transcoding |
441 | 441 | $pid = $this->executeShellCommand($ffmpegCmd); |
442 | 442 | |
443 | 443 | if ($synchronous) { |
444 | 444 | Craft::info($ffmpegCmd, __METHOD__); |
445 | - $url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
446 | - $result = Craft::parseEnv($url) . $destAudioFile; |
|
445 | + $url = $settings['transcoderUrls']['audio'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
446 | + $result = Craft::parseEnv($url).$destAudioFile; |
|
447 | 447 | } else { |
448 | - Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__); |
|
448 | + Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__); |
|
449 | 449 | // Create a lockfile in tmp |
450 | 450 | file_put_contents($lockFile, $pid); |
451 | 451 | } |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | // Build the basic command for ffprobe |
474 | 474 | $ffprobeOptions = $settings['ffprobeOptions']; |
475 | 475 | $ffprobeCmd = $settings['ffprobePath'] |
476 | - . ' ' . $ffprobeOptions |
|
477 | - . ' ' . escapeshellarg($filePath); |
|
476 | + . ' '.$ffprobeOptions |
|
477 | + . ' '.escapeshellarg($filePath); |
|
478 | 478 | |
479 | 479 | $shellOutput = $this->executeShellCommand($ffprobeCmd); |
480 | 480 | Craft::info($ffprobeCmd, __METHOD__); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | && (strpos($summaryResult['videoFrameRate'], '/') !== false) |
521 | 521 | ) { |
522 | 522 | $parts = explode('/', $summaryResult['videoFrameRate']); |
523 | - $summaryResult['videoFrameRate'] = (float)$parts[0] / (float)$parts[1]; |
|
523 | + $summaryResult['videoFrameRate'] = (float) $parts[0] / (float) $parts[1]; |
|
524 | 524 | } |
525 | 525 | $result = $summaryResult; |
526 | 526 | } |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | |
641 | 641 | if (!empty($filePath)) { |
642 | 642 | // Dest path |
643 | - $destVideoPath = $settings['transcoderPaths']['gif'] . $subfolder ?? $settings['transcoderPaths']['default']; |
|
643 | + $destVideoPath = $settings['transcoderPaths']['gif'].$subfolder ?? $settings['transcoderPaths']['default']; |
|
644 | 644 | $destVideoPath = Craft::parseEnv($destVideoPath); |
645 | 645 | |
646 | 646 | // Options |
@@ -654,9 +654,9 @@ discard block |
||
654 | 654 | // Build the basic command for ffmpeg |
655 | 655 | $ffmpegCmd = $settings['ffmpegPath'] |
656 | 656 | . ' -f gif' |
657 | - . ' -i ' . escapeshellarg($filePath) |
|
658 | - . ' -vcodec ' . $thisEncoder['videoCodec'] |
|
659 | - . ' ' . $thisEncoder['videoCodecOptions']; |
|
657 | + . ' -i '.escapeshellarg($filePath) |
|
658 | + . ' -vcodec '.$thisEncoder['videoCodec'] |
|
659 | + . ' '.$thisEncoder['videoCodecOptions']; |
|
660 | 660 | |
661 | 661 | |
662 | 662 | // Create the directory if it isn't there already |
@@ -671,16 +671,16 @@ discard block |
||
671 | 671 | $destVideoFile = $this->getFilename($filePath, $gifOptions); |
672 | 672 | |
673 | 673 | // File to store the video encoding progress in |
674 | - $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.progress'; |
|
674 | + $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.progress'; |
|
675 | 675 | |
676 | 676 | // Assemble the destination path and final ffmpeg command |
677 | 677 | $destVideoPath .= $destVideoFile; |
678 | 678 | $ffmpegCmd .= ' ' |
679 | - . ' -y ' . escapeshellarg($destVideoPath) |
|
680 | - . ' 1> ' . $progressFile . ' 2>&1 & echo $!'; |
|
679 | + . ' -y '.escapeshellarg($destVideoPath) |
|
680 | + . ' 1> '.$progressFile.' 2>&1 & echo $!'; |
|
681 | 681 | |
682 | 682 | // Make sure there isn't a lockfile for this video already |
683 | - $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.lock'; |
|
683 | + $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.lock'; |
|
684 | 684 | $oldPid = @file_get_contents($lockFile); |
685 | 685 | if ($oldPid !== false) { |
686 | 686 | // See if the process is running, and empty result means the process is still running |
@@ -696,12 +696,12 @@ discard block |
||
696 | 696 | |
697 | 697 | // If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding |
698 | 698 | if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) { |
699 | - $url = $settings['transcoderUrls']['gif'] . $subfolder ?? $settings['transcoderUrls']['default']; |
|
700 | - $result = Craft::parseEnv($url) . $destVideoFile; |
|
699 | + $url = $settings['transcoderUrls']['gif'].$subfolder ?? $settings['transcoderUrls']['default']; |
|
700 | + $result = Craft::parseEnv($url).$destVideoFile; |
|
701 | 701 | } else { |
702 | 702 | // Kick off the transcoding |
703 | 703 | $pid = $this->executeShellCommand($ffmpegCmd); |
704 | - Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__); |
|
704 | + Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__); |
|
705 | 705 | |
706 | 706 | // Create a lockfile in tmp |
707 | 707 | file_put_contents($lockFile, $pid); |
@@ -742,16 +742,16 @@ discard block |
||
742 | 742 | $suffix = self::SUFFIX_MAP[$key]; |
743 | 743 | } |
744 | 744 | if (is_bool($value)) { |
745 | - $value = $value ? $key : 'no' . $key; |
|
745 | + $value = $value ? $key : 'no'.$key; |
|
746 | 746 | } |
747 | 747 | if (!in_array($key, self::EXCLUDE_PARAMS, true)) { |
748 | - $fileName .= '_' . $value . $suffix; |
|
748 | + $fileName .= '_'.$value.$suffix; |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | } |
752 | 752 | // See if we should use a hash instead |
753 | 753 | if ($settings['useHashedNames']) { |
754 | - $fileName = $pathParts['filename'] . md5($fileName); |
|
754 | + $fileName = $pathParts['filename'].md5($fileName); |
|
755 | 755 | } |
756 | 756 | $fileName .= $options['fileSuffix']; |
757 | 757 | |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | } |
792 | 792 | $folderPath .= '' === $folderPath ? '' : DIRECTORY_SEPARATOR; |
793 | 793 | |
794 | - $filePath = $sourcePath . $folderPath . $asset->filename; |
|
794 | + $filePath = $sourcePath.$folderPath.$asset->filename; |
|
795 | 795 | } else { |
796 | 796 | // Otherwise, get a URL |
797 | 797 | $filePath = $asset->getUrl(); |
@@ -833,16 +833,16 @@ discard block |
||
833 | 833 | case 'letterbox': |
834 | 834 | $letterboxColor = ''; |
835 | 835 | if (!empty($options['letterboxColor'])) { |
836 | - $letterboxColor = ':color=' . $options['letterboxColor']; |
|
836 | + $letterboxColor = ':color='.$options['letterboxColor']; |
|
837 | 837 | } |
838 | 838 | $aspectRatio = ':force_original_aspect_ratio=decrease' |
839 | - . ',pad=' . $options['width'] . ':' . $options['height'] . ':(ow-iw)/2:(oh-ih)/2' |
|
839 | + . ',pad='.$options['width'].':'.$options['height'].':(ow-iw)/2:(oh-ih)/2' |
|
840 | 840 | . $letterboxColor; |
841 | 841 | break; |
842 | 842 | // Scale to the appropriate aspect ratio, cropping |
843 | 843 | case 'crop': |
844 | 844 | $aspectRatio = ':force_original_aspect_ratio=increase' |
845 | - . ',crop=' . $options['width'] . ':' . $options['height']; |
|
845 | + . ',crop='.$options['width'].':'.$options['height']; |
|
846 | 846 | break; |
847 | 847 | // No aspect ratio scaling at all |
848 | 848 | default: |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | $sharpen = ',unsharp=5:5:1.0:5:5:0.0'; |
857 | 857 | } |
858 | 858 | $ffmpegCmd .= ' -vf "scale=' |
859 | - . $options['width'] . ':' . $options['height'] |
|
859 | + . $options['width'].':'.$options['height'] |
|
860 | 860 | . $aspectRatio |
861 | 861 | . $sharpen |
862 | 862 | . '"'; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $filePath = parse_url($url, PHP_URL_PATH); |
68 | 68 | // Remove any relative paths |
69 | 69 | if (!PathHelper::ensurePathIsContained($filePath)) { |
70 | - throw new BadRequestHttpException('Invalid resource path: ' . $filePath); |
|
70 | + throw new BadRequestHttpException('Invalid resource path: '.$filePath); |
|
71 | 71 | } |
72 | 72 | // Only work for `allowedFileExtensions` file extensions |
73 | 73 | $extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | throw new AssetDisallowedExtensionException("File “{$filePath}” cannot be downloaded because “{$extension}” is not allowed."); |
77 | 77 | } |
78 | 78 | |
79 | - $filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath; |
|
79 | + $filePath = $_SERVER['DOCUMENT_ROOT'].$filePath; |
|
80 | 80 | Craft::$app->getResponse()->sendFile( |
81 | 81 | $filePath, |
82 | 82 | null, |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public function actionProgress($filename) |
101 | 101 | { |
102 | 102 | $result = []; |
103 | - $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename . '.progress'; |
|
103 | + $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$filename.'.progress'; |
|
104 | 104 | if (file_exists($progressFile)) { |
105 | 105 | $content = @file_get_contents($progressFile); |
106 | 106 | if ($content) { |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | |
112 | 112 | // rawDuration is in 00:00:00.00 format. This converts it to seconds. |
113 | 113 | $ar = array_reverse(explode(':', $rawDuration)); |
114 | - $duration = (float)$ar[0]; |
|
114 | + $duration = (float) $ar[0]; |
|
115 | 115 | if (!empty($ar[1])) { |
116 | - $duration += (int)$ar[1] * 60; |
|
116 | + $duration += (int) $ar[1] * 60; |
|
117 | 117 | } |
118 | 118 | if (!empty($ar[2])) { |
119 | - $duration += (int)$ar[2] * 60 * 60; |
|
119 | + $duration += (int) $ar[2] * 60 * 60; |
|
120 | 120 | } |
121 | 121 | } else { |
122 | 122 | $duration = 'unknown'; // with GIF as input, duration is unknown |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | |
134 | 134 | //rawTime is in 00:00:00.00 format. This converts it to seconds. |
135 | 135 | $ar = array_reverse(explode(':', $rawTime)); |
136 | - $time = (float)$ar[0]; |
|
136 | + $time = (float) $ar[0]; |
|
137 | 137 | if (!empty($ar[1])) { |
138 | - $time += (int)$ar[1] * 60; |
|
138 | + $time += (int) $ar[1] * 60; |
|
139 | 139 | } |
140 | 140 | if (!empty($ar[2])) { |
141 | - $time += (int)$ar[2] * 60 * 60; |
|
141 | + $time += (int) $ar[2] * 60 * 60; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | //calculate the progress |