Apply filter.

@param TranscodeInterface $media
@param FormatInterface    $format

@return array
434573
public function apply(TranscodeInterface $media, FormatInterface $format)
	{
		return [
			'filter:v' => [
				'crop' => http_build_query([
					'out_w' => $this->getDimension()->getWidth(),
					'out_h' => $this->getDimension()->getHeight(),
					'x'     => $this->getPoint()->getX(),
					'y'     => $this->getPoint()->getX()
				], null, ':')
			]
		];
	}
768356
public function getMediaUrl($mediaId, $format)
    {
        $media = $this->getMedia($mediaId);

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

        return '';
    }
274287
protected function applyDefaultFormat($format, $options, $data)
    {
        $aClassFunc = $this->getFuncParams($options);

        $params = array_key_exists('params', $format) && isset($options['params']) ? $format['params'] : [];

        if (!is_array($params)) {
            $params = [$params];
        }

        array_unshift($params, $data);

        $object = (new \ReflectionClass($aClassFunc['class']))->newInstance();

        $data = call_user_func_array([$object, $aClassFunc['method']], $params);

        return $data;
    }
249016
public static function canEncode($format)
    {
        $formats = array_merge(self::getSupportedAudioEncoders(), self::getSupportedVideoEncoders());

        // Return boolean if they can be encoded or not
        if(!in_array($format, $formats)) 
        {
            return false;
        } else {
            return true;
        }
    }
527780
public function apply(TranscodeInterface $media, FormatInterface $format)
	{
		if ( ! $format instanceof FrameFormatInterface)
		{
			throw new \InvalidArgumentException('The filter resize can be used only with the format of the frame.');
		}
		
		$format = $media->getFormat();
		$dimension = new Dimension($format->getWidth(), $format->getHeight());
		
		if ($this->width && ! $this->height) // Resize to width
		{
			$this->height = $this->width / $dimension->getRatio();
		}
		
		if ( ! $this->width && $this->height) // Resize to height
		{
			$this->width = $this->height * $dimension->getRatio();
		}
		
		// If the dimensions are the same, there's no need to resize.
		if($dimension->getWidth() === $this->width && $dimension->getHeight() === $this->height)
		{
			return [];
		}
		
		return [
			'filter:v' => [
				'scale' => http_build_query([
					'w' => $this->width,
					'h' => $this->height
				], null, ':')
			]
		];
	}
6487
public function getDocs($format = 'array')
    {
        if ($format == 'json') {
            $filler = [];
            foreach ($this->docs as $doc) {
                $filler[] = $doc->toArray();
            }

            return json_encode($filler, true);
        }

        return $this->docs;
    }
807081
protected function prepareFile(Media $media): array
    {
        return [
            'id' => $media->id,
            'name' => $media->name,
            'size' => 1024,
            'file' => $media->getUrl(),
            'type' => $media->type,
            'data' => [
                'url' => $media->getUrl(),
                'thumbnail' => $media->getUrl(),
                'id' => $media->id,
            ]
        ];
    }
1152229
private function getMimeType($format)
    {
        $format = $this->normalizeFormat($format);

        static $mimeTypes = array(
            'jpeg' => 'image/jpeg',
            'gif'  => 'image/gif',
            'png'  => 'image/png',
            'wbmp' => 'image/vnd.wap.wbmp',
            'xbm'  => 'image/xbm',
        );

        if (!isset($mimeTypes[$format])) {
            throw new \RuntimeException('Invalid format');
        }

        return $mimeTypes[$format];
    }
1319248
protected function applyFilterToMediaCollection(Collection $media, $filter): Collection
    {
        if (is_array($filter)) {
            $filter = $this->getDefaultFilterFunction($filter);
        }

        return $media->filter($filter);
    }
1223888
protected function getExportOption($key, $format)
    {
        if ('1.2.xliff' !== $format) {
            return;
        }

        $translate = true;

        if (in_array(
            $key,
            $this->seoAttributes
        )) {
            $translate = false;
        }

        return [
            'translate' => $translate,
        ];
    }
521386
public function apply(TranscodeInterface $media, FormatInterface $format)
	{
		$options = [
			't'     => $this->getEffectType(),
			'st'    => (string) $this->getStartTime(),
			'curve' => $this->getCurve()
		];
		
		if ($this->getNumberSamples() !== null)
		{
			$options['ns'] = $this->getNumberSamples();
		}
		
		if ($this->getDuration() !== null)
		{
			$options['d'] = (string) $this->getDuration();
		}
		
		if ($this->getStartSample() !== null)
		{
			$options['ss'] = $this->getStartSample();
		}
		
		return [
			'filter:a' => [
				'afade' => http_build_query($options, null, ':')
			]
		];
	}
227974
private function parseMediaToString($media, array $rules)
    {
        if ($media == '') {
            return
                join(
                    '',
                    array_map(
                        function (Rule $rule) {
                            return $this->parsePropertiesToString($rule->getSelector(), $rule->getProperties());
                        },
                        $rules
                    )
                );

        }

        return "$media { " . join(
                '',
                array_map(
                    function (Rule $rule) {
                        return $this->parsePropertiesToString($rule->getSelector(), $rule->getProperties());
                    },
                    $rules
                )
            ) . "}";
    }
1144525
public function media($media, $format, $options = [])
    {
        return $this->getTwigExtension()->media($media, $format, $options);
    }
81446
public function normalize($object, $format = null, array $context = [])
    {
        $normalized = [];
        foreach ($object->getDefinition()->getFields() as $field) {
            if (isset($object->{$key = $field->getName()})) {
                if ($field instanceof SerializerAwareInterface) {
                    $field->setSerializer($this->serializer);
                }

                $normalized[$key] = $field->normalize($object->{$key}, $format, $context);
            }
        }

        return $normalized;
    }
66070
protected function getMaxUncompressionSpeedFormat(FormatInterface $format, array $methods)
    {
        $maxSpeed = MethodInterface::SPEED_LEVEL_LOWEST;

        foreach ($methods as $method) {
            if ($method->isSupported() && $method->isFormatSupported($format)) {
                $maxSpeed = max($maxSpeed, $method->getUncompressionSpeedLevel($format));
            }
        }

        if ($format instanceof ComposedFormatInterface) {
            $maxSpeedComposed = MethodInterface::SPEED_LEVEL_LOWEST;
            $subformats = $format->getComposedFormats();
            foreach ($subformats as $subformat) {
                $maxSpeedComposed = max($maxSpeedComposed, $this->getMaxUncompressionSpeedFormat($subformat, $methods) / count($subformats));
            }
        }

        return $maxSpeed;
    }
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, ':'),
			],
		];
	}
466522
protected function applyCustomFormat($format, $data)
    {
        $aClassFunc = $this->getFuncParams($format);

        $params = array_key_exists(
            'params',
            $format
        ) ? $format['params'] : [];

        array_unshift($params, $data);

        $object = (new \ReflectionClass($aClassFunc['class']))->newInstance();

        $data = call_user_func_array([$object, $aClassFunc['method']], $params);

        return $data;
    }