Skip to content

Commit 7c27ef6

Browse files
committed
Fixed issues with the synchronous and stripMetadata options
Signed-off-by: Andrew Welch <andrew@nystudio107.com>
1 parent b407309 commit 7c27ef6

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/services/Transcode.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,16 +386,24 @@ public function getAudioUrl($filePath, $audioOptions): string
386386

387387
// Assemble the destination path and final ffmpeg command
388388
$destAudioPath .= $destAudioFile;
389-
390-
if ($audioOptions['stripMetadata']) {
389+
// Handle the `stripMetadata` setting
390+
$stripMetadata = false;
391+
if (!empty($audioOptions['stripMetadata'])) {
392+
$stripMetadata = $audioOptions['stripMetadata'];
393+
}
394+
if ($stripMetadata) {
391395
$ffmpegCmd .= ' -map_metadata -1 ';
392396
}
393-
397+
// Add the file format
394398
$ffmpegCmd .= ' -f '
395399
.$thisEncoder['fileFormat']
396400
.' -y '.escapeshellarg($destAudioPath);
397-
398-
if (!$audioOptions['synchronous']) {
401+
// Handle the `synchronous` setting
402+
$synchronous = false;
403+
if (!empty($audioOptions['synchronous'])) {
404+
$synchronous = $audioOptions['synchronous'];
405+
}
406+
if (!$synchronous) {
399407
$ffmpegCmd .=' 1> '.$progressFile.' 2>&1 & echo $!';
400408
// Make sure there isn't a lockfile for this audio file already
401409
$lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destAudioFile.'.lock';
@@ -418,8 +426,8 @@ public function getAudioUrl($filePath, $audioOptions): string
418426
} else {
419427
// Kick off the transcoding
420428
$this->executeShellCommand($ffmpegCmd);
421-
422-
if ($audioOptions['synchronous']) {
429+
430+
if ($synchronous) {
423431
Craft::info($ffmpegCmd, __METHOD__);
424432
$url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default'];
425433
$result = Craft::getAlias($url).$destAudioFile;

0 commit comments

Comments
 (0)