index.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /* For license terms, see /license.txt */
  3. /**
  4. * Script to convert videos to several formats
  5. * Put a comment before the exit(); line to enable.
  6. * Load in your browser with http(s)://[yourcampus]/tests/video/index.php
  7. * @todo Add security filtering for filenames
  8. * @author Yannick Warnier <yannick.warnier@beeznest.com>
  9. */
  10. exit();
  11. ini_set('memory_limit',0);
  12. ini_set('max_execution_time',0);
  13. ini_set('upload_max_filesize',0);
  14. ini_set('post_max_size',0);
  15. ?>
  16. <html>
  17. <body>
  18. <p>
  19. <form method="post" action="" enctype="multipart/form-data">
  20. <table>
  21. <tr><td>Video to convert:</td><td><input type="file" name="video"/></td></tr>
  22. <tr><td>Desired Codec:</td>
  23. <td>
  24. <select name="codec">
  25. <option value="webm" selected>WebM</option>
  26. <option value="ogv">OGV</option>
  27. </select>
  28. </td>
  29. </tr>
  30. <tr><td colspan="2"><input type="submit" name="Convert" value="Convert"></tr>
  31. </table>
  32. </form>
  33. </p>
  34. <p>
  35. <?php
  36. if (!empty($_FILES['video'])) {
  37. error_log($_FILES['video']['name']);
  38. $orig = __DIR__.'/upload/'.md5(uniqid(rand(),true)).'-'.$_FILES['video']['name'];
  39. $dest = __DIR__.'/upload/'.md5(uniqid(rand(),true)).'-'.substr($_FILES['video']['name'],0,-3).(($_POST['codec']!='ogv')?'webm':'ogv');
  40. error_log($dest);
  41. $res = @move_uploaded_file($_FILES['video']['tmp_name'],$orig);
  42. if ($res === false) { error_log("Error moving video file: ".$php_error_msg); }
  43. error_log('Calling '.'ffmpeg -i '.$orig.' -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k -v quiet -s 1080x720 '.$dest);
  44. $ffmpeg = @exec('ffmpeg -i '.$orig.' -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k -v quiet -s 1080x720 '.$dest);
  45. if ($ffmpeg === false) { error_log('no'); }
  46. }
  47. ?>
  48. </p>
  49. <p>
  50. <?php
  51. echo "Files on server:<br />";
  52. $list = scandir(__DIR__.'/upload');
  53. if (is_array($list)) {
  54. foreach ($list as $file) {
  55. if (substr($file,0,1) == '.') {
  56. continue;
  57. } else {
  58. echo '<a href="upload/'.$file.'">'.$file.'</a><br />'."\n";
  59. }
  60. }
  61. }
  62. ?>
  63. </p>
  64. </body>
  65. </html>