scratch – Blame information for rev 115
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
115 | office | 1 | <?php |
2 | /* |
||
3 | * This file is part of PHP-FFmpeg. |
||
4 | * |
||
5 | * (c) Alchemy <dev.team@alchemy.fr> |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | */ |
||
10 | |||
11 | namespace FFMpeg\Filters\Video; |
||
12 | |||
13 | use FFMpeg\Coordinate\Dimension; |
||
14 | use FFMpeg\Coordinate\Point; |
||
15 | use FFMpeg\Format\VideoInterface; |
||
16 | use FFMpeg\Media\Video; |
||
17 | |||
18 | class CropFilter implements VideoFilterInterface |
||
19 | { |
||
20 | /** @var integer */ |
||
21 | protected $priority; |
||
22 | /** @var Dimension */ |
||
23 | protected $dimension; |
||
24 | /** @var Point */ |
||
25 | protected $point; |
||
26 | |||
27 | public function __construct(Point $point, Dimension $dimension, $priority = 0) |
||
28 | { |
||
29 | $this->priority = $priority; |
||
30 | $this->dimension = $dimension; |
||
31 | $this->point = $point; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | public function getPriority() |
||
38 | { |
||
39 | return $this->priority; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function apply(Video $video, VideoInterface $format) |
||
46 | { |
||
47 | foreach ($video->getStreams()->videos() as $stream) { |
||
48 | if ($stream->has('width') && $stream->has('height')) { |
||
49 | $stream->set('width', $this->dimension->getWidth()); |
||
50 | $stream->set('height', $this->dimension->getHeight()); |
||
51 | } |
||
52 | } |
||
53 | |||
54 | return array( |
||
55 | '-filter:v', |
||
56 | 'crop=' . |
||
57 | $this->dimension->getWidth() .':' . $this->dimension->getHeight() . ':' . $this->point->getX() . ':' . $this->point->getY() |
||
58 | ); |
||
59 | } |
||
60 | } |