play a video like youtube in my application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarayu
    New Member
    • Jul 2008
    • 15

    play a video like youtube in my application

    Hi,

    I want to convert some video files to .flv format and store it in database and play.For this i used ffmpeg and i convert the files in cmd and here my problem is how can i connect ffmpeg and php.I searched for it but i got an error in ffmpeg-php classes.Which class is suitable for my application and how we connect with.Please help me?
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Sarayu.

    You have a couple of options. If you post what error you're getting from ffmpeg-php, we might be able to help you out along that avenue.

    The other option is to just do it yourself using exec() to call the ffmpeg binary (http://php.net/manual/en/function.exec.php). Just remember to escapeshellarg( ) your arguments (http://php.net/escapeshellarg)!

    Comment

    • sarayu
      New Member
      • Jul 2008
      • 15

      #3
      Hi
      I got this error when run my script.

      Warning: exec(): Unable to fork [FFmpeg/ffmpeg -Uv FFmpeg/ffmpeg/monkeydog.wmv FFmpeg/ffmpeg/monkeydog.flv] in D:\project\FPI\ public_html\OLD CONTENT\admin\h tml\helo1.php on line 3


      Can you please help how can i connect to cmd in my php script.

      Comment

      • coolsti
        Contributor
        • Mar 2008
        • 310

        #4
        Don't know if this has anything to do with your error, but many sites configure their PHP to forbid use of commands such as exec().

        We had this problem when we had one company produce our company website and then tried to host it on an external web server. The company that produced the website code used exec() for tasks such as image conversions, but the hosting web server blocked exec() commands as being unsafe. We ended up having to move our code to a virtual server in order to be allowed to unblock exec().

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          This is a fairly common problem on a Windows server (http://www.google.com/search?client=...UTF-8&oe=UTF-8).

          Comment

          • sarayu
            New Member
            • Jul 2008
            • 15

            #6
            Hi,

            i successfully converted the videos to .flv prompt using ffmpeg.But when i want to call the exec command in my file i cant access the convertion.Here is my code.Please let me know what the mistake i did?
            [code=php]
            <?
            $srcFile = "/FFmpeg/monkeydog.wmv";
            $destFile = "/FFmpeg/mn.flv";
            $ffmpegPath = "/FFmpeg/ffmpeg";
            echo exec('cmd /c echo Hello World!');
            exec($ffmpegPat h . " -i " . $srcFile . " -ar 22050 -ab 32 -f flv -s 420 * 320 " . $destFile);
            //exec('cmd /c ffmpeg -i monkeydog.wmv -ar 22050 -ab 32 -f flv -s 320×240 video2.flv');
            ?>[/code]
            Last edited by pbmods; Jul 9 '08, 02:55 AM. Reason: Added CODE tags.

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              What error are you getting?

              Comment

              • sarayu
                New Member
                • Jul 2008
                • 15

                #8
                Hi,

                I didnt got any error.But the files was not converted...

                Comment

                • pbmods
                  Recognized Expert Expert
                  • Apr 2007
                  • 5821

                  #9
                  Check to make sure Apache has write permissions for /FFmpeg.

                  What happens if you run the command manually in a shell?

                  Comment

                  • sarayu
                    New Member
                    • Jul 2008
                    • 15

                    #10
                    when i run the cmd in shell it converted the file to .flv format and place that converted file into the directory where the input file located.And using that i can play the video.But when i do the same in php it wont be convert and wont give any error?

                    In my php.ini the safe_mode is disabled(off).W hat the permissions i have to give this?Can u be explain it clearly?I am new to this concept?

                    Thanks in advance.

                    Comment

                    • pbmods
                      Recognized Expert Expert
                      • Apr 2007
                      • 5821

                      #11
                      You'll need to make the /FFmpeg directory writable to Apache or its group.

                      Look in your httpd.conf file for the User and/or Group directive (e.g., "User www").

                      Use the chown and chgrp commands to change ownership of /FFmpeg and the files inside it. Note that you might need to replace 'www' with the actual User and group values, respectively, from httpd.conf.
                      [code=sh]
                      sudo chown -R www /FFmpeg
                      sudo chgrp -R www /FFmpeg
                      [/code]

                      Finally, you need to make that directory User/group writable:
                      [code=sh]
                      sudo chmod -R 775 /FFmpeg
                      [/code]

                      Comment

                      Working...