Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL & ~E_NOTICE);
  4.  
  5. if (isset($_POST['submit'])) {
  6. $currentPath = $_FILES['video']['tmp_name'];
  7. $watermark = $_POST['watermark'];
  8. $xy = $_POST['xy'];
  9. $star = $_POST['star'];
  10. $end = $_POST['end'];
  11. if (empty($currentPath)) {
  12. exit('die');
  13. }
  14. if (empty($star)) {
  15. $cut = null;
  16. } elseif (!empty($star) && empty($end)) {
  17. $cut = "-ss $star";
  18. } elseif (!empty($star) && !empty($end)) {
  19. $cut = "-ss $star -to $end";
  20. }
  21. /*vi tri (10|-10 là padding thêm cách lề)*/
  22. if ($xy == 'tl') {
  23. $vt = ": x=10:y=10";
  24. } elseif ($xy == 'tr') {
  25. $vt = ": x=w-tw-10:y=10";
  26. } elseif ($xy == 'bl') {
  27. $vt = ": x=10:y=h-th-10";
  28. } elseif ($xy == 'br') {
  29. $vt = ": x=w-tw-10:y=h-th-10";
  30. }
  31. if (!empty($watermark)) {
  32. $wm = "-vf drawtext=\"fontfile=old_stamper.ttf: text='" . $watermark . "': fontsize=40: fontcolor=white: box=0" . $vt . "\"";
  33. }
  34.  
  35. /*thuc thi*/
  36. $output = rand(1, 100);
  37. exec("ffmpeg.exe");
  38. exec("ffmpeg -y -i " . $currentPath . " " . $cut . " " . $wm . " " . $output . ".mp4");
  39.  
  40. /*show*/
  41. echo "<code>ffmpeg -y -i " . $currentPath . " " . $cut . " " . $wm . " " . $output . ".mp4</code>";
  42.  
  43. }
  44.  
  45. ?>
  46. <!DOCTYPE html>
  47. <html lang="en">
  48. <head>
  49. <meta charset="UTF-8">
  50. <title>FFMPEG PHP</title>
  51. <style>
  52. input[type="file"],
  53. input[type="text"],
  54. input[type="submit"]
  55. {
  56. margin: 10px 0;
  57. }
  58. </style>
  59. </head>
  60. <body>
  61. <form method="post" enctype="multipart/form-data">
  62. <input type="file" name="video" style="width: 100%; background: #ccc">
  63. <input type="text" name="star" placeholder="00:00:00.0000"> to
  64. <input type="text" name="end" placeholder="00:00:00.0000"> (giờ:phút:giây:mili giây)
  65. <input type="text" name="watermark" placeholder="watermark text" style="width: 100%">
  66. <p>
  67. <select name="xy">
  68. <option value="tl">Top left</option>
  69. <option value="tr">Top right</option>
  70. <option value="bl">Bottom left</option>
  71. <option value="br">Bottom right</option>
  72. </select> (vị trí watermark)
  73. </p>
  74. <input type="submit" name="submit" value="FFMPEG">
  75. </form>
  76. </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement