Created ClipFilter
This commit is contained in:
		
					parent
					
						
							
								b6ec274d2e
							
						
					
				
			
			
				commit
				
					
						ba7bd90780
					
				
			
		
					 2 changed files with 80 additions and 0 deletions
				
			
		
							
								
								
									
										65
									
								
								src/FFMpeg/Filters/Video/ClipFilter.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								src/FFMpeg/Filters/Video/ClipFilter.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,65 @@ | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | /* | ||||||
|  |  * This file is part of PHP-FFmpeg. | ||||||
|  |  * | ||||||
|  |  * (c) Alchemy <dev.team@alchemy.fr> | ||||||
|  |  * | ||||||
|  |  * For the full copyright and license information, please view the LICENSE | ||||||
|  |  * file that was distributed with this source code. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | namespace FFMpeg\Filters\Video; | ||||||
|  | 
 | ||||||
|  | use FFMpeg\Format\VideoInterface; | ||||||
|  | use FFMpeg\Media\Video; | ||||||
|  | use FFMpeg\Coordinate\TimeCode; | ||||||
|  | 
 | ||||||
|  | class ClipFilter implements VideoFilterInterface | ||||||
|  | { | ||||||
|  |     /** @var TimeCode */ | ||||||
|  |     private $start; | ||||||
|  |     /** @var TimeCode */ | ||||||
|  |     private $duration; | ||||||
|  |     /** @var integer */ | ||||||
|  |     private $priority; | ||||||
|  | 
 | ||||||
|  |     public function __construct(TimeCode $start, TimeCode $duration, $priority = 0) | ||||||
|  |     { | ||||||
|  |     	$this->start = $start; | ||||||
|  |     	$this->duration = $duration; | ||||||
|  |         $this->priority = $priority; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * {@inheritdoc} | ||||||
|  |      */ | ||||||
|  |     public function getPriority() | ||||||
|  |     { | ||||||
|  |         return $this->priority; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @return TimeCode | ||||||
|  |      */ | ||||||
|  |     public function getStart() | ||||||
|  |     { | ||||||
|  |         return $this->start; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @return TimeCode | ||||||
|  |      */ | ||||||
|  |     public function getDuration() | ||||||
|  |     { | ||||||
|  |         return $this->duration; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * {@inheritdoc} | ||||||
|  |      */ | ||||||
|  |     public function apply(Video $video, VideoInterface $format) | ||||||
|  |     { | ||||||
|  |     	return array('-ss', $this->start->__toString(), '-t', $this->duration->__toString()); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -66,6 +66,21 @@ class VideoFilters extends AudioFilters | ||||||
| 
 | 
 | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Clips (cuts) the video. | ||||||
|  |      * | ||||||
|  |      * @param TimeCode $start | ||||||
|  |      * @param TimeCode $duration | ||||||
|  |      * | ||||||
|  |      * @return VideoFilters | ||||||
|  |      */ | ||||||
|  |     public function clip($start, $duration) | ||||||
|  |     { | ||||||
|  |         $this->media->addFilter(new ClipFilter($start, $duration)); | ||||||
|  | 
 | ||||||
|  |         return $this; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Resamples the audio file. |      * Resamples the audio file. | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue