Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2.  
  3. $count = isset($argv[1]) ? intval($argv[1]) : 1000;
  4.  
  5. // IMAGES ---------------------------
  6.  
  7. $start = hrtime(true);
  8.  
  9. for ($i = 1; $i <= $count; $i++) {
  10. $num = str_pad($i, 7, '0', STR_PAD_LEFT);
  11. $txt = preg_replace('/^(\d)(\d{3})(\d{3})$/', '${1} ${2} ${3}', $num);
  12.  
  13. $draw = new ImagickDraw();
  14. $draw->setFillColor('#CCCCCC');
  15. $draw->setFont(__DIR__ . '/DigitalDismay.otf');
  16. $draw->setFontSize(120);
  17. $draw->annotation(427, 318, $txt);
  18.  
  19. $img = new Imagick();
  20. $img->newImage(1280, 720, '#000000');
  21. $img->setImageFormat('png');
  22. $img->drawImage($draw);
  23. $img->writeImage(__DIR__ . "/images/{$num}.png");
  24. }
  25.  
  26. $images_task_duration = (hrtime(true) - $start) / 1e+9;
  27.  
  28. // VIDEO ---------------------------
  29.  
  30. $start = hrtime(true);
  31. $output = "{$count}.mp4";
  32. exec("ffmpeg -framerate 60 -i images/%07d.png -r 60 -s 1280x720 -c:v libx264 {$output}");
  33. $video_task_duration = (hrtime(true) - $start) / 1e+9;
  34.  
  35.  
  36. // SUMMARY ---------------------------
  37.  
  38. printf("\n--------------------------------------\n");
  39. printf("{$count} images generated in %s sec\n", $images_task_duration);
  40. printf("Video generated in %s sec\n", $video_task_duration);
  41. printf("Video size: %s Kb\n", filesize($output) / 1024);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement