Jump to content

FFMpeg with PHP


carty

Recommended Posts

Hello people,

 

      I'm completely new to php and would love to learn through experiencing it. I have just read some tutorials and all i can say: php is fun :)

 

Anyway, here is my situation, Ive seen many YouTube online video converters and I need one of my own. I figured out that FFmpeg can do the conversion and the code http://cache.googlevideo.com/get_video?video_id=VIDEOID&origin=youtube.com will grab the video.

 

Now what I need is, a small php script that will accept video id into variable, convert the flv-mpg using ffmpeg tool on server and produce a response with url to the converted video file.

 

Can someone please help me?

 

Thanks a million,

Carty.

Link to comment
Share on other sites

The script should download the flv video from youtube site, use ffmpeg on server to convert it to mpg format on server itself to a new file and the link to the new file will let you download the video!

 

For example: An url to youtube video looks like youtube.com/watch?v=VIDEIOid

 

The script will be run like:

http://domainname.com/script.php?video=VIDEOid

 

The above will download the video onto the server, use ffmpg to convert to mpg file on the same server. Then the converted file can be downloaded or streamed with the mpg link on the server.

 

Thanks again,

Carty.

Link to comment
Share on other sites

O.k, so here is how I would do it:

 

Have a page with a form on it that will accept the video ID. When they submit, have it submit to the same page and it should do the following:

 

Check to see that the youtube video exists.

 

Figure out the URL to the flv file on youtube (check the source)

 

Use popen() to wget the file, do the ffmpeg conversion. popen is useful because it will launch a process in the background, which means that the page doesn't need to stay open for this to keep working. I'd suggest writing a perl script to do the wget and ffmpeg commands, and have PHP to a popen on the perl script. (this is how I've gotten it to work in the past).

 

Finally, when done, have it put the URL into a database, or move it to a new folder, or whatever you need so that it can be displayed on your website.

 

The page itself should follow a form like this:

 

<?php
if(isset($_POST['Submit']) && $_POST['Submit'] == "Get It")
{
  // Do your popen on the perl script here, along with anything else
} else {
  //Put your form code here, along with a Submit button with a "value" of "Get It"
}
?>

 

This will allow you to do everything on one page.

 

Link to comment
Share on other sites

If my server has php max upload size limited to 2 mb but the video the script downloads to server is over 2mb, will there be a problem?

 

I understand your flowchart but since im a newbie, I don't know how to fill it with php. Anyway, I know its too much to ask for that in a forum but if you wish to help and have time, I'g be more than happy.

 

Thanks a million in advance.

Carty.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.