mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Merge pull request #2645 from aynsix/PHRAS-2112-video-subdef-in-specified-path
PHRAS-2112 generate video subdef in temporary path first
This commit is contained in:
@@ -67,6 +67,20 @@ class FilesystemService
|
||||
return $pathdest . $this->generateSubdefFilename($record, $subdef);
|
||||
}
|
||||
|
||||
public function generateTemporarySubdefPathname(\record_adapter $record, \databox_subdef $subdef, $tmpDir)
|
||||
{
|
||||
$tmpDir = \p4string::addEndSlash($tmpDir);
|
||||
$ffmpegDir = $tmpDir."ffmpeg/";
|
||||
|
||||
if(!is_dir($ffmpegDir)){
|
||||
$this->filesystem->mkdir($ffmpegDir);
|
||||
}
|
||||
|
||||
$filenameSufix = $this->generateSubdefFilename($record, $subdef);
|
||||
|
||||
return $ffmpegDir . hash('sha256', $filenameSufix) . $filenameSufix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecordInterface $record
|
||||
* @param string|\SplFileInfo $source
|
||||
|
@@ -22,6 +22,7 @@ use Alchemy\Phrasea\Filesystem\FilesystemService;
|
||||
use Alchemy\Phrasea\Media\Subdef\Specification\PdfSpecification;
|
||||
use MediaAlchemyst\Alchemyst;
|
||||
use MediaAlchemyst\Specification\Image;
|
||||
use MediaAlchemyst\Specification\Video;
|
||||
use MediaVorus\MediaVorus;
|
||||
use MediaAlchemyst\Exception\ExceptionInterface as MediaAlchemystException;
|
||||
use Neutron\TemporaryFilesystem\Manager;
|
||||
@@ -173,6 +174,14 @@ class SubdefGenerator
|
||||
return;
|
||||
}
|
||||
|
||||
$tmpDir = $this->app['conf']->get(['main', 'storage', 'tmp_files']);
|
||||
$destFile = null;
|
||||
|
||||
if($subdef_class->getSpecs() instanceof Video && !empty($tmpDir)){
|
||||
$destFile = $pathdest;
|
||||
$pathdest = $this->filesystem->generateTemporarySubdefPathname($record, $subdef_class, $tmpDir);
|
||||
}
|
||||
|
||||
if (isset($this->tmpFilePath) && $subdef_class->getSpecs() instanceof Image) {
|
||||
|
||||
$this->alchemyst->turnInto($this->tmpFilePath, $pathdest, $subdef_class->getSpecs());
|
||||
@@ -187,6 +196,11 @@ class SubdefGenerator
|
||||
|
||||
}
|
||||
|
||||
if($destFile){
|
||||
$this->filesystem->copy($pathdest, $destFile);
|
||||
$this->app['filesystem']->remove($pathdest);
|
||||
}
|
||||
|
||||
} catch (MediaAlchemystException $e) {
|
||||
$this->logger->error(sprintf('Subdef generation failed for record %d with message %s', $record->getRecordId(), $e->getMessage()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user