Fix using rotate and resize filters at the same time (#78)
This commit is contained in:
		
					parent
					
						
							
								5a9d4a0f04
							
						
					
				
			
			
				commit
				
					
						fca866e1d8
					
				
			
		
					 8 changed files with 118 additions and 7 deletions
				
			
		|  | @ -50,6 +50,21 @@ abstract class AbstractData implements \Countable | |||
|         return $this->properties[$property]; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Sets the property value given its name. | ||||
|      * | ||||
|      * @param  string $property | ||||
|      * @param  mixed  $value | ||||
|      * | ||||
|      * @return AbstractData | ||||
|      */ | ||||
|     public function set($property, $value) | ||||
|     { | ||||
|         $this->properties[$property] = $value; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns all property names. | ||||
|      * | ||||
|  |  | |||
|  | @ -55,6 +55,16 @@ class RotateFilter implements VideoFilterInterface | |||
|      */ | ||||
|     public function apply(Video $video, VideoInterface $format) | ||||
|     { | ||||
|         if (in_array($this->angle, array(self::ROTATE_90, self::ROTATE_270), true)) { | ||||
|             foreach ($video->getStreams()->videos() as $stream) { | ||||
|                 if ($stream->has('width') && $stream->has('height')) { | ||||
|                     $width = $stream->get('width'); | ||||
|                     $stream->set('width', $stream->get('height')); | ||||
|                     $stream->set('height', $width); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return array('-vf', $this->angle, '-metadata:s:v:0', 'rotate=0'); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -96,9 +96,9 @@ class VideoFilters extends AudioFilters | |||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function rotate($angle, $priority = 0) | ||||
|     public function rotate($angle) | ||||
|     { | ||||
|         $this->media->addFilter(new RotateFilter($angle, $priority)); | ||||
|         $this->media->addFilter(new RotateFilter($angle, 30)); | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
|  |  | |||
|  | @ -16,12 +16,18 @@ use FFMpeg\FFProbe\DataMapping\StreamCollection; | |||
| 
 | ||||
| abstract class AbstractStreamableMedia extends AbstractMediaType | ||||
| { | ||||
|     private $streams; | ||||
| 
 | ||||
|     /** | ||||
|      * @return StreamCollection | ||||
|      */ | ||||
|     public function getStreams() | ||||
|     { | ||||
|         return $this->ffprobe->streams($this->pathfile); | ||||
|         if (null === $this->streams) { | ||||
|             $this->streams = $this->ffprobe->streams($this->pathfile); | ||||
|         } | ||||
| 
 | ||||
|         return $this->streams; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue