77 public function getExtraParams () {
88 return $ this ->extra_params ;
99 }
10-
10+
1111 public function setExtraParams ($ value ) {
1212 $ this ->extra_params = $ value ;
1313 }
14-
14+
1515 public function getAvailableAudioCodecs () {
1616 return array ();
1717 }
1818
1919 public function getAvailableVideoCodecs () {
2020 return array ();
2121 }
22-
22+
2323 public function supportBFrames () {
2424 return false ;
2525 }
@@ -31,28 +31,28 @@ public function supportBFrames() {
3131
3232 public function getExtraParams () {
3333 return array ("-profile:v " , "baseline " , "-f " , "mp4 " , "-pix_fmt " , "yuv420p " );
34- }
35-
34+ }
35+
3636}
3737
3838
3939Class MapAndMergeFilter implements FFMpeg \Filters \Video \VideoFilterInterface {
40-
40+
4141 private $ priority ;
42-
42+
4343 private $ filename ;
44-
44+
4545 private $ mapOriginal ;
46-
46+
4747 private $ mapThis ;
48-
48+
4949 public function __construct ($ filename , $ mapOriginal = 0 , $ mapThis = 1 , $ priority = 13 ) {
5050 $ this ->priority = $ priority ;
5151 $ this ->filename = $ filename ;
5252 $ this ->mapOriginal = $ mapOriginal ;
5353 $ this ->mapThis = $ mapThis ;
5454 }
55-
55+
5656 public function getPriority () {
5757 return $ this ->priority ;
5858 }
@@ -67,19 +67,19 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
6767 "-map " ,
6868 "1: " . $ this ->mapThis
6969 );
70- }
70+ }
7171
7272}
7373
7474
7575Class AudioOnlyFilter implements FFMpeg \Filters \Video \VideoFilterInterface {
76-
76+
7777 private $ priority ;
78-
78+
7979 public function __construct ($ priority = 0 ) {
8080 $ this ->priority = $ priority ;
8181 }
82-
82+
8383 public function getPriority () {
8484 return $ this ->priority ;
8585 }
@@ -89,21 +89,43 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
8989 return array (
9090 "-vn "
9191 );
92- }
92+ }
93+
94+ }
95+
96+
97+ Class VideoOnlyFilter implements FFMpeg \Filters \Video \VideoFilterInterface {
98+
99+ private $ priority ;
100+
101+ public function __construct ($ priority = 0 ) {
102+ $ this ->priority = $ priority ;
103+ }
104+
105+ public function getPriority () {
106+ return $ this ->priority ;
107+ }
108+
109+ public function apply (FFMpeg \Media \Video $ video , FFMpeg \Format \VideoInterface $ format )
110+ {
111+ return array (
112+ "-an "
113+ );
114+ }
93115
94116}
95117
96118
97119Class WatermarkFilter implements FFMpeg \Filters \Video \VideoFilterInterface {
98-
120+
99121 private $ priority ;
100-
122+
101123 private $ filename ;
102-
124+
103125 private $ scale_of_video ;
104-
126+
105127 private $ positionx ;
106-
128+
107129 private $ positiony ;
108130
109131 public function __construct ($ filename , $ scale_of_video = 0.25 , $ positionx = 0.95 , $ positiony = 0.95 , $ priority = 0 ) {
@@ -132,17 +154,17 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
132154 }
133155 }
134156 }
135-
157+
136158 $ image = getimagesize ($ this ->filename );
137159 $ image_width = $ image [0 ];
138160 $ image_height = $ image [1 ];
139-
161+
140162 $ scale_width = $ image_width ;
141163 $ scale_height = $ image_height ;
142-
164+
143165 $ max_width = floor ($ originalWidth * $ this ->scale_of_video );
144166 $ max_height = floor ($ originalHeight * $ this ->scale_of_video );
145-
167+
146168 if ($ image_width > $ max_width || $ image_height > $ max_height ) {
147169 if ($ image_width * $ max_height > $ image_height * $ max_width ) {
148170 $ scale_width = $ max_width ;
@@ -152,24 +174,24 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
152174 $ scale_width = round ($ image_width * $ max_height / $ image_height );
153175 }
154176 }
155-
177+
156178 $ posx = floor ($ this ->positionx * ($ originalWidth - $ scale_width ));
157179 $ posy = floor ($ this ->positiony * ($ originalHeight - $ scale_height ));
158-
180+
159181 $ commands = array (
160182 "-vf " ,
161183 'movie= ' . $ this ->filename . ',scale= ' . $ scale_width . ": " . $ scale_height . '[wm];[in][wm]overlay= ' . $ posx . ': ' . $ posy . '[out] '
162184 );
163185
164186 return $ commands ;
165- }
187+ }
166188}
167189
168190
169191Class DurationFilter implements FFMpeg \Filters \Video \VideoFilterInterface {
170-
192+
171193 private $ priority ;
172-
194+
173195 private $ duration ;
174196
175197 public function __construct ($ duration , $ priority = 0 ) {
@@ -186,7 +208,7 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
186208 "-t " ,
187209 $ this ->duration . ""
188210 );
189- }
211+ }
190212}
191213
192214
@@ -216,13 +238,13 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
216238 }
217239 }
218240 }
219-
241+
220242 $ cropping = $ this ->cropping ;
221243 $ w = isset ($ cropping ["width " ]) ? $ cropping ["width " ] : $ originalWidth ;
222244 $ h = isset ($ cropping ["height " ]) ? $ cropping ["height " ] : $ originalHeight ;
223245 $ x = isset ($ cropping ["x " ]) ? $ cropping ["x " ] : (ceil (($ originalWidth - $ w ) / 2 ));
224246 $ y = isset ($ cropping ["y " ]) ? $ cropping ["y " ] : (ceil (($ originalHeight - $ h ) / 2 ));
225-
247+
226248 return array (
227249 "-vf " ,
228250 "crop= " . join (": " , array ($ w , $ h , $ x , $ y ))
@@ -245,7 +267,7 @@ public function getPriority() {
245267 }
246268
247269 public function apply (FFMpeg \Media \Video $ video , FFMpeg \Format \VideoInterface $ format ) {
248-
270+
249271 $ originalWidth = $ originalHeight = null ;
250272
251273 foreach ($ video ->getStreams () as $ stream ) {
@@ -258,22 +280,22 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
258280 }
259281 }
260282 }
261-
283+
262284 $ originalRatio = $ originalWidth / $ originalHeight ;
263285 if ($ originalRatio == $ this ->ratio )
264286 return array ();
265-
287+
266288 $ w = $ originalWidth ;
267289 $ h = $ originalHeight ;
268-
290+
269291 if ($ originalRatio > $ this ->ratio )
270292 $ w = $ originalHeight * $ this ->ratio ;
271- else
293+ else
272294 $ h = $ originalWidth / $ this ->ratio ;
273-
295+
274296 $ x = ceil (($ originalWidth - $ w ) / 2 );
275297 $ y = ceil (($ originalHeight - $ h ) / 2 );
276-
298+
277299 return array (
278300 "-vf " ,
279301 "crop= " . join (": " , array ($ w , $ h , $ x , $ y ))
@@ -376,17 +398,17 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
376398
377399
378400Class RotationFilter implements FFMpeg \Filters \Video \VideoFilterInterface {
379-
401+
380402 private $ priority ;
381-
403+
382404 private $ rotation ;
383-
405+
384406 private $ transpose ;
385407 private $ doubleflip ;
386408
387409 public function __construct ($ rotation , $ priority = 0 ) {
388410 $ this ->priority = $ priority ;
389- $ this ->rotation = $ rotation ;
411+ $ this ->rotation = $ rotation ;
390412 $ this ->transpose = 0 ;
391413 $ this ->doubleflip = false ;
392414 if ($ this ->rotation == 90 )
@@ -412,27 +434,27 @@ public function apply(FFMpeg\Media\Video $video, FFMpeg\Format\VideoInterface $f
412434 $ result [] = "hflip,vflip " ;
413435 }
414436 $ result [] = "-metadata:s:v:0 " ;
415- $ result [] = "rotate=0 " ;
437+ $ result [] = "rotate=0 " ;
416438 return $ result ;
417439 }
418-
440+
419441 public function getTranspose () {
420442 }
421443}
422444
423445
424446Class RotationFrameFilter implements FFMpeg \Filters \Frame \FrameFilterInterface {
425-
447+
426448 private $ priority ;
427-
449+
428450 private $ rotation ;
429-
451+
430452 private $ transpose ;
431453 private $ doubleflip ;
432454
433455 public function __construct ($ rotation , $ priority = 0 ) {
434456 $ this ->priority = $ priority ;
435- $ this ->rotation = $ rotation ;
457+ $ this ->rotation = $ rotation ;
436458 $ this ->transpose = 0 ;
437459 $ this ->doubleflip = false ;
438460 if ($ this ->rotation == 90 )
@@ -458,10 +480,10 @@ public function apply(FFMpeg\Media\Frame $frame) {
458480 $ result [] = "hflip,vflip " ;
459481 }
460482 $ result [] = "-metadata:s:v:0 " ;
461- $ result [] = "rotate=0 " ;
483+ $ result [] = "rotate=0 " ;
462484 return $ result ;
463485 }
464-
486+
465487 public function getTranspose () {
466488 }
467489}
@@ -528,7 +550,7 @@ public function areStandardsForced()
528550 {
529551 return $ this ->forceStandards ;
530552 }
531-
553+
532554 public function apply (FFMpeg \Media \Video $ video , FFMpeg \Format \VideoInterface $ format )
533555 {
534556 $ dimensions = null ;
@@ -591,7 +613,7 @@ private function getComputedDimensions(FFMpeg\Coordinate\Dimension $dimension, $
591613
592614 return new FFMpeg \Coordinate \Dimension ($ width , $ height );
593615 }
594-
616+
595617}
596618
597619
0 commit comments