943,843 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3708
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 21st, 2009
0

How to upload and stream videos?

Expand Post »
I assuming it is unefficent to upload and stream a video with php.
So this is a 2 part question (1. using php to upload the contents, 2. using php? flash? etc? to convert and play the video file).

1. How would I upload a video file? - Like a normal file?
2. Now If I converted to a fla format, I would do this before or after the video file is uploaded?
3. How do I stream a live video?
4. How much bandwidth am I looking at consuming?

In short im looking for video tutorials that can be used to upload and play your own videos (something similar to youtube - on a very small scale). What is the best way to do this?

Thankyou, Regards X

PS: The same concept for the video would be used for a powerpoint presentation?
Last edited by OmniX; May 21st, 2009 at 1:17 am.
Similar Threads
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 21st, 2009
0

Re: How to upload and stream videos?

Click to Expand / Collapse  Quote originally posted by OmniX ...
I assuming it is unefficent to upload and stream a video with php.
So this is a 2 part question (1. using php to upload the contents, 2. using php? flash? etc? to convert and play the video file).

1. How would I upload a video file? - Like a normal file?
2. Now If I converted to a fla format, I would do this before or after the video file is uploaded?
3. How do I stream a live video?
4. How much bandwidth am I looking at consuming?

In short im looking for video tutorials that can be used to upload and play your own videos (something similar to youtube - on a very small scale). What is the best way to do this?

Thankyou, Regards X

PS: The same concept for the video would be used for a powerpoint presentation?
Hi,

Acco'd to my knowledge uploading of any file can be done by PHP. And videos are converted on the fly to flv format from any format using FFMPEG. Basically to start a site like youtube or any thing which streams videos requires FFMPEG modules installed. And secondly the bandwidth issue is it depends on the file size. Say the video is of 1mb, you upload it, and is viewed 10 times. So the bandwidth used is 1+1*10=11mb used. I hope you understood.
Reputation Points: 10
Solved Threads: 0
Light Poster
lamiv007 is offline Offline
30 posts
since May 2009
May 21st, 2009
0

Re: How to upload and stream videos?

Ya I gather most of that and I have uploaded files to a server before, details to a database, etc just never video.

When a person uploads a video the 'FFMPEG ' would convert it to fla and store it on the server and then would be avaliable to all to see? How would I code that? Would I need to make sure my server supports x, y and z?

I was thinking when you upload it FFMPEG converts it to fla and stores it and then you could easily make a webpage with basic html to play the file?

Let me know your ideas, more importantly example code but ideally some sort of website with a tutorial (I have searched and nothing but youtube this and youtube that tutorials).

Thanks, Regards X
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 21st, 2009
0

Re: How to upload and stream videos?

I have a simple php upload script, but it does not play the movie. koolhq.com/upload.zip
Last edited by koolhq; May 21st, 2009 at 12:27 pm.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
koolhq is offline Offline
9 posts
since May 2009
May 21st, 2009
0

Re: How to upload and stream videos?

php Syntax (Toggle Plain Text)
  1. <?php ob_start("ob_gzhandler"); ?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html xmlns="http://www.w3.org/TR/REC-html40">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html;charset=utf-8"><meta name="distribution" content="global">
  5. <meta http-equiv="content-Script-Type" content="text/javascript"><meta name="author" content="Rob Dockrey 2004">
  6. <style type='text/css'>
  7. <!--
  8. .logo {
  9. background-color: #eeeeee;
  10. color: #000000;
  11. text-align: right;
  12. font-family: verdana, geneva, arial, serif;
  13. font-size: 8pt;
  14. top: expression(document.body.scrollTop +
  15. document.body.clientHeight -
  16. offsetHeight );
  17. left: expression(document.body.scrollLeft +
  18. document.body.clientWidth -
  19. offsetWidth - 1 );
  20. position: absolute;
  21. }
  22. -->
  23. </style>
  24. <script type="text/javascript">
  25. <!--//
  26. function shrink(){
  27. document.getElementById("MediaPlayer1").style.width=384;
  28. document.getElementById("MediaPlayer1").style.height=300;
  29. }
  30. function enLarge(){
  31. document.getElementById("MediaPlayer1").style.width=480;
  32. document.getElementById("MediaPlayer1").style.height=402;
  33. }
  34. //-->
  35. </script>
  36. <title>video - Entertainment - Dockrey Apartments</title>
  37. </head><body><a name='top'></a>
  38. <p class='logo'>
  39. <button onclick="enLarge()">large</button>
  40. <button onclick="shrink()">small</button>
  41. <a class='button' href='..'>Main Menu</a>
  42. <A href="http://www.microsoft.com/windows/windowsmedia/player/download/"><IMG ALT="Get Windows Media Player" SRC="http://www.microsoft.com/windows/windowsmedia/images/logos/getwm/mp11_88x31_static.gif" WIDTH="88" HEIGHT="31" BORDER="0"></A><br>
  43. <OBJECT ID="MediaPlayer1" width=384 height=300 classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">
  44. <PARAM NAME="fileName" VALUE="">
  45. <PARAM NAME="showControls" VALUE="true">
  46. <PARAM NAME="PlayCount" VALUE="0">
  47. <PARAM NAME="animationatStart" VALUE="true">
  48. <PARAM NAME="transparentatStart" VALUE="true">
  49. <PARAM NAME="autoStart" VALUE="true">
  50. <EMBED type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="" name="MediaPlayer1" width=360 height=260 AutoStart=true></EMBED></object></p>
  51. <p>Videos<div style='float:left; text-align:left;'>
  52. <?php $p = split('/', $_SERVER['SCRIPT_FILENAME']);
  53. $script_name = $p[count($p)-1];
  54. $path = str_replace($script_name, '', $_SERVER['SCRIPT_FILENAME']);
  55. $dir_handle = @opendir($path) or die("Unable to open $path");
  56. Function get_Extension($m_FileName){
  57. $path_parts = pathinfo($m_FileName);
  58. if ($path_parts["extension"]) {
  59. $m_Extension = strtolower($path_parts["extension"]);
  60. return(strtoupper($m_Extension));
  61. }
  62. else { return "unbekannt"; }
  63. }
  64. function check_image($filename){
  65. $temp=strtoupper(get_Extension($filename));
  66. if(($temp=="WMV")||($temp=="ASF"))
  67. return (true);
  68. else
  69. return (false);
  70. }
  71. Function get_Files($path) {
  72. if ($handle = opendir($path)) {
  73. while (false !== ($file = readdir($handle))) {
  74. if(!is_dir($file) && substr($file,O,1) != "."){
  75. $m_Files[]=$file;
  76. }
  77. }
  78. closedir($handle);
  79. }
  80. if(sizeof($m_Files)>1)
  81. asort($m_Files);
  82. return $m_Files;
  83. }
  84. $files=get_Files($path);
  85. $filter_files=array_filter($files,"check_image");
  86. $maxnr=sizeof($filter_files)-1;
  87. sort($filter_files);
  88. for ($i=0;$i<sizeof($filter_files);$i++){
  89. echo "<a class='button' onclick=\"MediaPlayer1.SRC='$filter_files[$i]';MediaPlayer1.fileName='$filter_files[$i]';\">";
  90. echo substr($filter_files[$i], 0, strlen($filter_files[$i])-4);
  91. echo "</a><br>";
  92. }
  93. closedir($dir_handle); ?>
  94. </p>
  95. </body></html>
  96. <?php ob_flush(); ?>
serves wmv asf files, without flash overhead
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
May 22nd, 2009
0

Re: How to upload and stream videos?

The code looks good but when I tried to run it, there was only an out of area media player available, no upload, no movie and also required active x.

Is there something more like you tube script available or something?

Thanks
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 22nd, 2009
0

Re: How to upload and stream videos?

google, utube clone script
upload and serve scripts are always separate
often in the same package, but separate
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
May 22nd, 2009
0

Re: How to upload and stream videos?

almostbob - Will do so now, thanks.

I have been doing some research with php and video and the "FFMPEG" has come up several times, which will allow me to covnert and play my videos like youtube does but I havent found anything accurate yet.

So pretty much looking for a php video script that will lead to a mini website of youtube.

Thanks, Regards X
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 29th, 2009
0

Re: How to upload and stream videos?

Hei,

I think this tutorial will be helpful. http://www.tutorialhero.com/tutorial...eg_and_php.php
Reputation Points: 10
Solved Threads: 0
Light Poster
lamiv007 is offline Offline
30 posts
since May 2009
May 31st, 2009
1

Re: How to upload and stream videos?

Here is a bit on uploading files in PHP:
http://www.php.net/manual/en/feature...ost-method.php

You can convert the file to flv after uploading using FFMPEG and FLVTool2 for the metadata.
FFMPEG-PHP can help with this: http://ffmpeg-php.sourceforge.net/

It's probably easier to use FFMPEG and FLVTool2 in the command line first and when you're successful, try doing it from PHP with exec().

The tutorial given previously explains this well.

You'll need root access to install FFMPEG and FLVTool2. If you don't have this, you could probably get away with uploading the video file to a site such as google video or youtube, and then downloading the converted FLV through their API.

Basically there are 2 ways of streaming the FLV to the flash player.

1) using HTTP
2) using a streaming protocols such as RTMP (Real Time Messaging Protocol)

http://en.wikipedia.org/wiki/Flash_V...livery_options

Using RTMP requires a streaming server, such as Red5 (open source).

If you won't want to use a special server, just using your HTTP server would allow you to progressively download the FLV without any special setup. Just giving your choice of flash player (eg: http://www.longtailvideo.com/players/jw-flv-player/) the URL of the flv and it should "stream". The only thing it won't be able to do is seek (seek to a position not yet downloaded).

You can stream the FLV, and allow seeking using HTTP by having PHP control the HTTP stream:
http://www.flashcomguru.com/index.cf...a-PHP-take-two

Here is a PHP class based on this:
http://xmoov.com/xmoov-php/

There is a server implementation in Lighty based on the same:
http://blog.lighttpd.net/articles/20...-with-lighttpd
http://jan.kneschke.de/projects/flv-streaming/

This is better then using PHP, since PHP has a greater overhead, but it isn't a problem with just a few simultaneous downloads.
Last edited by digital-ether; May 31st, 2009 at 1:06 am.
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Newbee... SSL works for .html pages but not .php pages
Next Thread in PHP Forum Timeline: zipcodes packages





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC