Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [PHP]Uploaduje plik ale go nie konwersuje...
Forum PHP.pl > Forum > Przedszkole
JamalBIG
Witam

Wiecie moze gdzie zapodzial sie blad w tym kodzie? Uploaduje mi film ale nie chce go skonwersjowac do flv... Tymbardziej nie wyswietla mi sie zaden alert...

  1. <?php
  2. /***************Ladowanie FFMPEG *********************************/
  3. $extension = "ffmpeg";
  4. $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
  5. $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
  6. // load extension
  7. if (!extension_loaded($extension)) {
  8. dl($extension_soname) or die("Can't load extension $extension_fullname\n");
  9. }
  10. /***********************************************************/
  11. /*****************Pobieranie sciezki do Uploadu ****************/
  12. $array_path = explode("/",$_SERVER['SCRIPT_FILENAME']);
  13. $dynamic_path = "";
  14. for ($i=0;$i<sizeof($array_path)-1;$i++)
  15. if($array_path[$i]!="")
  16. $dynamic_path =$dynamic_path."/".$array_path[$i];
  17. /**********************************************************/
  18. /******************foldery*****************************/
  19. $flvpath = "flvfiles/";
  20. $moviepath = "movies/" ;
  21. chmod($moviepath,0777);
  22. chmod($flvpath,0777);
  23. /*********************************************************/
  24. /******************Upload i konwersja wideo *****************************/
  25. if(isset($_FILES["x_URL"]))
  26. {
  27. $fileName = $_FILES["x_URL"]["name"];
  28. $fileNameParts = explode( ".", $fileName );
  29. $fileExtension = end( $fileNameParts );
  30. $fileExtension = strtolower( $fileExtension );
  31. if($fileExtension=="avi" || $fileExtension=="wmv" || $fileExtension=="mpeg"
  32. || $fileExtension=="mpg" || $fileExtension=="mov" )
  33. {
  34. if ( move_uploaded_file($_FILES["x_URL"]["tmp_name"],$moviepath.$_FILES["x_URL"]["name"])
  35. )
  36. {
  37. if( $fileExtension == "wmv" ) {
  38. exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$fileName."
  39. -sameq -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");
  40. }
  41. if( $fileExtension == "avi" || $fileExtension=="mpg" ||
  42. $fileExtension=="mpeg" || $fileExtension=="mov" ) {
  43.  
  44. exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$fileName."
  45. -sameq -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");
  46. }
  47. /******************tworzenie miniaturki***************/
  48. exec("ffmpeg -y -i ".$dynamic_path."/".$moviepath."".$fileName."
  49. -vframes 1 -ss 00:00:03 -an -vcodec png -f rawvideo -s 110x90 ".$dynamic_path."/".$flvpath."myflv.png");
  50. }
  51. else
  52. {
  53. die("Plik nie zostal zaladowany");
  54. }
  55. }
  56. else
  57. {
  58. die("Prosze wysylac tylko pliki avi, wmv, mov lub mpg!");
  59. }
  60. }
  61. else
  62. {
  63. die("Plik nie zostal znaleziony");
  64. }
  65. ?>
wipo
Zobacz czy wykonuj± Ci siê polecenia exec

Informacja: Je¶li tryb bezpieczny zosta³ w³±czony, mo¿liwe jest wykonywanie programów tylko z katalogu okre¶lonego przez safe_mode_exec_dir. Ze wzglêdów praktycznych, nie mo¿na podawaæ elementów .. w ¶cie¿ce do pliku wykonywalnego.

JamalBIG
No wlasnie mam problem bo uzywajac samego kodu
  1. <?php
  2. exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$fileName."
  3. -sameq -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");
  4. ?>


tez nie chce wykonac konwersji... Jak mozna sprawdzic czy ffmpeg jest poprawnie zainstalowany i wszystko dziala poprawnie?
wipo
A masz dostêp do shella?

Jak tam to wykonaj to polecenie w shellu.
Jak nie to sprawd¼ poleceniem `whereis ffmpeg` w celu sprawdzenie gdzie jest i czy w ogóle jest
JamalBIG
W php.ini mam tak:

Cytat
safe_mode = Off

safe_mode_exec_dir =


Jak widac w safe_mode_exec_dir nie mam poprostu nic smile.gif

Kiedy wlaczam ten kod:

  1. <?php
  2. exec("ffmpeg -i D:/usr/apache/httpd/html/film.mpg -ar 22050 -ab -f -s 320x240 D:/usr/apache/httpd/html/myflv.flv");
  3. exec("ffmpeg -y -i D:/usr/apache/httpd/html/film.mpg -vframes 1 -ss 00:00:03 -an -vcodec png -f rawvideo -s 110x90 D:/usr/apache/httpd/html/myflv.png");
  4. ?>


tylko mi miga okienko nazwijmy to 'dosa'... ale nic pozatym sie nie 'tworzy'... Znalazlem pewien plik do testowania ffmpeg'a i wyglada na to ze wszystko dziala poprawnie ale czemu nie chce sie sluchac mojego kodu tego juz nie wiem...

  1. <?
  2. /*
  3.  * This test script is not part of the automatic regression tests. It serves
  4.  * as a simple manual test script and an example of the syntax for calling
  5.  * the ffmpeg-php functions
  6.  * 
  7.  * To run it from the command line type 'php -q ffmpeg_test.php 'or from a 
  8.  * browser * copy this file into your web root and point your browser at it.
  9.  */
  10.  
  11. $extension = "ffmpeg";
  12. $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
  13. $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
  14.  
  15. // load extension
  16. if (!extension_loaded($extension)) {
  17. dl($extension_soname) or die("Can't load extension $extension_fullname\n");
  18. }
  19.  
  20. if (php_sapi_name() != 'cgi') {
  21. echo '<pre>';
  22. }
  23.  
  24. printf("ffmpeg-php version string: %s\n", FFMPEG_PHP_VERSION_STRING);
  25. printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
  26. printf("libavcodec version number: %d\n", LIBAVCODEC_VERSION_NUMBER);
  27. printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
  28.  
  29. print_class_methods("ffmpeg_movie");
  30. print_class_methods("ffmpeg_frame");
  31. print_class_methods("ffmpeg_animated_gif");
  32.  
  33. // get an array for movies from the test media directory 
  34. $movies = getDirFiles(dirname(__FILE__) . '/tests/test_media');
  35.  
  36. echo "--------------------\n\n";
  37. foreach($movies as $movie) {
  38. $mov = new ffmpeg_movie($movie);
  39. printf("file name = %s\n", $mov->getFileName());
  40. printf("duration = %s seconds\n", $mov->getDuration());
  41. printf("frame count = %s\n", $mov->getFrameCount());
  42. printf("frame rate = %0.3f fps\n", $mov->getFrameRate());
  43. printf("comment = %s\n", $mov->getComment());
  44. printf("title = %s\n", $mov->getTitle());
  45. printf("author = %s\n", $mov->getAuthor());
  46. printf("copyright = %s\n", $mov->getCopyright());
  47. printf("get bit rate = %d\n", $mov->getBitRate());
  48. printf("has audio = %s\n", $mov->hasAudio() == 0 ? 'No' : 'Yes');
  49. if ($mov->hasAudio()) {
  50. printf("get audio codec = %s\n", $mov->getAudioCodec());
  51. printf("get audio bit rate = %d\n", $mov->getAudioBitRate());
  52. printf("get audio sample rate = %d \n", $mov->getAudioSampleRate());
  53. printf("get audio channels = %s\n", $mov->getAudioChannels());
  54. }
  55. printf("has video = %s\n", $mov->hasVideo() == 0 ? 'No' : 'Yes');
  56. if ($mov->hasVideo()) {
  57. printf("frame height = %d pixels\n", $mov->getFrameHeight());
  58. printf("frame width = %d pixels\n", $mov->getFrameWidth());
  59. printf("get video codec = %s\n", $mov->getVideoCodec());
  60. printf("get video bit rate = %d\n", $mov->getVideoBitRate());
  61. printf("get pixel format = %s\n", $mov->getPixelFormat());
  62. printf("get pixel aspect ratio = %s\n", $mov->getPixelAspectRatio());
  63. printf("get frame = %s\n", is_object($mov->getFrame(10)) ? 'true' : 'false');
  64. printf("get frame number = %d\n", $mov->getFrameNumber());
  65. }
  66. echo "\n--------------------\n\n";
  67. }
  68.  
  69. if (php_sapi_name() != 'cgi') {
  70. echo '</pre>';
  71. }
  72.  
  73. /* FUNCTIONS */
  74. function print_class_methods($class) {
  75. echo "\nMethods available in class '$class':\n";
  76. $methods = get_class_methods($class);
  77. if (is_array($methods)) {
  78. foreach($methods as $method) {
  79. echo $method . "\n";
  80. }
  81. } else {
  82. echo "No Methods Defined\n";
  83. }
  84. }
  85.  
  86. function getDirFiles($dirPath)
  87. {
  88. if ($handle = opendir($dirPath))
  89. {
  90. while (false !== ($file = readdir($handle))) {
  91. $fullpath = $dirPath . '/' . $file;
  92. if (!is_dir($fullpath) && $file != "CVS" && $file != "." && $file != "..")
  93. $filesArr[] = trim($fullpath);
  94. }
  95. closedir($handle);
  96. } 
  97.  
  98. return $filesArr;  
  99. }
  100.  
  101.  
  102. ?>
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.