index.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. ini_set('memory_limit',0);
  3. ini_set('max_execution_time',0);
  4. ini_set('upload_max_filesize',0);
  5. ini_set('post_max_size',0);
  6. require_once dirname(__FILE__).'../../main/inc/global.inc.php';
  7. ?>
  8. <html>
  9. <body>
  10. <p>
  11. <form method="post" action="" enctype="multipart/form-data">
  12. <table>
  13. <tr><td>Video to convert:</td><td><input type="file" name="video"/></td></tr>
  14. <tr><td>Desired CODEC:</td>
  15. <td>
  16. <select name="codec">
  17. <option value="webm" selected>WebM</option>
  18. <option value="ogv">OGV</option>
  19. </select>
  20. </td>
  21. </tr>
  22. <tr><td colspan="2"><input type="submit" name="Convert" value="Convert"></tr>
  23. </table>
  24. </form>
  25. </p>
  26. <p>
  27. <?php
  28. if (!empty($_FILES['video'])) {
  29. error_log($_FILES['video']['name']);
  30. $orig = dirname(__FILE__).'/upload/'.md5(uniqid(rand(),true)).'-'.$_FILES['video']['name'];
  31. $dest = dirname(__FILE__).'/upload/'.md5(uniqid(rand(),true)).'-'.substr($_FILES['video']['name'],0,-3).(($_POST['codec']!='ogv')?'webm':'ogv');
  32. error_log($dest);
  33. $res = @move_uploaded_file($_FILES['video']['tmp_name'],$orig);
  34. if ($res === false) { error_log("Error moving video: ".$php_error_msg); }
  35. error_log('Calling '.'ffmpeg -i '.$orig.' -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k -v quiet -s 1080x720 '.$dest);
  36. $ffmpeg = @exec('ffmpeg -i '.$orig.' -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k -v quiet -s 1080x720 '.$dest);
  37. if ($ffmpeg === false) { error_log('no'); }
  38. }
  39. ?>
  40. </p>
  41. <p>
  42. <?php
  43. echo "Files on disk:<br />";
  44. $list = scandir(dirname(__FILE__).'/upload');
  45. if (is_array($list)) {
  46. foreach ($list as $file) {
  47. if (substr($file,0,1) == '.') {
  48. continue;
  49. } else {
  50. echo '<a href="'.api_get_path(WEB_PATH).'video/upload/'.$file.'">'.$file.'</a><br />'."\n";
  51. }
  52. }
  53. }
  54. ?>
  55. </p>
  56. </body>
  57. </html>