ffmpeg_handler.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. include '../auth.php';
  3. ?>
  4. <html>
  5. <head>
  6. <link rel="stylesheet" href="../script/tocas/tocas.css">
  7. <script src="../script/tocas/tocas.js"></script>
  8. <script src="../script/jquery.min.js"></script>
  9. <script>
  10. $( document ).ready(function() {
  11. //Comment the line below for debugging
  12. window.location.replace("index.php");
  13. });
  14. </script>
  15. </head>
  16. <body>
  17. <br>
  18. <div class="ts container">
  19. <div class="ts segment">
  20. <h1>DONE!</h1>
  21. <div class="ts outlined message">
  22. <div class="header">Information</div>
  23. <p>If it cannot redirect itself, click <a href="index.php">HERE</a></p>
  24. </div>
  25. <?php
  26. //ffmpeg handler. Have to be modified after deploying on linux environment.
  27. echo "Experimental Converter for mp4 to mp3 conversion.<br>";
  28. echo "If the conversion crashed, it might be you haven't correctly setup the FFmpeg or your PHP buffer is not enough.<br>";
  29. foreach (glob("uploads/*.mp4") as $filename) {
  30. $mp4filename = $filename;
  31. echo $mp4filename . "<br><br>";
  32. $mp3filename = str_replace(".mp4",".mp3",$mp4filename);
  33. echo shell_exec('ffmpeg -i "'.$mp4filename.'" -b:a 320K "'.$mp3filename.'" 2>&1');
  34. //Replace the above line with the line below for Raspberry pi with libav-tools
  35. //echo shell_exec("avconv -i ".$mp4filename." -b:a 320K ".$mp3filename." 2>&1");
  36. //unlink($mp4filename);
  37. }
  38. /*
  39. foreach (glob("uploads/*.aac") as $filename) {
  40. $aacfilename = $filename;
  41. echo $aacfilename . "<br><br>";
  42. $mp3filename = str_replace(".aac",".mp3",$aacfilename);
  43. echo shell_exec("ffmpeg -i ".$aacfilename." -b:a 320K ".$mp3filename." 2>&1");
  44. //Replace the above line with the line below for Raspberry pi with libav-tools
  45. //echo shell_exec("avconv -i ".$aacfilename." -b:a 320K ".$mp3filename." 2>&1");
  46. unlink($aacfilename);
  47. }
  48. */
  49. //header('Location: index.php');
  50. ?>
  51. <br><br><br>
  52. <div class="ts outlined message">
  53. <div class="header">Information</div>
  54. <p>If it cannot redirect itself, click <a href="index.php">HERE</a></p>
  55. </div>
  56. </div>
  57. </div>
  58. </body>
  59. </html>