PHP - Video Script Help
Hi
I am having an issue searching videos from youtube when ever I do a search i keep getting an page not found error. here is my code Code: [Select] <? class Youtube { var $dom, $idvideo, $title, $video; //function for video title function videoTitle() { return $this->title; } function pagination() { return true; } function tag($tag, $page = 1) { if ($page <= 0) $page = 1; $start = ($page-1)*10 + 1; $tag = str_replace(' ', '+', $tag); $feed = ('http://gdata.youtube.com/feeds/api/videos?vq='.$tag.'&start-index='.$start.'&max-results=10&orderby=updated&alt=rss'); $this->dom = getFeed($feed); } function video($id) { $this->idvideo = $id; $feed = ("http://gdata.youtube.com/feeds/api/videos/".$id); $this->dom = getFeed($feed); $this->video = $this->dom->getElementsByTagName('entry')->item(0); $this->title = $this->video->getElementsByTagName('title')->item(0)->textContent; } function player() { ?> <object width="425" height="355"> <param name="movie" value="http://www.youtube.com/v/<?=$this->idvideo?>" /> <param name="wmode" value="transparent" /> <embed src="http://www.youtube.com/v/<?=$this->idvideo?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed> </object> <? } function view($tag) { $videos = $this->dom->getElementsByTagName('item'); foreach ($videos as $video) { $id = $video->getElementsByTagName('guid')->item(0)->textContent; $id = explode('/', $id); $id = $id[6]; echo '<div class="video">'; $title = $video->getElementsByTagName("title")->item(0)->textContent; echo '<p><a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html">'.$title.'</a></p>'; $fotos = $video->getElementsByTagNameNS("http://search.yahoo.com/mrss/", "thumbnail"); $tiempo = $video->getElementsByTagNameNS("http://gdata.youtube.com/schemas/2007", "duration"); $tiempo = $tiempo->item(0)->getAttribute("seconds"); $i = 0; echo '<div class="img">'; foreach ($fotos as $foto) { $url = $foto->getAttribute("url"); echo '<a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html"><img src="'.$url.'" alt="'.$title.'"/></a>'; $i++; if ($i > 2) break; } echo '</div>'; echo '<p class="links"><a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html">'._VIEW.'</a> '._DURATION.': '.minutes($tiempo).'</p>'; echo '<p>'.cut($video->getElementsByTagName("description")->item(0)->textContent).'</p>'; $tags = $video->getElementsByTagName("category"); echo '<div class="tags">'; echo 'tags: '; foreach ($tags as $palabra) { if (strpos($palabra->textContent, "http") === FALSE) echo '<a href="'.BASE_URL.'/0/tag/'.$palabra->textContent.'.html">'.$palabra->textContent.'</a> '; } echo '</div>'; echo '</div>'; } } function videoInfo() { $id = $this->video->getElementsByTagName("id")->item(0)->textContent; $id = explode("/", $id); $id = $id[6]; echo '<div class="video">'; $title = $this->video->getElementsByTagName("title")->item(0)->textContent; $tiempo = $this->video->getElementsByTagNameNS("http://gdata.youtube.com/schemas/2007", "duration"); $tiempo = $tiempo->item(0)->getAttribute("seconds"); echo '<p class="links">'._DURATION.': '.minutes($tiempo).'</p>'; echo '<p>'.$this->video->getElementsByTagName("description")->item(0)->textContent.'</p>'; $tags = $this->video->getElementsByTagNameNS("http://www.w3.org/2005/Atom", "category"); echo '<div class="tags">'; echo 'tags: '; foreach ($tags as $palabra) { if (strpos($palabra->getAttribute("term"), "http") === FALSE) echo '<a href="'.BASE_URL.'/0/tag/'.$palabra->getAttribute("term").'.html">'.$palabra->getAttribute("term").'</a> '; } echo '</div>'; echo '</div>'; } } ?> Similar TutorialsHello all! I've been searching for sometimes without result on how to write a PHP script to open video streams in a website. When I open a website where there are links to several video streams and what I would like to do is to view them all in a consecutive manner (kind of a playlist). Could any one help me with this? Many thanks in advance! BR, Tomi Anyone have access to a youtube video/audio downloader script? I'm sure there are one of these laying around somewhere... Looking for 1. This is the php file code to a video jukebox add-on script, for a popular web video script. I'd like to modify it so the "Click Here" text font and color can be changed. Can you help or suggest what I can do to accomplish this? Thanks Code: [Select] <?php include("../classes/config.php");?> <artworkinfo> <? $query = "select * from videos where viewtime<>'0000-00-00 00:00:00' and public_private='public' AND approved ='yes' AND promoted ='yes' limit 10"; // Max 10!"; $db=mysql_connect ($dbhost,$dbusername,$dbpassword) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($dbname); $num_rows = mysql_num_rows(mysql_query("select * from videos WHERE public_private = 'public' AND promoted = 'yes' AND approved ='yes'")); $result = mysql_query($query) or die ('Query Error: ' . mysql_error()); while ($results = mysql_fetch_array($result)) { ?> <albuminfo> <artLocation>../uploading/thumbs/<?=$results['video_id']; ?>.jpg</artLocation> <artist>Click Here!!</artist> <albumName><?=$results['title']; ?></albumName> <artistLink>../play.php?vid=<?=$results['indexer']; ?>&src=jukebox</artistLink> <albumLink>../play.php?vid=<?=$results['indexer']; ?>&src=jukebox</albumLink> </albuminfo> <? } mysql_close(); ?> </artworkinfo> Anyone know of a script that will allow you to upload a file and converts it to a specified file format? Folder layout: script/ script/videos/mp4/ } script/videos/ogg/ } folders for converted files from uploaded files script/videos/webm/ } script/videos/swf/ } Video player: Code: [Select] <video width="320" height="240" controls="controls"> <source src="script/videos/mp4/<? echo $movie; ?>.mp4" type="video/mp4" /> <source src="script/videos/ogg/ <? echo $movie; ?> .ogg" type="video/ogg" /> <source src="script/videos/webm/ <? echo $movie; ?> .webm" type="video/webm" /> <object data="script/videos/mp4/ <? echo $movie; ?> .mp4" width="320" height="240"> <embed src="script/videos/swf/ <? echo $movie; ?> .swf" width="320" height="240"> Your browser does not support video </embed> </object> </video> I have searched and searched the web for an answer and cannot find one pleas help? Hello, i just joined the forums, nice forum . Well im looking for a solution. I want download the videos from a site, but i cant find a solution how to get the location of the video, cause its dynamic. Here is a sample video: http://www.collegehumor.com/video:1946215 And here is the link to the video: http://8.media.collegehumor.cvcdn.com/21/12/a8cc907f5e150fe77ce7c0c47b1b9d31.mp4 That link i got via a FIREFOX Addon called "DownloadHelper" this addon finds the location with help of http headers. So is it possible way to find the videos with php? Thanks for help. hi all How we can read the id of an element tag on the html page to use it in a sql query for selecting a particular record. or else how we can simply connect a link to jwplayer to play in the specific area defined for it. That we just click that link and it will play a video in that area. how it is implement in php hello, i have read topic on the internet that says i have to buy an adobe media interactive server and moyea so that you can have a video on the internet (without using you tube). how can i install a software like this to the webhost? thanks everyone. Hi, I want to restrict my registered user to see video only once per day... Can anyone guide me how can i do this with php??? Thanks Hi guys, My first post here. I would like to seek you guys help about playing video from mysql. I wanted to upload video to database and also play it inside my webpage using the media player format. Thank in advance So i have a large video files, 1.5 gigs even. I made an html5 video player where the source is a php file. The php file is supposed to go below the web root and serve the video file to the html5 video tag. This all works just fine if the video using a script that uses HTTP_RANGE to serve the file in parts to the client. The problem is, once one video is playing - i can't do anything else. Its like the server locks up. I mean i can scrub that video, i can do anything to that page. I just can't navigate away. But i can open a new browser and play a new video. But again, once that first one is playing, or even paused, i can't do anything else. That is of course until i restart apache. Any ideas on how to stream these large files better? I have a feeling they are set to stream and never stop. This is the code for that Code: [Select] function rangeDownload($file) { $fp = @fopen($file, 'rb'); $size = filesize($file); // File size $length = $size; // Content length $start = 0; // Start byte $end = $size - 1; // End byte // Now that we've gotten so far without errors we send the accept range header /* At the moment we only support single ranges. * Multiple ranges requires some more work to ensure it works correctly * and comply with the spesifications: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2 * * Multirange support annouces itself with: * header('Accept-Ranges: bytes'); * * Multirange content must be sent with multipart/byteranges mediatype, * (mediatype = mimetype) * as well as a boundry header to indicate the various chunks of data. */ header("Accept-Ranges: 0-$length"); // header('Accept-Ranges: bytes'); // multipart/byteranges // http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2 if (isset($_SERVER['HTTP_RANGE'])) { $c_start = $start; $c_end = $end; // Extract the range string list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); // Make sure the client hasn't sent us a multibyte range if (strpos($range, ',') !== false) { // (?) Shoud this be issued here, or should the first // range be used? Or should the header be ignored and // we output the whole content? header('HTTP/1.1 416 Requested Range Not Satisfiable'); header("Content-Range: bytes $start-$end/$size"); // (?) Echo some info to the client? exit; } // If the range starts with an '-' we start from the beginning // If not, we forward the file pointer // And make sure to get the end byte if spesified if ($range == '-') { // The n-number of the last bytes is requested $c_start = $size - substr($range, 1); } else { $range = explode('-', $range); $c_start = $range[0]; $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; } /* Check the range and make sure it's treated according to the specs. * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html */ // End bytes can not be larger than $end. $c_end = ($c_end > $end) ? $end : $c_end; // Validate the requested range and return an error if it's not correct. if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { header('HTTP/1.1 416 Requested Range Not Satisfiable'); header("Content-Range: bytes $start-$end/$size"); // (?) Echo some info to the client? exit; } $start = $c_start; $end = $c_end; $length = $end - $start + 1; // Calculate new content length fseek($fp, $start); header('HTTP/1.1 206 Partial Content'); } // Notify the client the byte range we'll be outputting header("Content-Range: bytes $start-$end/$size"); header("Content-Length: $length"); // Start buffered download $buffer = 1024 * 8; while(!feof($fp) && ($p = ftell($fp)) <= $end) { if ($p + $buffer > $end) { // In case we're only outputtin a chunk, make sure we don't // read past the length $buffer = $end - $p + 1; } set_time_limit(0); // Reset time limit for big files echo fread($fp, $buffer); flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit. } fclose($fp); } Ok, this is killing me, So I'm finally asking for help. I'm working on a website, which streams videofiles from external links. The site plays & allows you to download the videos from the same external link. I need to mask the url of these videos. At the moment, I have successfully masked the url when downloading. If you click the download image, rather than the path being http://externalsite.com/videofile.avi its http://mysitename.com/external.php?id=xx&mid=xx So that is nicely hidden. However, I am having a problem when it comes to the embedded player on the page. At the moment i am using flowplayer for flv & mp4 videos, and just the usual embed for avi videos. Flow players embed code is like this --------------------------------------------------- <a href="<?=$videoFile?>" style="display:block;width:740px;height:400px;" id="player"> </a> <script language="JavaScript"> flowplayer("player", "<?=url::base()?>flowplayer-3.2.5.swf", { clip: { autoPlay: false, autoBuffering: true } }); </script> ----------------------------------------- At the moment, the player only works if i put the url in this format: http://externalsite.com/videofile.avi and wont work in this format http://mysitename.com/external.php?id=xx&mid=xx all download.php does is check the file exists, sets the headers and prompts users to open or save. Why isnt this working with the player? Please see the attached external.php file for my heade info etc to hopefully shed some light on this In my php web site the video player appears and plays the video. In Chrome you can right click on the player screen and choose 'inspect element' etc, but another choice is 'Copy video URL'. How can I block that, or hide (or disguise/rename) video URLs?
Hiya! Is it possible to play an avi or mpg video file with php? If not is there any other recommeded scripts out there be it jquery, ajax, js ect that will do this? Many thanks, James. Hi,i m confused php developer (beginner bt i wnt to do advance things with php and mysql) i want to make video website for myself and i also have 10000s of video in my pc and can any one help me to complete this project 1. when user clik on some video thumbnail the video player(jw or flow player) pop-up and start the video without go to different page(if possible) 2.do i need to upload all my video first to my server or i upload it with php mysql then how is it possible to link and make thumbnail of all the 10000s videos with video player so all the video will play without error and i knw i cant make these 10000s videos thumbnails and video link and pages for each videos so how can i start my thing please help me in this a BIG THANKS in advance Hi my website offers the users to buy the videos. But the hackers are stealing my video links through view source. So there any option to hide my video links in view source and firebug etc..My videos are comign from amazon. and we are using JW Players to play the videos The methods i have tried.. 1)Encode and decode the urls still the embed tag displays the complete path in firebug. 2)Amazon provide signed url(temporary url)-Still have some problem in this.. 3)call the video through ajax call. Still the complete HTML code will be displayed in the firebug. please check here i have attached the firebug sample how it displays the code. Here we can find the complete video path in file: attribute in embed tag Is there any to hide the urls Do you know of a way in php to do multitrack video editing? The only tool I have found online is a MltMelt, which is a command line utility. I'm in the process of making an app that merges multiple videos, photos and audio clips into one video, but I was wondering if there was a way to process this in php. Can anyone point me to a PHP library that can handle things like multitrack merging, transitions, color effects, blurring, etc?
I'm looking for adobe premier like features in code. hello guys i am a newbie want help with how to upload a youtube in your script and in database i know about the $_files thing but how do i give a link please help me out !! Hi, i am trying to stream a video from Rackspace clould files account. I could simply get the url of the video file and stream the video using the php api they have provided. But they have provided a stream function which they suggest to be used for video streaming or for large images. Here is the code of the api : /** * Streaming read of Object's data * * Given an open PHP resource (see PHP's fopen() method), fetch the Object's * data and write it to the open resource handle. This is useful for * streaming an Object's content to the browser (videos, images) or for * fetching content to a local file. * * Pass in $hdrs array to set specific custom HTTP headers such as * If-Match, If-None-Match, If-Modified-Since, Range, etc. * * Example: * <code> * # ... authentication/connection/container code excluded * # ... see previous examples * * # Assuming this is a web script to display the README to the * # user's browser: * # * <?php * // grab README from storage system * // * $my_docs = $conn->get_container("documents"); * $doc = $my_docs->get_object("README"); * * // Hand it back to user's browser with appropriate content-type * // * header("Content-Type: " . $doc->content_type); * $output = fopen("php://output", "w"); * $doc->stream($output); # stream object content to PHP's output buffer * fclose($output); * ?> * * # See read() above for a more simple example. * # * </code> * * @param resource $fp open resource for writing data to * @param array $hdrs user-defined headers (Range, If-Match, etc.) * @return string Object's data * @throws InvalidResponseException unexpected response */ function stream(&$fp, $hdrs=array()) { list($status, $reason) = $this->container->cfs_http->get_object_to_stream($this,$fp,$hdrs); #if ($status == 401 && $this->_re_auth()) { # return $this->stream($fp, $hdrs); #} if (($status < 200) || ($status > 299 && $status != 412 && $status != 304)) { throw new InvalidResponseException("Invalid response (".$status."): " .$reason); } return True; } Here is the sample code they shared : $output = fopen("test.jpg", "w"); $pic->stream($output); fclose($output); If i echo the $pic variable, it just contains the name of the file. How do i display the image and how do i use this for streaming a video? Iam very new to php, so kindly help me. Thanks. Hey everyone!
I have a question about handling video files. Are there classes available for handling videos? I've found classes to handle images and I was wondering if there is something similar for videos.
I'm asking because I want to allow users to upload videos, but I want to reduce their resolution (take up less space). The video is intended to play in a small section on the page, so it doesn't require high resolution.
I'll appreciate any help. Thanks!
I have a mobile app. They visit a web site where they login. The videos live above web root, thus making it impossible for anyone to directly link to the video file. On iOS, I made a PHP script that checks if they are logged in first and if they are I use a range download method that acts like streaming. Works great! On android however, the script isn't working..lame. So I was trying to think of other methods to deliver the video, but first checking if they are logged in. My idea was to check if they are logged in, if they are, copy the video from above web root to a temp directory in web root and give it a uniqid name and insert it into the DB. That ID will then expire after two hours and I would delete the video. Ok that sounds like it would work for both phones, except with high traffic, that could be problematic. My next idea was symlinks, but I don't know much about them other than they are a shortcut. Could I potentially use a symlink to give the logged in user a video file that lives above web root? |