Page always asking for downloading after executing the ffmpeg using exec() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nert
    New Member
    • Nov 2006
    • 64

    Page always asking for downloading after executing the ffmpeg using exec() function

    hi,

    I have made a simple website that allows users to upload videos. The videos are automatically converted into flv using the ffmpeg. I'm executing the ffmpeg using the PHP function exec(). My problem is after everything is done, i mean after uploading and converting the video to flv my "upload.php " page always asking for downloading which i don't what to do. Anyone could help me?

    Any suggestions from you guys would be greatly appreciated.

    Thanks in advance..(^_^)


    .: Nert :.
  • Nert
    New Member
    • Nov 2006
    • 64

    #2
    Hello,

    Here i am again asking for help.., i'm still encountering the same problem after searching for some tips on the web.., does anyone had encountered this same problem as mine? help please (^_^)



    .: Nert :. ;P

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      Can we see some code?

      Comment

      • Nert
        New Member
        • Nov 2006
        • 64

        #4
        Originally posted by code green
        Can we see some code?
        Yes of course,

        Here is my code for the conversion of media files to flv file.
        upload.php

        [PHP]$config['ffmpeg'] = 'The path of my ffmpeg';
        function uploadfile($ori gin, $dest, $tmp_name){
        $origin = strtolower(base name($origin));
        $fulldest = $dest.$origin;
        $filename = $origin;
        for($i=1; file_exists($fu lldest); $i++){
        $fileext = (strpos($origin ,'.')===false?' ':'.'.substr(st rrchr($origin, "."), 1));
        $filename = substr($origin, 0, strlen($origin)-strlen($fileext )).'['.$i.']'.$fileext;
        $fulldest = $dest.$filename ;
        }
        if (move_uploaded_ file($tmp_name, $fulldest))
        return $filename;
        return false;
        }

        if(isset($_FILE S['file']['tmp_name']) && is_uploaded_fil e($_FILES['file']['tmp_name'])){
        if($vid = uploadfile($_FI LES['file']['name'], 'v/', $_FILES['file']['tmp_name'])){
        $vidDIR = 'v/'.$vid;
        $fileext = (strpos($vid,'. ')===false?'':' .'.substr(strrc hr($vid, "."), 1));
        $new = substr($vid, 0, strlen($vid)-strlen($fileext ));
        $filename = $new.'.flv';
        for($i=1; file_exists('v/'.$filename); $i++){
        $ext = (strpos($new.'. flv','.')===fal se?'':'.'.subst r(strrchr($new. '.flv', "."), 1));
        $filename = substr($new.'.f lv', 0, strlen($new.'.f lv')-strlen($ext)).'['.$i.']'.$ext;
        }
        $newVidName = $filename;
        exec("$config[ffmpeg] -i $vidDIR -acodec mp3 -ar 22050 -ab 32 -f flv v/".$newVidNa me);
        }
        }
        [/PHP]

        after that series of code has been executed my upload.php page will ask for downloading is anyone can explain why is that happening? Any suggestions?

        Thanks in advance..,(^_^)


        .: Nert :.

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          after that series of code has been executed my upload.php page will ask for downloading
          Sorry, can't see where this request is made in your script.
          But you are executing what looks like the same loop within the script and also inside the function
          [PHP]for($i=1; file_exists($fu lldest); $i++){[/PHP] Duplicate code is always a concern. You could be looping through the same files twice

          Comment

          • Nert
            New Member
            • Nov 2006
            • 64

            #6
            Originally posted by code green
            Sorry, can't see where this request is made in your script.
            But you are executing what looks like the same loop within the script and also inside the function
            [PHP]for($i=1; file_exists($fu lldest); $i++){[/PHP] Duplicate code is always a concern. You could be looping through the same files twice
            Sorry for bothering code green, ahmmn don't mind about the looping it doesn't do anything that cause my upload.php page request for downloading.

            And, it's not a duplicate code, they do different thing. And the second loop will not be executed unless the function uploadfile() is done and returning the filename of the uploaded file.

            Anyway, i think it's about the exec() function. After executing the ffmpeg command in the console a popup window will appear asking to download the upload.php page.

            thank you for being patient code green (^_^) i'm looking forward for your help. best regards.


            .: Nert :.

            Comment

            • jx2
              New Member
              • Feb 2007
              • 228

              #7
              if you dont know what cos problem but you suspect exec coment it and see if problem disappear...
              let us know

              Comment

              • Nert
                New Member
                • Nov 2006
                • 64

                #8
                Originally posted by jx2
                if you dont know what cos problem but you suspect exec coment it and see if problem disappear...
                let us know
                I already done that jx2, I commented the exec() and the popup window disappear. Thanks for the suggestion, but i should use the exec so that i can run the ffmpeg to convert media files to flv on fly. If you have any other idea on how to run the ffmpeg in much better way than I do please post me some snippets. Thanks (^_^)




                .: Nert :.

                Comment

                Working...