index.php 1.9 KB

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