Change the resize, it now depends of the format
This commit is contained in:
		
					parent
					
						
							
								b1e6eeaf95
							
						
					
				
			
			
				commit
				
					
						68852ca65a
					
				
			
		
					 2 changed files with 33 additions and 54 deletions
				
			
		|  | @ -219,55 +219,34 @@ class FFMpeg extends Binary | ||||||
| 
 | 
 | ||||||
|         $cmd_part2 = ''; |         $cmd_part2 = ''; | ||||||
| 
 | 
 | ||||||
|         if ($format->getWidth() && $format->getHeight()) { |         if ($format instanceof Format\ResizableVideo) { | ||||||
| 
 |             if ( ! $this->prober) { | ||||||
|             switch ($format->getResizeMode()) { |                 throw new LogicException('You must set a valid prober if you use RESIZEMODE_INSET'); | ||||||
|                 case Video::RESIZEMODE_FIT: |  | ||||||
|                 default: |  | ||||||
|                     $width = $this->getMultiple($format->getWidth(), 16); |  | ||||||
|                     $height = $this->getMultiple($format->getHeight(), 16); |  | ||||||
|                     break; |  | ||||||
|                 case Video::RESIZEMODE_INSET: |  | ||||||
| 
 |  | ||||||
|                     if ( ! $this->prober) { |  | ||||||
|                         throw new LogicException('You must set a valid prober if you use RESIZEMODE_INSET'); |  | ||||||
|                     } |  | ||||||
| 
 |  | ||||||
|                     $result = $this->prober->probeStreams($this->pathfile); |  | ||||||
| 
 |  | ||||||
|                     $originalWidth = $format->getWidth(); |  | ||||||
|                     $originalHeight = $format->getHeight(); |  | ||||||
| 
 |  | ||||||
|                     foreach ($result as $stream) { |  | ||||||
|                         foreach ($stream as $info) { |  | ||||||
|                             if (strpos($info, 'width=') === 0) { |  | ||||||
|                                 $originalWidth = substr($info, 6); |  | ||||||
|                                 continue; |  | ||||||
|                             } |  | ||||||
|                             if (strpos($info, 'height=') === 0) { |  | ||||||
|                                 $originalHeight = substr($info, 7); |  | ||||||
|                                 continue; |  | ||||||
|                             } |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                      |  | ||||||
|                     $originalRatio = $originalWidth / $originalHeight; |  | ||||||
|                      |  | ||||||
|                     $targetRatio = $format->getWidth() / $format->getHeight(); |  | ||||||
|                      |  | ||||||
|                     if($targetRatio >= $originalRatio){ |  | ||||||
|                         $height = $format->getHeight(); |  | ||||||
|                         $width = $format->getHeight() * $originalRatio; |  | ||||||
|                     }else{ |  | ||||||
|                         $width = $format->getWidth(); |  | ||||||
|                         $height = $format->getWidth() / $originalRatio; |  | ||||||
|                     } |  | ||||||
| 
 |  | ||||||
|                     $width = $this->getMultiple($width, 16); |  | ||||||
|                     $height = $this->getMultiple($height, 16); |  | ||||||
|                     break; |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             $result = $this->prober->probeStreams($this->pathfile); | ||||||
|  | 
 | ||||||
|  |             $originalWidth = $format->getWidth(); | ||||||
|  |             $originalHeight = $format->getHeight(); | ||||||
|  | 
 | ||||||
|  |             foreach ($result as $stream) { | ||||||
|  |                 foreach ($stream as $info) { | ||||||
|  |                     if (strpos($info, 'width=') === 0) { | ||||||
|  |                         $originalWidth = substr($info, 6); | ||||||
|  |                         continue; | ||||||
|  |                     } | ||||||
|  |                     if (strpos($info, 'height=') === 0) { | ||||||
|  |                         $originalHeight = substr($info, 7); | ||||||
|  |                         continue; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             list($width, $height) = $format->getComputedDimensions($originalWidth, $originalHeight); | ||||||
|  | 
 | ||||||
|  |             $width = $this->getMultiple($format->getWidth(), 16); | ||||||
|  |             $height = $this->getMultiple($format->getHeight(), 16); | ||||||
|  | 
 | ||||||
|             $cmd_part2 .= ' -s ' . $width . 'x' . $height; |             $cmd_part2 .= ' -s ' . $width . 'x' . $height; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue