|
23 | 23 | // The number of threads that FFMpeg should use |
24 | 24 | ] ); |
25 | 25 |
|
| 26 | +$clip1 = $ffmpeg->open( new \Sharapov\FFMpegExtensions\Input\File( getcwd() . '/examples/source/demo_video_720p_HD.mp4' ) ); |
| 27 | + |
| 28 | +// Create complex filter collection |
| 29 | +$options = new \Sharapov\FFMpegExtensions\Filters\Video\FilterComplexOptions\OptionsCollection(); |
| 30 | + |
| 31 | +// Create drawtext option 1 |
| 32 | +$text1 = new \Sharapov\FFMpegExtensions\Filters\Video\FilterComplexOptions\OptionDrawText(); |
| 33 | +$text1 |
| 34 | + // Set z-index property. Greater value is always in front |
| 35 | + ->setZIndex(160) |
| 36 | + // You can use fade-in and fade-out effects. Set time in seconds |
| 37 | + ->setFadeIn(2) |
| 38 | + ->setFadeOut(2) |
| 39 | + // Set font path |
| 40 | + ->setFontFile(new \Sharapov\FFMpegExtensions\Input\File(getcwd() . '/examples/source/calibri.ttf')) |
| 41 | + // Set font color. Accepts transparency value as the second argument. Float value between 0 and 1. |
| 42 | + ->setFontColor('#ffffff') |
| 43 | + // Set font size in pixels |
| 44 | + ->setFontSize(33) |
| 45 | + // Set text string |
| 46 | + ->setText('php-ffmpeg-extensions>library') |
| 47 | + // Coordinates where the text should be rendered. Accepts positive integer or |
| 48 | + // constants "(w-tw)/2", "(h-th)/2" to handle auto-horizontal, auto-vertical values |
| 49 | + ->setCoordinates(new \Sharapov\FFMpegExtensions\Coordinate\Point(\Sharapov\FFMpegExtensions\Coordinate\Point::AUTO_HORIZONTAL, 50)) |
| 50 | + // Set timings (start, stop) in seconds. Accepts float values as well |
| 51 | + ->setTimeLine(new \Sharapov\FFMpegExtensions\Coordinate\TimeLine(1, 20)); |
| 52 | + |
| 53 | +// Pass option to the options collection |
| 54 | +$options |
| 55 | + ->add($text1); |
| 56 | + |
| 57 | +// Apply filter options to video |
| 58 | +$clip1 |
| 59 | + ->filters() |
| 60 | + ->complex($options); |
| 61 | + |
26 | 62 | $collection = new \Sharapov\FFMpegExtensions\Media\VideoCollection(); |
27 | 63 |
|
| 64 | +// Adding clips to the collection |
28 | 65 | $collection |
29 | | - ->add( $ffmpeg->open( new \Sharapov\FFMpegExtensions\Input\File( getcwd() . '/examples/source/demo_video_720p_HD.mp4' ) ) ) |
| 66 | + ->add( $clip1 ) |
30 | 67 | ->add( $ffmpeg->open( new \Sharapov\FFMpegExtensions\Input\File( getcwd() . '/examples/source/intro_720p_muted.mp4' ) ) ); |
31 | 68 |
|
| 69 | +// And do concatenation |
32 | 70 | $format = new \Sharapov\FFMpegExtensions\Format\Video\X264(); |
33 | 71 | $format->on( 'progress', function ( $item, $format, $percentage ) { |
34 | 72 | print 'Done: ' . $percentage . "%\n"; |
|
0 commit comments