@param MediaInterface $media
@param string         $format

@return string
334814
public function getMediaFormatUrl(MediaInterface $media, $format)
    {
        $key = $media->getFilesystemName();

        if ($format != '' && MediaInterface::MEDIA_ORIGINAL != $format) {
            $key = $media->getAlternative($format);
        }

        return $this->getFileUrl($key);
    }
154805
public function generateThumbnail(MediaInterface $media)
    {
        $fileName = $media->getFilesystemName();
        $thumbnailName = '';

        $extractedImagePath = $this->videoManager->extractImageFromVideo(
            $this->tmpDir . DIRECTORY_SEPARATOR . $fileName,
            1
        );

        $thumbnailPath = $this->imageManager->generateAlternative($extractedImagePath, $this->thumbnailFormat);

        if ('' !== $thumbnailPath) {
            $thumbnailName = self::THUMBNAIL_PREFIX . '-' . pathinfo($fileName, PATHINFO_FILENAME) . '.jpg';
            $this->mediaStorageManager->uploadFile($thumbnailName, $thumbnailPath);
        }

        if (trim($extractedImagePath, DIRECTORY_SEPARATOR) !== trim($this->tmpDir, DIRECTORY_SEPARATOR)) {
            $this->fileSystem->remove(array($extractedImagePath));
        }

        $media->setThumbnail($thumbnailName);
    }
759755
public function getFormatMimeType($format)
    {
        $format = $this->normalizeFormat($format);
        $result = '';
        switch ($format) {
            case static::FORMAT_PNG:
            case static::FORMAT_JPEG:
            case static::FORMAT_GIF:
            case static::FORMAT_XBM:
                $result = 'image/' . $format;
                break;
            case static::FORMAT_WBMP:
                $result = 'image/vnd.wap.wbmp';
                break;
        }

        return $result;
    }
492846
public function formatMessageForBroadcast (TypeInterface $type)
    {
        $json = ['msgtype' => $type->getType()];

        $method = 'format' . ucfirst($type->getType()) . 'ForBroadcast';
        if (method_exists($this, $method)) {
            $json[$type->getType()] = $this->$method($type);
        } elseif ($type instanceof Uploaded) {
            $json[$type->getType()] = ['media_id' => $type->getMediaID()];
        }

        return $json;
    }
147431
public function apply(TranscodeInterface $media, FormatInterface $format)
	{
		$expressions = [
			'%frame%'      => 'n',
			'%frame_time%' => 't',
			'%width%'      => 'in_w',
			'%height%'     => 'in_h',
			'%width_out%'  => 'out_w',
			'%height_out%' => 'out_h',
		];
		
		return [
			'filter:v' => [
				'rotate' => http_build_query([
					'angle'     => str_replace(array_keys($expressions), $expressions, $this->getAngle()),
					'bilinear'  => $this->isBilinear(),
					'fillcolor' => $this->getColor(),
				], null, ':'),
			],
		];
	}
547720
protected function processMedia(MediaInterface $media, MediaProviderInterface $provider, $context, $format)
    {
        $this->log('Deleting thumbs for '.$media->getName().' - '.$media->getId());

        try {
            if ($format === $context.'_all') {
                $format = null;
            }

            $provider->removeThumbnails($media, $format);
        } catch (\Exception $e) {
            $this->log(sprintf('<error>Unable to remove thumbnails, media: %s - %s </error>',
                $media->getId(), $e->getMessage()));

            return false;
        }

        return true;
    }
111345
public function getUrl(MediaInterface $media, $alias = null)
    {
        return $this->filesystemManipulator->url($this->getAliasAndKey($media, $alias));
    }
839036
final public function format($format)
    {
        if(is_null($this->value)) {
            return null;
        } else {
            return $this->value->format($format);
        }
    }
1123290
protected function getFormatChoices(MediaInterface $media = null)
    {
        $formatChoices = [];

        if (!$media instanceof MediaInterface) {
            return $formatChoices;
        }

        $formats = $this->getMediaPool()->getFormatNamesByContext($media->getContext());

        foreach ($formats as $code => $format) {
            $formatChoices[$code] = $code;
        }

        return $formatChoices;
    }
459679
public function format(ElementInterface $element, $format = null)
    {
        if ($element instanceof DoctypeElement) {
            $formats = $this->getOption('formats');
            $doctype = $element->getValue();
            $this->setFormat($doctype);
            if (isset($formats[$doctype])) {
                $element->setValue(null);
            }
        }

        $format = $this->getFormatInstance($format);
        $format->setFormatter($this);

        $formatEvent = new FormatEvent($element, $format);
        $this->trigger($formatEvent);

        $element = $formatEvent->getElement();
        $format = $formatEvent->getFormat();

        $stringifyEvent = new StringifyEvent($formatEvent, $element ? $format($element) : '');
        $this->trigger($stringifyEvent);

        return $stringifyEvent->getOutput();
    }
90572
public function apply(TranscodeInterface $media, FormatInterface $format)
	{
		$options = [
			'seek_start' => (string) $this->getStartTime()
		];
		
		if ($this->getDuration() !== null)
		{
			if ($this->getDuration()->toSeconds() > $media->getDuration())
			{
				throw new \InvalidArgumentException('The duration value exceeds the allowable value.');
			}
			
			$options['seek_end'] = (string) $this->getDuration();
		}
		
		return $options;
	}
875366
public function generateThumbnail(MediaInterface $media)
    {
        $thumbnailName = $this->generateAlternative(
            $media->getFilesystemName(),
            self::THUMBNAIL_PREFIX,
            $this->thumbnailFormat
        );

        $media->setThumbnail($thumbnailName);
    }
1310635
public function path($media, $format)
    {
        if (!$media) {
            return '';
        }

        $provider = $this->getProvider($media);

        $format = $provider->getFormatName($media, $format);

        return $provider->generatePublicUrl($media, $format);
    }
314090
public function displayMediaForWysiwyg(MediaInterface $media, $format = '', $alt = '', $legend = '')
    {
        return $this->render(
            'OpenOrchestraMediaBundle:BBcode/WysiwygDisplay:thumbnail.html.twig',
            array(
                'media_url'    => $this->getFileUrl($media->getThumbnail()),
                'media_alt'    => $alt,
                'media_id'     => $media->getId(),
                'media_legend' => $legend
            )
        );
    }
162077
protected function getMetadata(MediaInterface $media, $url)
    {
        try {
            $metadata = file_get_contents($url);
        } catch (\RuntimeException $e) {
            throw new \RuntimeException('Unable to retrieve the video information for :'.$url, null, $e);
        }

        $metadata = json_decode($metadata, true);

        if (!$metadata) {
            throw new \RuntimeException('Unable to decode the video information for :'.$url);
        }

        return $metadata;
    }
768356
public function getMediaUrl($mediaId, $format)
    {
        $media = $this->getMedia($mediaId);

        if ($media) {
            return $this->displayMediaManager->getMediaFormatUrl($media, $format);
        }

        return '';
    }
1344997
protected function getFormatOptions(FormatInterface $format)
	{
		$options = $format->getOptions();
		
		if ($format instanceof AudioFormatInterface)
		{
			$options['audio_codec'] = (string) $format->getAudioCodec() ?: 'copy';
			
			if ($format->getAudioBitrate() > 0)
			{
				$options['audio_bitrate'] = $format->getAudioBitrate();
			}
			
			if ($format->getFrequency() > 0)
			{
				$options['audio_sample_frequency'] = $format->getFrequency();
			}
			
			if ($format->getChannels() > 0)
			{
				$options['audio_channels'] = $format->getChannels();
			}
		}
		
		if ($format instanceof FrameFormatInterface)
		{
			$options['video_codec'] = (string) $format->getVideoCodec() ?: 'copy';
		}
		
		if ($format instanceof VideoFormatInterface)
		{
			if ($format->getFrameRate() > 0)
			{
				$options['video_frame_rate'] = $format->getFrameRate();
			}
			
			if ($format->getVideoBitrate() > 0)
			{
				$options['video_bitrate'] = $format->getVideoBitrate();
			}
			
			$options['movflags'] = '+faststart';
		}
		
		return $options;
	}