Merge branch 'master' of https://github.com/guimeira/PHP-FFmpeg into guimeira-master
This commit is contained in:
		
				commit
				
					
						7e66785b5d
					
				
			
		
					 3 changed files with 100 additions and 0 deletions
				
			
		
							
								
								
									
										13
									
								
								README.md
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										13
									
								
								README.md
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -175,6 +175,19 @@ filters solves this issue. | ||||||
| $video->filters()->synchronize(); | $video->filters()->synchronize(); | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  | ###### Clip | ||||||
|  | 
 | ||||||
|  | Cuts the video at a desired point. | ||||||
|  | 
 | ||||||
|  | ```php | ||||||
|  | $video->filters()->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15)); | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | The clip filter takes two parameters: | ||||||
|  | 
 | ||||||
|  | - `$start`, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the start point of the clip | ||||||
|  | - `$duration`, optional, an instance of `FFMpeg\Coordinate\TimeCode`, specifies the duration of the clip | ||||||
|  | 
 | ||||||
| #### Audio | #### Audio | ||||||
| 
 | 
 | ||||||
| `FFMpeg\Media\Audio` can be transcoded, ie : change codec, isolate audio or | `FFMpeg\Media\Audio` can be transcoded, ie : change codec, isolate audio or | ||||||
|  |  | ||||||
							
								
								
									
										72
									
								
								src/FFMpeg/Filters/Video/ClipFilter.php
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										72
									
								
								src/FFMpeg/Filters/Video/ClipFilter.php
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,72 @@ | ||||||
|  | <?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 = null, $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) | ||||||
|  |     { | ||||||
|  |         $commands = array('-ss', (string) $this->start); | ||||||
|  | 
 | ||||||
|  |         if ($this->duration !== null) { | ||||||
|  |           $commands[] = '-t'; | ||||||
|  |           $commands[] = (string) $this->duration; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $commands; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										15
									
								
								src/FFMpeg/Filters/Video/VideoFilters.php
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										15
									
								
								src/FFMpeg/Filters/Video/VideoFilters.php
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -67,6 +67,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 = null) | ||||||
|  |     { | ||||||
|  |         $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