How to upload and stream videos?
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?
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
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
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
<?php ob_start("ob_gzhandler"); ?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"><meta name="distribution" content="global">
<meta http-equiv="content-Script-Type" content="text/javascript"><meta name="author" content="Rob Dockrey 2004">
<style type='text/css'>
<!--
.logo {
background-color: #eeeeee;
color: #000000;
text-align: right;
font-family: verdana, geneva, arial, serif;
font-size: 8pt;
top: expression(document.body.scrollTop +
document.body.clientHeight -
offsetHeight );
left: expression(document.body.scrollLeft +
document.body.clientWidth -
offsetWidth - 1 );
position: absolute;
}
-->
</style>
<script type="text/javascript">
<!--//
function shrink(){
document.getElementById("MediaPlayer1").style.width=384;
document.getElementById("MediaPlayer1").style.height=300;
}
function enLarge(){
document.getElementById("MediaPlayer1").style.width=480;
document.getElementById("MediaPlayer1").style.height=402;
}
//-->
</script>
<title>video - Entertainment - Dockrey Apartments</title>
</head><body><a name='top'></a>
<p class='logo'>
<button onclick="enLarge()">large</button>
<button onclick="shrink()">small</button>
<a class='button' href='..'>Main Menu</a>
<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>
<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">
<PARAM NAME="fileName" VALUE="">
<PARAM NAME="showControls" VALUE="true">
<PARAM NAME="PlayCount" VALUE="0">
<PARAM NAME="animationatStart" VALUE="true">
<PARAM NAME="transparentatStart" VALUE="true">
<PARAM NAME="autoStart" VALUE="true">
<EMBED type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="" name="MediaPlayer1" width=360 height=260 AutoStart=true></EMBED></object></p>
<p>Videos<div style='float:left; text-align:left;'>
<?php $p = split('/', $_SERVER['SCRIPT_FILENAME']);
$script_name = $p[count($p)-1];
$path = str_replace($script_name, '', $_SERVER['SCRIPT_FILENAME']);
$dir_handle = @opendir($path) or die("Unable to open $path");
Function get_Extension($m_FileName){
$path_parts = pathinfo($m_FileName);
if ($path_parts["extension"]) {
$m_Extension = strtolower($path_parts["extension"]);
return(strtoupper($m_Extension));
}
else { return "unbekannt"; }
}
function check_image($filename){
$temp=strtoupper(get_Extension($filename));
if(($temp=="WMV")||($temp=="ASF"))
return (true);
else
return (false);
}
Function get_Files($path) {
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if(!is_dir($file) && substr($file,O,1) != "."){
$m_Files[]=$file;
}
}
closedir($handle);
}
if(sizeof($m_Files)>1)
asort($m_Files);
return $m_Files;
}
$files=get_Files($path);
$filter_files=array_filter($files,"check_image");
$maxnr=sizeof($filter_files)-1;
sort($filter_files);
for ($i=0;$i<sizeof($filter_files);$i++){
echo "<a class='button' onclick=\"MediaPlayer1.SRC='$filter_files[$i]';MediaPlayer1.fileName='$filter_files[$i]';\">";
echo substr($filter_files[$i], 0, strlen($filter_files[$i])-4);
echo "</a>";
}
closedir($dir_handle); ?>
</p>
</body></html>
<?php ob_flush(); ?>
serves wmv asf files, without flash overhead
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
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
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
google, utube clone script
upload and serve scripts are always separate
often in the same package, but separate
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
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
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
Great Information digital-ether, Thankyou!!!
I have read your post and had a brief look at your links.
So with the links you have given me it looks like I will be able to:
- Upload a file (PHP).
- Convert it (FFMPEG).
- Store it on the server (HTTP).
- Then play it (HTTP).
Few things I noticed are:
- Should I convert then upload? or upload then convert?
- FFMPEG can be installed onto my server's site, if I have access to the root? meaning www folder?
- Get the idea of the streaming and requests just gotta check that out in more detail for more information and ill get back to ya.
Thanks for the useful and informative information!!
Regards, X
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
Reading the sites now in detail, to start anything I think I need to know how to :
- How do I install FFMPEG onto my localhost? I have a basic apache, php, mysql setup
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
Great Information digital-ether, Thankyou!!!
I have read your post and had a brief look at your links.
So with the links you have given me it looks like I will be able to:
- Upload a file (PHP).
- Convert it (FFMPEG).
- Store it on the server (HTTP).
- Then play it (HTTP).
Few things I noticed are:
- Should I convert then upload? or upload then convert?
- FFMPEG can be installed onto my server's site, if I have access to the root? meaning www folder?
- Get the idea of the streaming and requests just gotta check that out in more detail for more information and ill get back to ya.
Thanks for the useful and informative information!!
Regards, X
- Should I convert then upload? or upload then convert?
It depends on whether you want the process automated, or want to do it yourself. If you can install FFMPEG and FLVTool2 on your server and write the PHP code to do the automated conversions, then you might as well do it and save the manual conversions.
- FFMPEG can be installed onto my server's site, if I have access to the root? meaning www folder?
Root access means that you can log into the system as the root user, and/or gain root privileges in order to install programs and do other tasks.
This is usually given when you have a dedicated server, or a VPS server.
With shared servers, you do not have root access, however, you can ask your host to install the needed programs for you.
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
It depends on whether you want the process automated, or want to do it yourself. If you can install FFMPEG and FLVTool2 on your server and write the PHP code to do the automated conversions, then you might as well do it and save the manual conversions.
So how do I install FFMPEG and FLVTool2 onto my localhost and my server?
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
Reading the sites now in details:
Questions:
- How do I install FFMPEG onto my localhost?
- I have a basic apache, php, mysql setup
If you localhost running windows?
If so download a windows binary:
eg: http://ffmpeg.arrozcru.org/builds/
Then put that into your system path (if you want).
Here is the docs on using ffmpeg command:
http://ffmpeg.org/ffmpeg-doc.html
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
It depends on whether you want the process automated, or want to do it yourself. If you can install FFMPEG and FLVTool2 on your server and write the PHP code to do the automated conversions, then you might as well do it and save the manual conversions.
So how do I install FFMPEG and FLVTool2 onto my localhost and my server?
What are you running on your web server? You can either build FFMPEG or install it using the package manager for your particular linux distribution.
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
Im pretty sure my hosting is LINUX but I run WINDOWS. But I use windows to access both not linux. So I think I would need to know how to install it on windows first and then contact me web host about installing it on the server? or if i just need to install it on the root I can do that myself as I have access. But that still leaves how to install on windows as it only has linux instructions.
Thanks
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
Im pretty sure my hosting is LINUX but I run WINDOWS. But I use windows to access both not linux. So I think I would need to know how to install it on windows first and then contact me web host about installing it on the server? or if i just need to install it on the root I can do that myself as I have access. But that still leaves how to install on windows as it only has linux instructions.
Thanks
On windows you just have to download one of the windows binaries. Here is the link again to an unofficial windows builds: http://ffmpeg.arrozcru.org/builds/
For example, the latest build they have right now is:
http://ffmpeg.arrozcru.org/builds/bin/ffmpeg-latest.tar.bz2
Download that. Then uncompress it on your computer. This will give you an .exe file. Basicaly you're done.
To use it, you just need to open the command prompt:
Start -> All programs -> accessories -> command prompt
In the command prompt type in the full path to the ffmpeg.exe file you extracted.
eg: c:\downloads\ffmpeg.exe
This should give you some info on ffmpeg if you did it right.
For convenience, you want to put the path to that exec file in your windows system path. This is a list of folders that windows will look for commands.
Just search "edit windows system path" and you should have lots of tutorials on how to do that.
Once in the path, you can call ffmpeg in the command line by its name, and not its path.
On my windows system I copied ffmpeg.exe to c:\mybin\ffmpeg.exe for convenience. I have c:\mybin\ in the system path, so what ever *.exe I put in there becomes a command automatically.
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
I presumme you are on a shared server?
As far as I know there isn't a shared server host that supports FFMPEG.
It causes allot of strain on the servers so they tend not to allow it.
If the server doesn't already have FFMPEG installed then you will need Shell Root Access, this is like command prompt for winodws.
I would advise you (if you are serious about this) to falk out some extra money on either a dedicated server or a VPS server.
You should be able to install FFMPEG on either but I would presume you would need a heafty VPS server to handle FFMPEG as allot only allow you 500MB burstable RAM.
Have you thought of building a quad core system and paying a local computer store to give it unsupported hosting (means you have to do everything yourself, it's your computer). Although you would have to falk out £640 for a copy of windows server 2003 (the cheapest) because I doubt you would be able to run a server using SSH.
Shared hosting dreamhost.com has FFMPEG and flvtools2 on the machine I'm on. I haven't used it much, but it worked when I tested it just now. Transcoding a 400MB wmv to FLV with FFMPEG took about 10 minutes. I have no idea if thats considered fast or slow.
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101