cgimusic Posted September 16, 2009 Share Posted September 16, 2009 I have an on another server. http://www.example.com/video.flv. I want to parse it streight to the user. Should I use curl or readfile. Any help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/ Share on other sites More sharing options...
dreamwest Posted September 16, 2009 Share Posted September 16, 2009 You want to download or play? You can do both without curl or readfile If your trying to open a remote flv file with readfile itll show crap, youll have to do that with curl, and its really quite simple, i usually transfer flv files between my 2 servers using curl You can get alot of info about a flv file without downloading it like this one: $ch = curl_init($remote); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); if ($data === false) { echo 'cURL failed'; exit; } $contentLength = 'unknown'; if (preg_match('/Content-Length: (\d+)/', $data, $matches)) { $contentLength = (int)$matches[1]; } $filesize = round((($contentLength / 1224) / 1224)) + 4; //echo $filesize; if($filesize < 100){ echo "Im over 100MB"; }else{ echo "Im under 100MB"; } Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919372 Share on other sites More sharing options...
cgimusic Posted September 16, 2009 Author Share Posted September 16, 2009 I want to stream a YouTube video through my server to a flash FLV player. What is wrong with this code? I just get a blank page. $ch=curl_init("http://www.youtube.com/get_video?video_id=".$_GET["id"]."&t=".$vars["t"]); curl_exec($ch); curl_close($ch); Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919565 Share on other sites More sharing options...
MadTechie Posted September 16, 2009 Share Posted September 16, 2009 check the URL manually, do you get the flv file ? Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919583 Share on other sites More sharing options...
cgimusic Posted September 16, 2009 Author Share Posted September 16, 2009 check the URL manually, do you get the flv file ? Yes. The URL is correct. Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919659 Share on other sites More sharing options...
MadTechie Posted September 16, 2009 Share Posted September 16, 2009 can you give me a id and t, i'll test here Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919674 Share on other sites More sharing options...
cgimusic Posted September 16, 2009 Author Share Posted September 16, 2009 can you give me a id and t, i'll test here I don't know how long it is valid for but here you go: http://www.youtube.com/get_video?video_id=-xlAyxtEMFk&t=vjVQa1PpcFNIY3tmSkt3E8BtQq2ELdBONL-JtVLCY30%3D Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919690 Share on other sites More sharing options...
MadTechie Posted September 16, 2009 Share Posted September 16, 2009 got a blank page Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919694 Share on other sites More sharing options...
cgimusic Posted September 16, 2009 Author Share Posted September 16, 2009 It probably expired. Here is my script currently. <?php error_reporting(E_ALL); $file = file("http://www.youtube.com/watch?v=".$_GET["id"]); for ($count=0;$count<count($file);$count+=1) { if (preg_match('/.*?(var swfArgs)/',$file[$count])) { $linestring=$file[$count]; }; }; $url=explode("\"",$linestring); $count=1; while(isset($url[$count])&&!$url[$count]==""){ $vars[$url[$count]]=$url[$count+2]; $count=$count+4; }; echo "http://www.youtube.com/get_video?video_id=".$_GET["id"]."&t=".$vars["t"]; //$ch=curl_init("http://www.youtube.com/get_video?video_id=".$_GET["id"]."&t=".$vars["t"]); //curl_exec($ch); //curl_close($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919714 Share on other sites More sharing options...
cgimusic Posted September 16, 2009 Author Share Posted September 16, 2009 Here is what I get when I visit a link: Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919716 Share on other sites More sharing options...
MadTechie Posted September 16, 2009 Share Posted September 16, 2009 you could just change echo "http://www.youtube.com/get_video?video_id=".$_GET["id"]."&t=".$vars["t"]; to header('Content-Type: video/x-flv'); readfile("http://www.youtube.com/get_video?video_id=".$_GET["id"]."&t=".$vars["t"]); Quote Link to comment https://forums.phpfreaks.com/topic/174426-parse-flv-from-anothrer-server-to-user/#findComment-919727 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.