PHP - Php Script To Open Video Streams
Hello 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 Similar TutorialsHi 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>'; } } ?> 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? Well I am using easy php and I need to make a script that will open up a script in easy php in the web browser.. so like a script to open http://127.0.0.1:8888/script.php then sleep for x amount of time then open another script in the browser http://127.0.0.1:8888/script2.php Any help is appreciated Hi Guys! I'm new here at PHPFreaks, I have this problem using simplexml_load_file function. I am retrieving an XML from another sub-domain of my project, it's working fine on my local server (win xp, php 5.2.14) but when I try to execute it on our testing server (linux, php 5.2.14) it returns an error something like this.. Warning: simplexml_load_file([url of the script]) [function.simplexml-load-file]: failed to open stream: Connection timed out in [absolute path of the script] on line 3 i have tried cURL and file_get_contents, still get no luck. please note that the XML is validated via w3c.org and works really fine on my local server.. Thanks in advanced! I have an open source project (https://github.com/j.../patchdashboard)
Here's my .htaccess for this:
RewriteEngine On RewriteBase "/pm/" RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /patches/server/(.*)$ patch_list?server= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /packages/server/(.*)$ packages?server= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /search/exact/(.*)$ search?package=&exact=true [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /search/(.*)$ search?package= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /rewrite_check/(.*)$ rewrite_check.php [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)$ index.php?page= [QSA,L]Basically, I want it so that no matter where they drop this script ("/", "/patch_dashboard/", "/pb/", etc.) it will redirect as intended. In the example I provided, the document root is "/pm/". When I try to hit a page ("http://dev2.curltool...es/server/demo1" for example), it gives a 404. If I hard code in each rule the base path, it just redirects everything to the main page. Any help would be greatly appreciated. The Script:
<?php if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded images for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $tqs = "INSERT INTO images (`original_image_name`, `image_file`, `date_created`) VALUES ('" . $_FILES['file']['name'][$i] . "', '" . $new_image_name . "', now())"; $tqr = mysqli_query($dbc, $tqs); } // To create the thumbnails. function make_thumb($src, $dest, $desired_width) { /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height * ($desired_width / $width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); } $src = $target_path; $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/"; $desired_width = 100; make_thumb($src, $dest, $desired_width); } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } } ?>With this: $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/";I get this error message: Warning: imagejpeg(C:/xampp/htdocs/gallerysite/multiple_image_upload/thumbs/): failed to open stream: No such file or directory in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49With this: $dest = "http://localhost/gallerysite/multiple_image_upload/thumbs/";I get this error message: Warning: imagejpeg(http://localhost/gallerysite/multiple_image_upload/thumbs/): failed to open stream: HTTP wrapper does not support writeable connections in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49When I try deleting the "thumbs" folder and then try to upload an image, then I get this error message: Warning: imagejpeg(C:/xampp/htdocs/gallerysite/multiple_image_upload/thumbs/): failed to open stream: Invalid argument in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49The spot of line 49 is this, at the spot where the script creates the thumbnails: /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); }Also, with this part right here I am not getting an error message, which means that this part works fine in comparison: $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded imagesThe script itself works fine. The script also uses javascript for multiple image upload. I am using XAMPP. The folder "thumbs" is set to "read-only", when I try to uncheck the "read-only" option in the properties in Windows then it sets itself back again to "read-only". Then again, the script works fine when it comes to the "uploads" folder. This is mentioned in comparison to the "thumbs" folder. Any suggestions on how to solve this? EDIT: I am using XAMPP. The folder "thumbs" is set to "read-only", when I try to uncheck the "read-only" option in the properties in Windows then it sets itself back again to "read-only". I am wondering if I would have issue that the option sets itself back again with Linux? Edited by glassfish, 11 October 2014 - 05:35 PM. I'm trying to open a URL using fopen() and I keep getting this error: Code: [Select] Failed to open stream: Permission deniedI can not work out what is wrong, it's not a firewall as far as I can tell. Not to say that this occurs in every php software out there, but I far too occasionally notice that the application is written with scattered php open and close tags, for instance
<?php if(true) ?> <?php { ?> Blah blah blah, because it's true <?php } else { ?> because it's not true <?php } ?>To me, it is extremely irritating. Regardless, I see a lot of open source software written this way and I can't help but think that there must be some underlying reason for it. Magento, for example, is written exactly in this manner. The templates are infested with these opened and closed php snippets. Obscurity is not security so I'm ruling security reasons out. Maybe it is more efficient? -- But I couldn't understand why, if so. It seems like that would put more of a drag on the system itself causing php to start and stop parsing continually and excessively, then again, I'm no expert in the field of memory consumption and other operating system complexities. Honestly, in my opinion, it is stupid. i would never write a program that way.. HEREDOCs are much more useful and eye pleasing than that awful <?php { ?> I had the misfortune a few months ago when I purchased an invoicing/customer maintenance system that I didn't know was written for PHP 5.2 or something lower, one that allowed short tags; and thus short tags were used in the same manner as I've described. Is this just plain disorganization or is there some deep-seated inner lining advantage that I'm not aware of? 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 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 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. 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 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,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 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?
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); } 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 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 |