extracts streaminformations of an episode from its video.
@param object $episode Entity you want the stream infos from
@return false|array if informations can't be extracted,
array of video and audio info
434938
private function getMetainfoForEpisode($episode) {
        $uri = $this->bprs_asset_helper->getAbsoluteUrl(
            $episode->getVideo()
        );
        if (!$uri) { // can't create uri of episode video
            $this->logbook->error(
                'oktolab_media.episode_encode_no_streams',
                [],
                $episode->getUniqID()
            );
            return false;
        }

        $metainfo = json_decode(
            shell_exec(
                sprintf(
                    'ffprobe -v error -show_streams -print_format json %s',
                    $uri)
                ),
            true
        );
        $metadata = ['video' => false, 'audio' => false];

        // run through all streams to find the primary video and audio stream
        foreach ($metainfo['streams'] as $stream) {
            // found both streams, skip the rest
            if ($metadata['video'] && $metadata['audio']) {
                break;
            }

            // found an audio stream
            if ($stream['codec_type'] == "audio" && $metadata['audio'] == false) {
                $metadata['audio'] = $stream;
                if (
                    !array_key_exists('max_bit_rate', $metadata['audio']) &&
                    array_key_exists('tags', $metadata['audio'])
                ) {
                    $metadata['audio']['max_bit_rate'] = $metadata['tags']['BPS'];
                }
            }

            if ($stream['codec_type'] == "video") {
                $metadata['video'] = $stream;
                if (!array_key_exists('duration', $metadata['video'])) {
                    $metadata['video']['duration'] = 0;
                } else {
                    $episode->setDuration($metadata['video']['duration']);
                }
            }
        }

        return $metadata;
    }
490332
private function createNewCacheAssetForResolution($episode, $resolution) {
        $asset = $this->getContainer()->get('bprs.asset')->createAsset();
        $asset->setFilekey(
            sprintf('%s.%s',$asset->getFilekey(), $resolution['container'])
        );
        $asset->setAdapter(
            $this->getContainer()->getParameter(
                'oktolab_media.encoding_filesystem'
            )
        );
        $asset->setName($episode->getVideo()->getName());
        $asset->setMimetype($resolution['mimetype']);

        return $asset;
    }
5575
protected function extract(array $files)
    {
        foreach ($files as $key => $file) {
            if ($file instanceof Doozr_Request_File) {

                // Simple security layer
                $filename = $this->cleanFilename($file->getClientFilename());

                // @todo Move to a basic validation applied always for files if enabled in configuration.
                #$mediaType = $this->getMimeTypeByExtension(pathinfo($filename)['extension']);

                /* @var Doozr_Request_File $file */
                // Put everything in a simple array structure ...
                $files[$key] = [
                    'name'     => $filename,
                    'type'     => $file->getClientMediaType(),
                    'tmp_name' => $file->getTemporaryName(),
                    'error'    => $file->getError(),
                    'size'     => $file->getSize(),
                    'emulated' => false,
                ];
            } else {
                $files[$key] = $this->extract($file);
            }
        }

        return $files;
    }
1062274
private function generateThumbs($episode, $cache_asset)
    {
        $uri = $this->asset_helper->getAbsoluteUrl($episode->getVideo());
        $path = $this->asset_helper->getPath($cache_asset, true);
        $cmd = sprintf(
            "ffmpeg -i %s -s %sx%s -vf fps=1/%s %s 2>&1",
            $uri,
            $this->sprite_width,
            $this->sprite_height,
            $this->sprite_interval,
            $path
        );
        // open (ffmpeg) process, read stdout to get duration if unknown to this point.
        $fp = popen($cmd, "r");
        while(!feof($fp)) {
            // read outputstream of ffmpeg
            $chunk = fread($fp, 1024);

            // try to get the duration information at the beginning of the ffmpeg output.
            if (!$episode->getDuration()) {
                preg_match("/Duration: (.*?), start:/", $chunk, $matches);
                if (array_key_exists(1, $matches)) {
                    list($hours,$minutes,$seconds) = explode(":",$matches[1]);
                    // calculate the duration in seconds. Used to calculate overall progress in percent.
                    $episode->setDuration((($hours * 3600) + ($minutes * 60) + $seconds));
                }
            }
            // flush the content to the browser
            flush();
        }
        fclose($fp);
    }
44362
private function finalizeEpisode($episode) {
        $event = new EncodedEpisodeEvent($episode);
        $this->getContainer()->get('event_dispatcher')->dispatch(
            OktolabMediaEvent::ENCODED_EPISODE,
            $event
        );

        $this->oktolab_media->addFinalizeEpisodeJob(
            $episode->getUniqID(),
            false,
            true
        );
    }
755185
public function editAction(Request $request, $episode)
    {
        $entity = $episode;

        $editForm = $this->createEditForm($entity);
        $deleteForm = $this->createDeleteForm($id);

        return [
            'entity' => $entity,
            'form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ];
    }
633736
public function getVideoInfo($src) {
    $lines = array();
    if (!is_readable($src)) {
      throw new \Exception("Source file '$src' is not readable");
    }
    $this->Process->run($this->config['ffmpeg.bin'], array('-i', $src), $lines);
    if (count($lines)) {
      return $this->parseInfo($lines);
    }
    return false;
  }
1221083
protected function canReadStream(GetEventsRequest $request, Pbjx $pbjx): bool
    {
        /** @var StreamId $streamId */
        $streamId = $request->get('stream_id');

        /*
         * a simplistic but mostly correct assertion that requests tend
         * to be named "acme:news:request:get-[node-label]-history-request".
         * If the incoming request is asking for that topic it is allowed.
         *
         * This only exists to prevent someone with permission to get
         * history on one thing but pass in a different stream id
         * (message permission vs message content permission).
         *
         * Override if more complex check is desired or if the convention
         * doesn't match.
         */
        $allowedTopic = str_replace(
            ['get-', '-request', '-history'],
            ['', '', '.history'],
            $request::schema()->getCurie()->getMessage()
        );

        return $allowedTopic === $streamId->getTopic();
    }
101751
def get_episode(self, episode_id):
        

        raw_response = requests_util.run_request('get', self.API_BASE_URL + '/episodes/%d' % episode_id,
                                                 headers=self.__get_header_with_auth())

        return self.parse_raw_response(raw_response)
190519
public function processStream($event)
    {
        /**
         * @var Request $event->message
         */
        
        if($event->message->isCtlFrame()) {
            if($event->message->isCloseFrame()) {
                return $this->processClose($event);
            }else if($event->message->isPingFrame()){
                return $this->processPing($event);
            }else if($event->message->isPongFrame()){
                return $this->processPong($event);
            }
            
        }else{
            return $this->processData($event);
        }
    }
72177
protected function getCaptions($videoInfo, $detailed=false) {
		$index = 0;
		$captions = array();
		$captionTracks = explode(',', $videoInfo['caption_tracks']);

		foreach($captionTracks as $captionTrack) {
			$decodedTrack = $this->decodeString($captionTrack);

			$language = $index++;

			if (isset($decodedTrack['lc']))
				$language = $decodedTrack['lc'];

			if (isset($decodedTrack['v']) && $decodedTrack['v'][0] != '.')
				$language = $decodedTrack['v'];

			if ($detailed)
				$captions[$language] = $decodedTrack;
			else
				$captions[$language] = $decodedTrack['n'];
		}

		return $captions;
	}
917304
public function getOptionsForSeries( $series )
    {
        $seriesTitle = $this->getSeriesTitle( $series );
        if (! isset( $this->options['seriesStorage'][$seriesTitle] ) ) {
            throw new \Exception( 'Series not registered with JsWriter' );
        } 
        return $this->options['seriesStorage'][$seriesTitle];
    }
1363812
public static function createTwitterTagsForEpisode($episode, $show) {
        return [
            'twitter:card'        => Config::get('lasallecmsfrontend.twitter_card'),
            'twitter:site'        => Config::get('lasallecmsfrontend.twitter_site'),
            'twitter:title'       => $episode->title,
            'twitter:description' => $episode->meta_description,
            'twitter:creator'     => Config::get('lasallecmsfrontend.twitter_creator'),
            //'twitter:image:src'   => self::determineEpisodeImagePath($episode, $show),
            'twitter:image'       => self::determineEpisodeImagePath($episode, $show),
        ];
    }
245862
private function getReviewEpisode($top_area)
    {
        $episode = $top_area->find('div div', 1)->plaintext;
        $episode = str_replace(['episodes seen', 'chapters read'], '', $episode);

        return trim($episode);
    }
846773
public function extract($file, $destination = false)
    {
        $archive = $this->getArchiver()->open($file);
        if ($archive) {
            $this->getArchiver()->extractTo($destination);
            return $this->getArchiver()->close();
        }
    }
657923
public static function createMetaTagsForEpisode($episode) {
        return [
            'page_title'             => $episode->title . '&verbar;' . Config::get('lasallecmsfrontend.og_site_name'),
            'canonical_url'          => $episode->canonical_url,
            'meta_description'       => $episode->meta_description,
        ];
    }
1238821
private Episode getTVEpisode(String seriesId, int seasonNbr, int episodeNbr, String language, String episodeType) throws TvDbException {
        if (!isValidNumber(seriesId) || !isValidNumber(seasonNbr) || !isValidNumber(episodeNbr)) {
            // Invalid number passed
            return new Episode();
        }

        StringBuilder urlBuilder = new StringBuilder();
        urlBuilder.append(BASE_URL)
                  .append(apiKey)
                  .append(SERIES_URL)
                  .append(seriesId)
                  .append(episodeType)
                  .append(seasonNbr)
                  .append("/")
                  .append(episodeNbr)
                  .append("/");
        if (StringUtils.isNotBlank(language)) {
            urlBuilder.append(language).append(XML_EXTENSION);
        }

        LOG.trace(URL, urlBuilder.toString());
        return TvdbParser.getEpisode(urlBuilder.toString());
    }