Generates sprite and WebVTT for selected video

@throws \Exception
@return string[]
328315
public function generate(): array
    {
        // create temporay directory
        $tempDir = new Tempdir('sprite');
        $tempDir->addPlugin(new ListFiles);

        // get basic info about video
        $ffprobe  = FFProbe::create()->format($this->getSource());
        $duration = (float)$ffprobe->get('duration');

        // check if sample rate is high enough to reach desired minimum amount of thumbnails
        if ($duration <= $this->getMinThumbs()) {
            // we only have a 1 second resolution, so we can't get lower than 1 obviously
            $this->setRate(1);
        } else {
            if ($duration / $this->getRate() < $this->getMinThumbs()) {
                // sample rate too high, let's adjust rate a little
                $this->setRate((int)floor($duration / $this->getMinThumbs()));
            }
        }

        $this->thumbnailer
            ->setSource($this->getSource())
            ->setWidth($this->getWidth())
            ->setDestination($tempDir->getPath());

        // capture images to tempdir
        for ($i = 0; $i <= $duration; $i += $this->getRate()) {
            $this->thumbnailer->run($i, (int)floor($i / $this->getRate()));
        }

        if (!empty($this->outputImageDirectory)) {
            foreach ($tempDir->listFiles() as $image) {
                copy($tempDir->getPath() . $image['path'], $this->outputImageDirectory . $image['basename']);
            }
        }

        // combine all images to one sprite with quadratic tiling
        $gridSize   = ceil(sqrt(count($tempDir->listFiles())));
        $firstImage = Image::make(sprintf('%s/0001.jpg', $tempDir->getPath()));
        $spriteFile = sprintf('%s/%s.jpg',
            $this->getOutputDirectory(),
            $this->getPrefix()
        );

        $spriteUrl = empty($this->getUrlPrefix())
            ? basename($spriteFile)
            : sprintf('%s/%s', $this->getUrlPrefix(), basename($spriteFile));

        $cmd = sprintf('montage %1$s/*.jpg -tile %2$dx -geometry %3$dx%4$d+0+0 %5$s',
            $tempDir->getPath(),
            $gridSize,
            $firstImage->width(),
            $firstImage->height(),
            $spriteFile
        );

        $proc = new Process($cmd);
        $proc->run();

        if (!$proc->isSuccessful()) {
            throw new \RuntimeException($proc->getErrorOutput());
        }

        // create WebVTT output
        $vttFile = sprintf('%s/%s.vtt',
            $this->getOutputDirectory(),
            $this->getPrefix()
        );

        $vtt      = new WebvttFile();
        $numFiles = count($tempDir->listFiles());

        for ($i = 0; $i < $numFiles; $i++) {
            $start = $i * $this->getRate();
            $end   = ($i + 1) * $this->getRate();
            $x     = ($i % $gridSize) * $firstImage->width();
            $y     = floor($i / $gridSize) * $firstImage->height();

            $vtt->addCue(new WebvttCue(
                    $this->secondsToCue($start),
                    $this->secondsToCue($end),
                    sprintf('%s#xywh=%d,%d,%d,%d',
                        $spriteUrl,
                        $x,
                        $y,
                        $firstImage->width(),
                        $firstImage->height()
                    )
                )
            );
        }

        $vtt->build();
        $vtt->save($vttFile);

        return [
            'vttFile' => $vttFile,
            'sprite'  => $spriteFile,
        ];
    }
1124922
public function buildMessage()
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        $video = [
            'type' => MessageType::VIDEO,
            'originalContentUrl' => $this->originalContentUrl,
            'previewImageUrl' => $this->previewImageUrl,
        ];

        if ($this->quickReply) {
            $video['quickReply'] = $this->quickReply->buildQuickReply();
        }

        $this->message[] = $video;

        return $this->message;
    }
149885
public function getData()
    {
        $imagick = new \Imagick();
        $imagick->newImage($this->width, $this->height, $this->backgroundColor->__toString());
        $imagick->setImageFormat('png');

        if (method_exists($imagick, 'setImageProperty')) {
            $imagick->setImageProperty('Software', 'Jdenticon');
        } else {
            $imagick->setImageAttribute('Software', 'Jdenticon');
        }
        
        $imagick->drawImage($this->draw);
        return $imagick->getImageBlob();
    }
295562
public function buildChoicesFromSprite()
    {
        $sprite = $this->sprite();

        if (!file_exists($sprite)) {
            return [];
        }

        $spriteString = file_get_contents($sprite);

        try {
            $xml = new SimpleXMLElement($spriteString);

            $choices = [];

            foreach ($xml->symbol as $ident => $node) {
                $id = (string)$node->attributes()->id;

                $choices[$id] = $id;
            }

            return $choices;
        } catch (Exception $e) {
            $this->logger->error('Could not parse sprite. Invalid SVG / XML.');
            return [];
        }
    }
616340
private Video generateRandomVideo() {
    Video video = new Video();
    configureFavoriteStatus(video);
    configureLikeStatus(video);
    configureLiveStatus(video);
    configureTitleAndThumbnail(video);
    return video;
  }
946879
public static function webvtt2subrip(WebvttFile $_vtt)
    {
        $srt = new SubripFile();
        foreach ($_vtt->getCues() as $cue) {
            $srt->addCue($cue->getText(), SubripCue::ms2tc($cue->getStartMS()), SubripCue::ms2tc($cue->getStopMS()));
        }

        return $srt;
    }
1047965
function VideoFeature() {
      var _this;

      var ua = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
      var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      var cssFlagsPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'video';

      _classCallCheck(this, VideoFeature);

      _this = _possibleConstructorReturn(this, _getPrototypeOf(VideoFeature).call(this, ua, flags, cssFlagsPrefix));

      _this._createTestElements();

      _this.formats = {
        mp4: _this.getMp4(),
        ogv: _this.getOgv(),
        webm: _this.getWebm()
      };
      return _this;
    }
237270
function () {
                var el = document.createElement( 'video' ),
                    bool = false;
                // IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224
                try {
                    if ( bool = !!el.canPlayType ) {
                        bool      = new Boolean(bool);
                        bool.ogg  = el.canPlayType('video/ogg; codecs="theora"')      .replace(/^no$/,'');
                        bool.h264 = el.canPlayType('video/mp4; codecs="avc1.42E01E"') .replace(/^no$/,'');
                        bool.webm = el.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,'');
                    }
    
                } catch(e) {}
                _video = bool;
    
                this.supportVideo = function () { return _video; };
                return this.supportVideo();
            }
922032
public static function subrip2webvtt(SubripFile $_srt)
    {
        $vtt = new WebvttFile();
        foreach ($_srt->getCues() as $cue) {
            $vtt->addCue($cue->getText(true), SubripCue::ms2tc($cue->getStartMS(), '.'), SubripCue::ms2tc($cue->getStopMS(), '.'));
        }

        return $vtt;
    }
287983
public function GetOutput() {
        $numberOfVarsExtracted = extract($this->variablesList);
        if (count($this->variablesList) !== $numberOfVarsExtracted) {
            $errMsg = "Number of variables extracted different from the $vars array";
            throw new \Exception($errMsg, Codes\LogicErrors::UNEXPECTED_VALUE, null);
        }
        ob_start();
        include_once $this->contentFile;
        $content = ob_get_clean();
        ob_start();
        include_once "APP_ROOT_DIR" . \Puzzlout\Framework\Enums\FrameworkFolderName::ViewsFolderName . \Puzzlout\Framework\Enums\FileNameConst::LayoutTemplate;
        return ob_get_clean();
    }
831860
public function generate() {
		$tmp_pdf_path = create_tmp_file();
		$success = $this->generateWithPrince( null, null, $this->generateHtml(), $tmp_pdf_path );
		if ( true !== $success ) {
			throw new \Exception( 'Failed to create PDF file' );
		}
		$output_path = $this->timestampedFileName( 'jpg' );
		$this->convert( $tmp_pdf_path, $output_path );
		delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
		return $output_path;
	}
276267
public Video[] getVideo() {
		List<Video> list = getComponentModel().video;
		return list == null ? null : list.toArray(new Video[]{});
	}
601246
public static function getSupportedVideoDecoders()
    {
        // Run terminal command
        $command = self::getConverterPath().' -decoders';
        $output  = shell_exec($command);

        // PREG pattern to retrive version information
        $output = preg_match_all("/[V]([.]|\w)([.]|\w)([.]|\w)([.]|\w)([.]|\w)\s(?P<format>\w{3,20})\s/", $output, $parsed);

        // Verify output
        if ($output === false || $output == 0)
        {
            return false;
        }

        return $parsed['format'];
    }
91448
protected function generateFakeData(): array
    {
        $this->checkEntityIsInConfig();
        $colsInConfig = $this->configEntities[$this->entity]['cols'];
        $row = [];
        foreach ($colsInConfig as $colName => $colProps) {
            $this->checkColIsInEntity($colName);
            $data = \call_user_func_array(
                [$this->getFakerObject($this->entity, $colName, $colProps), $colProps['method']],
                $colProps['params']
            );
            if (!is_scalar($data)) {
                $msg = "You must use faker methods that generate strings: '{$colProps['method']}' forbidden";
                throw new NeuralyzerConfigurationException($msg);
            }
            $row[$colName] = trim($data);
            $colLength = $this->entityCols[$colName]['length'];
            // Cut the value if too long ...
            if (!empty($colLength) && \strlen($row[$colName]) > $colLength) {
                $row[$colName] = substr($row[$colName], 0, $colLength - 1);
            }
        }

        return $row;
    }
965197
public function getFrames()
    {
        if ($this->frames === null) {
            $frames = $this->exception->getTrace();

            // If we're handling an \ErrorException thrown by BooBoo,
            // get rid of the last frame, which matches the handleError method,
            // and do not add the current exception to trace. We ensure that
            // the next frame does have a filename / linenumber, though.
            if ($this->exception instanceof \ErrorException) {
                foreach ($frames as $k => $frame) {
                    if (isset($frame['class']) &&
                        strpos($frame['class'], 'BooBoo') !== false
                    ) {
                        unset($frames[$k]);
                    }
                }
            }

            $this->frames = new FrameCollection($frames);

            if ($previousInspector = $this->getPreviousExceptionInspector()) {
                // Keep outer frame on top of the inner one
                $outerFrames = $this->frames;
                $newFrames = clone $previousInspector->getFrames();
                $newFrames->prependFrames($outerFrames->topDiff($newFrames));
                $this->frames = $newFrames;
            }
        }

        return $this->frames;
    }
1057615
public function render()
    {
        $body = $this->getBody();
        if (!$body) {
            throw new Exception\RuntimeException(
                'Body has not been set'
            );
        }

        $element = $this->getElement();
        $header  = ($this->hasCloseButton() ? $this->renderCloseButton() : '')
            . $this->getHeader();

        if ($header) {
            $element->spawnChild('div')
                ->setContent($header)
                ->addClass('modal-header');
        }

        $element->spawnChild('div')
            ->setContent($body)
            ->addClass('modal-body');

        $footer = $this->getFooter();
        if ($footer) {
            $element->spawnChild('div')
                ->setContent($footer)
                ->addClass('modal-footer');
        }

        $element
            ->addClass('modal')
            ->addAttributes($this->getDataAttributes());

        return $element->render();
    }
421331
protected function doRenderDebug(\Throwable $exception, ?string $outputBuffer = null): array
    {
        $title = Exception::getName($exception);
        $extras = '';

        $this->emit(WebErrorScreenEvents::RENDER_DEBUG, [
            'title' => &$title,
            'extras' => &$extras,
            'exception' => $exception,
            'output_buffer' => $outputBuffer,
        ]);

        $output = '';
        $chain = Exception::getChain($exception);
        $totalExceptions = count($chain);

        for ($i = 0; $i < $totalExceptions; ++$i) {
            $output .= $this->renderException($chain[$i], $i, $totalExceptions);

            if ($i === 0) {
                // render extras after the first exception
                $output .= $extras;
                $output .= $this->renderOutputBuffer($outputBuffer);
                $output .= $this->renderPlaintextTrace($exception);
            }
        }

        return [$title, $output];
    }