SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    conversion problem

    Hi Guys,

    i have written a small upload a video and convert to .flv script but it's not working for some reason, the initial file is uploaded but the conversion isn't doing its stuff, can anyone see any problems at all:

    PHP Code:
    <?php 
      
    ## HTML form 
      
    echo ("<br />");
      echo (
    "<fieldset>");
      echo (
    "<legend>Upload Your Audition Video</legend>");
      echo (
    "<form action=\"uploadvideo.php\" method=\"post\" enctype=\"multipart/form-data\" />"); 
      echo (
    "<table width=\"600\" border=\"0\" bordercolor=\"#000000\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\">");
      echo (
    "<tr>");
      echo (
    "<td align=\"center\"><b>Select an audition video to upload</b></td><td align=\"center\"><input type=\"file\" name=\"video\" size=\"50\" /></td>");
      echo (
    "</tr>");
      echo (
    "<tr>");
      echo (
    "<td colspan=\"2\" align=\"right\"><input type=\"submit\" class=\"btn\" name=\"submit\" value=\"Upload Video\" /></td>");
      echo (
    "</tr>");
      echo (
    "</table><div id=\"notice\">Video formats you can upload are: <b>.avi .mov .wmv</b></div></form>");
      echo (
    "</fieldset>");
      
      
    ## deal with the submission
      
    if(isset($_POST['submit']))
      {
      
      
    ## set up a few server variables
      
    $ffmpeglocation "/usr/bin/ffmpeg";
      
      
    ## set up file variables
      
    $filename $_FILES['video']['name'];
      
    $filetemp $_FILES['video']['tmp_name'];
      
    $filesize $_FILES['video']['size'];
      
    $filetype $_FILES['video']['type'];
      
      
    ## get the extension everything after the .
      
    $fileextension substr(strrchr($filename"."), 1);
      
      
    ## make lower case
      
    $filenamelowercase strtolower($fileextension);
      
      
    ## now we have the files extension do some checking
      //if($fileextension != 'avi' || $fileextension != 'mov' || $fileextension != 'wmv') {
      //   stderr("Error","That file isn't one of the allowed types, look above for the proper files to upload.");
      //   include("includes/footer.php");
      //   exit;  
      //}
      
      ## no video uploaded
      
    if($filesize <= 0) { 
         
    stderr("Error","No video file was selected for uploading.");
         include(
    "includes/footer.php");
         exit;     
      }
      
      
    ## start processing stuff vars first
      
    $uploadedmoviesdir "movies/$filename";
      
    $outputflvdirectory "flvfiles/video.flv";
      
      
    ## move the uploaded file
      
    if(move_uploaded_file($filetemp,$uploadedmoviesdir)) {
         
    stderr("Success","Your video file has been uploaded.");
         include(
    "includes/footer.php");
         exit;   
      }
      
      
    ## ffmpeg encoding
      
    $encode_cmd "/usr/bin/ffmpeg -i $uploadedmoviesdir -acodec mp3 -ar 22050 -ab 32 -f flv -author \"Clip Author\" -copyright \"Clip Copyright\" $outputflvdirectory";
      
    exec($encode_cmd);
      
      }
    ?>
    cheers

    Graham

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Run the ffmpeg command on the shell first and see make sure if it works.

    Turn the error reporting on and make sure if there are no errors.

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi phpd,

    i turned on error reporting, no errors came up.

    Run the ffmpeg command on the shell first and see make sure if it works.
    i'm not to sure how to do this part, do you mean echo out the actual command?

    thanks mate

    Graham

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I mean run it through ssh.

    Or if you can't do so, try to run the command with minimal parameters necessary, ex.:

    PHP Code:
    $encode_cmd "/usr/bin/ffmpeg -i $uploadedmoviesdir $outputflvdirectory"

  5. #5
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah i see did that still nothing, the funny thing is there isnt a great deal of help when it comes to this from google, is there a way i can echo my commands out to see things in more detail?

    cheers

    Graham

  6. #6
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    OK, then next thing to try is:
    PHP Code:
    $encode_cmd "/usr/bin/ffmpeg -i $uploadedmoviesdir $outputflvdirectory 2> ffmpeg.txt"
    and create a file ffmpeg.txt with write permissions. That will give yout the output of ffmpeg.

  7. #7
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi PHPD,

    can you believe i was exiting the scripts after the initial upload was successfull, cutting out the encode part lol

    i have now fixed everything up, my only problem is how exactly a specific users video is played? i mean if you goto my profile how do i display the video for playing, like images you store the file path and img src="$imagepath" but the player is just looking for a file named file.flv?

    cheers mate

    Graham

  8. #8
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    lol I should've noticed.

    Check out this player: http://www.jeroenwijering.com/?item=JW_FLV_Player

  9. #9
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mate,

    the best part of 4 hours away on that aswell at least i'v learned

    funnily enough i was tinkering about with that player earlier, theres 1 thing i'm stuck on:

    if we both upload video files and i save them as:

    phpdvideo.flv
    graham23svideo.flv

    if i'm viewing your profile how to tell the player to play your video and vice versa when your on mine or another users?

    thanks for the help mate

    Graham

  10. #10
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You're gonna have to save this information about a video to database, assign a user id to determine what is what.

  11. #11
    SitePoint Guru
    Join Date
    Nov 2001
    Location
    Fort Lauderdale
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any chance you can post the working code?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •