carty Posted March 15, 2008 Share Posted March 15, 2008 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. Quote Link to comment Share on other sites More sharing options...
JD* Posted March 15, 2008 Share Posted March 15, 2008 Are you looking to convert video that you upload to flv? Or take flv videos from online and convert them to something else? Quote Link to comment Share on other sites More sharing options...
carty Posted March 15, 2008 Author Share Posted March 15, 2008 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. Quote Link to comment Share on other sites More sharing options...
JD* Posted March 15, 2008 Share Posted March 15, 2008 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. Quote Link to comment Share on other sites More sharing options...
carty Posted March 16, 2008 Author Share Posted March 16, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.