public function saveImage($file, $timeOffset = null)
{
if (!$timeOffset) {
$timeOffset = 5;
}
$realTargetPath = null;
if (!stream_is_local($file)) {
$realTargetPath = $file;
$file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/ffmpeg-tmp-" . uniqid() . "." . File::getFileExtension($file);
}
$cmd = self::getFfmpegCli() . " -i " . escapeshellarg(realpath($this->file)) . " -vcodec png -vframes 1 -vf scale=iw*sar:ih -ss " . $timeOffset . " " . escapeshellarg(str_replace("/", DIRECTORY_SEPARATOR, $file));
Console::exec($cmd, null, 60);
if ($realTargetPath) {
File::rename($file, $realTargetPath);
}
}