This is a neat feature because it is usually only possible to play and seek to a part of a video that has already been downloaded unless you deploy a streaming media server.
Here's the working example. You need Player 8 for this but that's only because I encoded the video using VP6. The rest is compatible with Player 7.
I have uploaded my progress and included all sources.
It should be noted that due to the support of Buraks it was much easier to implement this idea. A new version of flvmdi injects an object containg two arrays into the flv's metadata. It contains the exact starting position in bytes and timecode of each keyframe. Using this information we can request any part of the flv file starting at a specified keyframe. Check this post for more info on flvmdi - the injection is NEEDED if you want the PHP seeking to work.
Thanks to everyone on the chattyfig list who contributed to this and also to Brian Bailey for blogging about his efforts. Thanks also to Lee Brimelow whose scrubber I have used and modified for this app.
*** UPDATE ***
I have made some small changes now:
- the 'buffering' no longer appears once the video has ended. This was done by simply introducing a new variable 'ending' and checking for a NetStream.Buffer.Flush message.
- loading bar shows the download progress again, although this is not that important as you can seek beyond that point anyway :-). But it will be good to further extend the app so that it will not request the file via PHP once it has loaded completely. We could seek normally once download is complete.
- source files have been updated
- another update (09/2007): updated sources by xmoov.com are now available at http://flashcomguru.com/downloads/phpstream_update.zip
UPDATE: Steve Savage has now ported this to Coldfusion: http://www.realitystorm.com/experiments/flash/streamingFLV/index.cfm

This work is licensed under a Creative Commons Attribution 2.0 England & Wales License.

I am very excited about Red5. What I like about this approach is its easy implementation. A webserver and PHP - it doesn't get much easier than that.
Also I noticed that the video doesn't really end well...gets to the end and flashes Buffing Video. Perhaps some simple check to autoRewind or something.
Thanks again!
I had checked your php file. You are reading whole flv file at a time, i think this will become then progressive download. You need to read file from the seek point. I will suggest you to improve your coding in php to read from any given location by clicking on progress bar while playing flv.
Glad to hear it's useful to you though. Make sure to email me if you improve it. I think Patrick Mineault's suggestion is a good one, once the file has been downloaded completely we should use the cached version and not request the file again.
Also, I think is not possible to replay the video from cache if you skip some part of the video, as the stream changes everytime you change the play position you get only the remaining part and not the full video, is this right?
anyway, good stuff, keep it going ;)
I tried to use this method with a huge video (68Mo, 40mn) and the player is freezing when i try to seek.
Do you think it comes from PHP script or actionscript ?
Anyway, very good job, i really like it and would like to enhance the player .
I think for a huge video, the search in the actionscript could get a big performance improvement by using binary search.
Best regards,
Burak
www.asvguy.com
Post the link of big flv somewhere, i like to test.
I think the problem do not come from actionscript as it freezes when i try to seek to the begining of the movie.
The actionscript routine should retrieve the number of the keyframe very quickly in this case so probably it comes from PHP.
I got another question, what should happen if a user try to play a file bigger than the space defined for Temporary Internet Files. Would it crash ?
And one more question : i can't understand why the movie will be downloaded even if you seek to the end of the movie at the begining.
Why classic players are not able to read a FLV with keyframe location metadata injected in it ?
Regards
I would also assume that the 'slowness' may come from PHP but I do not know.
Question 2: What do you mean by 'classic players'? The keyframe info can be read by any player which 'listens' for the 2 new arrays. However only flvs injected with flvmdi27b will hold this info.
http://www.rich-media-design.com/test/scrubber.htm...
Concerning classic players, i understand that keyframe info can be read by player asking for this metadata. But what i mean is that with 'classic players' (not yours) i can read a FLV file without keyframe info metadata but not FLV file containing these metadata.
Strange as other players do not process such metadata so it should not create an issue.
Regards
i've tried ... everything works fine,
but I actually dont know how to use Buraks FLVMDI. I dont which metadata should I add to my FLVs.
With golfers.flv everything goes great. With my FLVs it doesnt SEEK.
Please tell me where is the problem
Thanks
Tom
I'll post an article shortly that shows you how it's done.
Kind regards
tom.krcha.com
while (!feof($fh))
{
print (fread($fh, filesize($file)));
}
..are causing the problem. When you fread($handle, $buffer_size), the interpreter allocates $buffer_size bytes for reading. This causes a problem with large files or, to be more specific, files larger than the memory available to the PHP script. Changing the above to this:
while (!feof($fh))
{
print (fread($fh, 10000));
}
Fixes the problem. You can use a much larger buffer (up to little less than your script memomry limit), but please do some performance testing first.
your comments and fix is much appreciated. However I never claimed that this script is anywhere near production ready, it's merely a proof of concept. In fact I don't even know PHP very well so keep that in mind. Anything posted on my site is meant to be for demo purposes only.
Again, thank you very much for your comments.
Thanks to Michal's new PHP script, we were able to play a huge video using PHP streaming method
(about 90Mo / 40 Min).
Performance seem to be ok when several users try to get the video.
We are looking for a PHP expert that could enhance the script in order to increase performance.
Here is the sample (Flash Player 8 is needed as we used On2 VP6 codec) :
http://www.rich-media-project.com/test4/cool.html
I'm not an expert in PHP, so. I came here to ask about the path. I'd like to make this video works through the internet. How should I set this path: 'C:/.../clips/'
I tryied 'http://www.myurl.com/videos/' and I put my flv into the folder videos, but is not working.
I'll appreciate your help,
Thanks
Fabio
that path is a local webserver filepath, it cannot be substituted by a URL. It will only work if you have access to a webserver running PHP.
It's working now!
Do you know where can I find a FLA sample with a component lists with xml to apply to this?
Best,
F
What should be wrong with my playear, when I drag the button on the progress bar the video doesn't go to the frame and the buffering message start blinking without stopping.
Thanks for your help,
Fabio
it says unexpectet file format. Is the zip file corruptet or ?
I'm on a big scholar project with it but i try to find a way to use it with flvplayback (or netstream but i don't know how to inject cue point to the flv correctly, and dynamically) ... because of netstream doesn't support cuepoint adding ! ThX
Sorry for my english ...
This is a real good one. I am trying to use the Media Server only for realtime streams for a project of mine so this could help. What could be some problems using this in a project with a lot of users? Has anyone tried? Thanks a lot.
I do not know FLVTool2 but I would imagine that it will not offer the functionality of flvmdi (which is needed to make this PHP solution work).
For everyone's information: FLVTool2 is the first tool that implement this feature. FLVMDI followed a day after since I've explained Nicolas (from FLVMDI) how this really cool feature works. He's as soon implement it in his version for others benefit of.
just my two cents on history.
Cheers!
Have you seen Rich Media Project amazing PHP player at :
http://www.rich-media-project.com/test4/cool3.html...
I have written a mail to this french company and they told me that PHP streaming components will be available soon.
Have someone heard about other products ?
David
Other than this, I think the link you posted looks like a great example of the usage of this PHP seeking technique that has been elaborated and enhanced by multiple peoples.
"For everyone's information: FLVTool2 is the first tool that implement this feature."
I don't really care which tool implemented it first. For the record: Stefan Richter (Flashcomguru), asked about this to us on October 25, 2005. We releassed a beta version of FLVMDI with this feature on November 2, 2005.
I think "the idea" was important here; if it had occured to us, we would have implemented this years ago.
So thanks again Frederic and Stefan.
Best regards,
Burak
Sorry I did a mistake, your right Burak.
"FLVTool2 is the first tool that implement this feature. FLVMDI followed a day after since I've explained Nicolas (from FLVMDI) how this really cool feature works."
Should be changed to:
FLVMDI is the first tool that implement this feature. FLVTool2 followed a day after since I've explained Nicolas (from FLVTool2) how this really cool feature works.
:)
Cheers
Thanks
VP6 allow to put keyframes every x frames/s but object keyframe doesn't work ... so using flvmdi !
For me after using flvmdi, I have too much keyframes (double or more) but i have de keyframe object, cool ... but don't really works on the player ...
I just want your settings when you encode video in VP6 ... which is the best codec for flv (i can't return to sorenson) ...
THX and sorry for my english !
As far as we are aware there's no bug with FLVMDI.
If you think any problem is related to FLVMDI, or, have a suggestion how we can improve it, please let me know (burakk at buraks.com).
Thanks,
Best regards,
Burak
So, I think about something : it should be so good to delete all keyframes from a flv movie and to put keyframes with personnal interval (10 frames / s or 1 kframe / s ... for example) with FLVMDI ! We already can ? say me how ! :D
I just wanted to know how encode with on2 vp6 for flv streaming with php ... thanks.
Alexandre
But otherwise I seem to have it working. Thanks a bunch!
In other words, I want to use this to stream my video, but when I take the video off the server, I don't want people to still be able to see the video from their cache (In other words copyright protecting it). Is this possible?
I needed this, as I have a 30MB file to stream. And each time the user changes position (the way the php file originally works), the rest of the file from the scrub point gets re-downloaded. So if a user is in the first few seconds of watching and waits until the whole video downloads (all 30MB), and then the user scrubs back to the say the third second from the beginning, almost the whole 30MB will be downloaded again at the users FULL connection speed. I don't want to waste that much bandwidth.
The code below is limited to 30k/2sec or 15k/sec. Using 30k/sec is more of an average than 15k/sec as the limit is over 2 seconds instead of one, giving the download more of a chance to allow bursts to get the player the amount of file it needs to continue playing while the bandwidth limiting sleep is happening.
Hope this posts readable!
//set below to be your bandwidth
$bytes_per_timeframe = 30000;
$time_frame = 2;
while (!feof($fh)) {
// get start time
list($usec, $sec) = explode(" ", microtime());
$time_start = ((float)$usec + (float)$sec);
print (fread($fh, $bytes_per_timeframe));
// get end time
list($usec, $sec) = explode(" ", microtime());
$time_stop = ((float)$usec + (float)$sec);
// Sleep if output is slower than bytes per timeframe
$time_difference = $time_stop - $time_start;
if ($time_difference < (float)$time_frame) {
usleep((float)$time_frame*1000000 - (float)$time_difference*1000000);
}
}
Also, my bandwidth limit above of 15k/sec is pretty low. Obviously you can change it to 100k/s for videos that need more bandwidth.
Thanks again.
Would be glad of any pointers and suggestions&
Thanks
Without loading the complete file into the player !?
Like that the php file sends chunks of the file to the player, and the player stats playing directly without having the complete 40mb loaded.
anyone ideas on this?
I tried some things with the code 'terry' posted above at 1/25/06 7:53.
But the video doesn't start directly, it starts when the complete 40mb file is loaded.
that is exactly what this script is supposed to do: making it possible to seek to a point in time that hasn't yet been downloaded. As you can see from the demo on the page this works well.
When I test it with a 40mb .flv file I have here, it doesn't start playing at all.
It does nothing.
Concerning switching between local and PHP mode i found a working solution (still beta testing) but it is not really interesting with giant movies.
The main point is to be able to kill the php file in Temporary Internet Files folder.
Anyone has an idea on how we can make this :
From Flash ?
In the PHP script ?
Still will always be flawed. We may be able to discourage local caching but at the end of the day the file you are playing is available online and for that reason it can be downloaded.
Have you experimented with the headers, trying to get the browser to expire the file right away?
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
Will that make any difference?
I realize that its not going to be 100 percent. I just need to weed out the vast majority from being able to easily watch the file again, especially if their browser is too lazy to check for a new version.
However, I moved the name of the file into the php script and set the file name with an identifier from the swf file. So the URL won't contain the flv file name. In other words the url will be www.mysite.com/stream/flvprovider?name=clip1&position=2345. In the php file, clip1 equates to the flv file I want to play.
I also replaced the line in restartIt()
from...
ns.play( _vidURL );
to...
trace("play " + _phpURL + "?file=" + _vidName + "&position=" + 0;
the _vidURL is then no longer used, so I also removed the variable. (jeroen -- do this and I think your problem will be solved because now the file always comes form the php and is constantly regulated)
Since the php file streams the flv file from the backend, the actual flv file name is never seen by the viewer or their machine. If the person is smart enough to download the flv file by just entering the correct url parameters on the php file (www.mysite.com/stream/flvprovider?name=clip1&position=0), then they will be able to get the file as a download. However, they will have to save the file as an flv file and then create an swf file to play the flv file (or find an flv player). This all takes some intelligence, which weeds out a vast majority (80%) of the internet viewers.
if (ns.time >= ns.duration - 3){
bufferClip._visible = false;
}
(Thanks to flashcomguru for posting his original code, or I would not be able to do this. I am hugely appreciative as it got me started.)
Would you mind sending me your updated code? stefan AT flashcomguru.com
I'd like to check it out and give it a test run. I think other people will also find it very useful. A cheap (if not totally reliable) way to achieve some DRM with flv files. Great stuff.
And i've moved the .flv file location outside the http docroot, so they're not accessible directly.
Also i've used terry's code earlyer with $bytes_per_timeframe = 256000;
The working demo i've setup now:
An flashvideo behind an pay per minute phone number.
If the viewer(caller) hangs up the phone, the flvprovider stop's sending blocks of the flv video, and the player stops playing after the current buffer ( 256000b) is empty.
It looks like it's working correctly now, and the viewer can't even watch the part he've already seen after hanging up the phone.
I'm going to clean up the code a bit tomorrow, it's kinda messy now ;)
please post your files so we can keep track of the modifications and additions that everyone adds to this.
Thanks!
also, i realized my post above with the line:
trace("play " + _phpURL + "?file=" + _vidName + "&position=" + 0;
should have been (I copied the trace instead of the line that actually does the work - but the idea is the same)
ns.play( _phpURL + "?file=" + _vidName + "&position=" + 0);
You seem to be on the same page with me...
I just realized that we can make the player even better by including whether or not the buffer is full in the variables that are sent to the php file.
In other words, we can check the current buffer time:
_bufferFull = 1;
if(ns.bufferLength<ns.bufferTime){
_bufferFull = 0; // False
}
then add it to the call to the php file:
my_ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i] + "&bufferFull=" + _bufferFull);
The php file then has the the ability (with a check of the incoming _bufferFull variable)to remove or increase the bandidth limit until the buffer is full!! Thus, increasing the amount of feedback and making the performance for the user better.
this is the dreamsolution for my videosite!
But (I think) I'm in the same path-trouble as demiurgu:
"when I drag the button on the progress bar the video doesn't go to the frame and the buffering message start blinking without stopping. I use flvmdi to inject metadata on flv and i am able to read this data so metadata is corect"
What are the right $path?
Please, give me a hint. ;) thx!
For Linux, if you have access to the command line, navigate to the directory where your flv file is stored and type "pwd" (present working directory).
That comand will show your current path, which is the path to your flv file because you are in the flv folder. Set the $path variable to that output. (should be something similar in form to: /home/users/www/flv/ -- make sure you include the training slash if its not there)
I had some problems when I first tried the script with my own .flv file.
The reason why it didn't play the file was because apache/php didn't had the rights to access the file.
( I forgot to chmod the file )
@terry:
Indeed we're on the right page. I didn't had time the last 3 days to work on the code. So I've no progress on new things.
I won't have any time next week to work on it.( wintersports )
So I'll pick it up again after 12 Feb.
The next problem was the memorylimit of my php-host (16MB),
because my FLVs are 290 to 450 MB! (each)
The example golfers.flv run and seek correct - but my FLVs run only once and don't seek a later position.
The hint from Michal Tatarynowicz are the solution:
>>> print (fread($fh, filesize($file)));
to
>>> print (fread($fh, 10000));
@demiurgu
some time its run, somtimes not? Eventually it is the filesize (or a late seekposition) of your flv. Test the hint from Michal.
Thanks!
But there is one thing : why choose 10000 instead of filesize ? it's in bits, if memory limit is 16MB, why not choose 16000000 (or a bit less) ? ;)
You can theoretically use 16384. But the script also runs it self in the memory. A better value: 15360? (sorry for my very bad english!)
Btw. - its a integer (byte) and 1 MB == 1024 Byte...
I am trying to implement the xml loader, the thumbnail previewer and the progressive functionality all in one.
(See the thumbnail preview and xml stuff on this site)
Here's what happens:
All five videos play when selected in the list (simple with the tutorial). I placed the srubit function inside the event listener.
Here is what happens:
1) All videos load and play the first time
2) Can scrub the first video
3) Cannot scrub any other video.
4) Scrubber resides on the same location as the first video WHY???
Do I need to reset some values. Is my code completely ridiculuos.
(I hope to port the xml from Php and be able to have it all dynamic...)
Here is a code snippet.
Sorry about the formatting...
//Tell Function to do stuff when a user selects an item
listListener.change = function( evtobj ){
// close any current stream
ns.close();
video.clear();
//create a new stream
ns = new NetStream(nc);
//"attach" (pipe) stream to this video object
video.attachVideo(ns);
//Build FLV file name
var flvfile = evtobj.target.selectedItem.data + ".flv";
var _phpURL ="http://www.name.com/Example12/flvprovider.php";
var ending = false;
var amountLoaded:Number;
var duration:Number = 0;
var loaderwidth = loader.loadbar._width;
loader.loadbar._width = 0;
//ATTEMPT TO RESET X VALUE TO RESET SCRUBBER
loader.scrub._x = 0;
// play selected flv
ns.play(flvfile);
//PULL METADATE FROM INJECTED ARRAY FROM FLVMDI
ns["onMetaData"] = function(obj) {
duration = obj.duration;
// suck out the times and filepositions array, this was added by flvmdi
times = obj.keyframes.times;
positions = obj.keyframes.filepositions;
}
//END OF METADATA FUNCTION
//SCRUBBING FEATURE CALLED WHEN USER MOVES SCRUBBER
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * loaderwidth;
loader.scrub._x = ns.time / duration * loaderwidth;
}
loader.scrub.onPress = function() {
clearInterval (statusID );
ns.pause();
this.startDrag(false,0,this._y,loaderwidth,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
scrubit();
this.stopDrag();
}
function scrubit() {
var tofind = Math.floor((loader.scrub._x/loaderwidth)*duration);
if (tofind <= 0 ) {
restartIt();
return;
}
for (var i:Number=0; i < times.length; i++){
var j = i + 1;
if( (times[i] <= tofind) && (times[j] >= tofind ) ){
trace("match at " + times[i] + " and " + positions[i]);
bufferClip._visible = true;
ns.play( _phpURL + "?file=" + flvfile + "&position=" + positions[i]);
trace("play " + _phpURL + "?file=" + flvfile + "&position=" + positions[i]);
break;
}
}
}
//END OF SCRUBBING FEATURE
}
It looks like when you change files, you play the file from the start, so I would expect the headers to get through.
Does everything work if you remove the scubbing? In other words can you change files and have each of them them start and play all the way through from the beginning of the video after changing videos?
One thing I might try (again I'm not a great programmer):
Destroy (or empty) the duration, times, and positions variables before putting the meta data of the new file in them (I'm not sure how the assignment works works, but maybe the new file information just overwrites as much of the arrays as there is information, leaveing any extra length on the array unchanged?)
(replace the AT with an @ and remove the spaces)
I would think for it to work, it would have to be implemented by a second call from within the swf file to another php file (the way you might load an xml file, or maby through another hidden NetStream?) that somehow communicates with the streamprovider.php (maybe it sets a flag in a file that the streamprovider.php opens and checks every few seconds? or maybe php files can somehow share variables and the swf just periodically calls another php file that injects the variable into the streamprovider.php? ) -- don't now if that makes sense, but if possible, coding it would be a little beyond me.
Sorry for my spell.
it looks like keyframes.times and keyframes.filepositions are a large amount of numbers for each frame in the video. Macromedia's video encoder doesn't put this information in the Video, so your scrubber do only work with flvmdi.
On the Website of flvmdi they say, that they do this with a commercial 'flv-library', and they want to keep it secret.
Do you think there is a possibility to build the php to calculate the byte position from a given time position and do like flvmdi does, without having the metadata injected?
Very great stuff, it works on the demo but not in my environment.
When moving to another position, I always got StreamNotFound. I got this message without having done any modification on the source code (except, of course, the URL).
Thanks in advance to provide any advise.
Cheers.
Xris
Actually, the problem was coming from the (fread($fh, filesize($file)); line.
Replacing the filesize by a constant fixed the problem.
Now, let's try to have it running with FLVPlayBack.
Did someone already succeed ?
Cheers.
Xris
FLVPlayback needs a XML file (from Flash Communication Server) or a *.flv for the contentPath parameter. Any other extensions (php here) doesn't work.
Anyway, to get back metadata from FLV using FLVPlayback, I create a netStream connection and get them (ns.play() + onMetaData + ns.close()). There is no onMetaData method for FLVPlayback. You must use a listener like that :
var listenerObject:Object = new Object();
listenerObject.metadataReceived = function(eventObject:Object):Void {
trace("canSeekToEnd is " + my_FLVPlybk.metadata.canSeekToEnd);
trace("Number of cue points is " + my_FLVPlybk.metadata.cuePoints.length);
trace("Frame rate is " + my_FLVPlybk.metadata.framerate);
trace("Height is " + my_FLVPlybk.metadata.height);
trace("Width is " + my_FLVPlybk.metadata.width);
trace("Duration is " + my_FLVPlybk.metadata.duration + " seconds");
};
my_FLVPlybk.addEventListener("metadataReceived", listenerObject);
But I couldn't access to keyframes object by this method.
I think there is no way to stream FLV with FLVPlayback and this method. Sorry ! :(
I think in order to make this work with FLVPlayback we would need to modify a few of its classes. I am sure the metadata can also be added but right now the event may simply dispatch a hardcoded series of properties.
I will look into modifying another, simpler player to provide this functionality. FLVPlayback is good but has some baggage that we don't need for this PHP streaming scenario.
stoem
here's a MX 2004 version of the scrubber.fla:
www.flashcomguru.com/downloads/scrubber.zip
http://philflash.inway.fr/phpstream
This is a beta version.
All sources are available.
Philippe
This is a beta.
All is ok with Internet Explorer but with Mozilla Firefox
there are some bugs.
With Firefox, we will get "NetStream.Play.Stop" events
if there is a seek.
I'm working on a solution but the problem is difficult...
Philippe
www.post-television.com
The generated FLV contains the metadata to use PHP streaming.
Podawan
http://www.realitystorm.com/experiments/flash/stre...
The code probably needs some work, and the site's definitely does, but the code does work.
I thought it would never happen. Great stuff, I'll give it a try as soon as I the chance as most of my apps run on CF too.
PS: my real name is Stefan Richter ;-)
Great program. Looks like it will be quite handy.
Just a thought. In the following line in the as code
if( (times[i] <= tofind) && (times[j] >= tofind ) ){
then ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
might want to put a check just before that and have something like this
if( (times[i] <= tofind) && (times[j] >= tofind ) ){
if(times[j]==tofind) // check upper boundary
i=j;
bufferClip._visible = true;
ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
}
Also, if anyone can point me to some code that reads/seeks binary files in asp i would be happy to change the code to work in asp.
With the php code:
print (fread($fh, filesize($file)));
Might be a good idea to check where abouts in the file you. Say if the flv is 10mb and u seek to the mid part of the flv then fread from mid to the length of the file won't it read 5mb of garbage ? Been awhile since i've used these functions so i'm probably wrong :)
Just curious you will never have the complete flv in the temp int folder ? Unless the user watches the whole video without seeking ?
Terry would it be possible to get a copy of the code you are working on ? Looks interesting. Email is benassi at tpg.com.au
In our project, we work with huge file (2 hours and 1 keyframe by second !) and the actual code seems to be optimized ton find the right position on the positions tab.
Instead of linear search on the tab, I thought to cut the tab in 2 parts while the searched value (tofind) is on one part. So, to be clear, if we have 3000 keyframes, we don't test 3000 times the tab as actual. In this code we have only 11/12 loops (3000/2^12) instead of 3000.
The code :
function scrubit() {
//Value can be a float ...!
var tofind = (loader.scrub._x/loaderwidth)*duration;
if (tofind <= 0 ) {
restartIt();
return;
}
var moitie = times.length; //get number of keyframes to test
var tab_test:Array = times; //Copy of the times tab
var positions_test:Array = positions; //Copy of the positions tab
var j = null;
var valeur = 0; //Index of the searched value in the tab
if (moitie > 0) {
//Showing buffer clip
bufferClip._visible = true;
/*************************
Here, we cut tabs on 2 parts. If value is superior of the value in the middle of the tab,
we delete (slice) the left part of the tab. If value is inferior, we delete the right of the tab.
We do many times and when the tab has only 2 values, we verify
*************************/
while (tab_test.length != 1) {
/************************
This if can be deleted if you want the inferior value (in the exemple, it will be 11 and not 12)
of the tab near the value to find.
Exemple : if tofind = 11.6 and the time tab has two value 11 and 12, it's the value 12 which
will be selected. We take this position and find the searched positions on the tab positions
************************/
if (tab_test.length == 2) {
var ecart = (tab_test[1] - tab_test[0])/2;
var verif = tab_test[1] - tofind;
if (verif < ecart) valeur = 1;
if (verif >= ecart) valeur = 0;
break;
}
else {
j = Math.round(moitie/2);
if (tofind > tab_test[j]) {
tab_test = tab_test.slice(j, tab_test.length);
positions_test = positions_test.slice(j, positions_test.length);
}
else {
tab_test = tab_test.slice(0, j);
positions_test = positions_test.slice(0, j);
}
moitie = tab_test.length;
}
}
trace("play " + _phpURL + "?file=" + _vidName + "&position=" + positions_test[valeur]);
ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions_test[valeur]);
}
}
Perhaps there is error(s) beacause I write it for the function scrub_it() quickly (I tested it correctly with my own tab not times and positions added to a flv).
Here is the original code :
var tab:Array = new Array(3,5,8,10,15,17,19,31,33,34,36,48,52,67,78.1,90,101,111,112,113,114,115,116,120,
121,130,131,132,145,189,190,193,215,234,235,245,253,256,456,478,500,511,512,513);
var positions:Array = new Array(3,5,8,10,15,17,19,31,33,34,36,48,52,67,78.1,90,101,111,112,113,114,115,
116,120,121,130,131,132,145,189,190,193,215,234,235,245,253,256,456,478,500,511,512,513);
var toFind = 234.6;
trace("Taille du tableau
Perhaps there is error(s) beacause I write it for the function scrub_it() quickly (I tested it correctly with my own tab not times and positions added to a flv).
Here is the original code :
var tab:Array = new Array(3,5,8,10,15,17,19,31,33,34,36,48,52,67,78.1,90,101,111,112,113,114,115,
116,120,121,130,131,132,145,189,190,193,215,234,235,245,253,256,456,478,500,511,512,513);
var positions:Array = new Array(3,5,8,10,15,17,19,31,33,34,36,48,52,67,78.1,90,101,111,112,113,114
,115,116,120,121,130,131,132,145,189,190,193,215,234,235,245,253,256,456,478,500,511,512,513);
var toFind = 234.6;
var moitie = tab.length;
var tab_test:Array = tab;
var positions_test:Array = positions;
var j = null;
var valeur = 0;
while (tab_test.length != 1) {
if (tab_test.length == 2) {
var ecart = (tab_test[1] - tab_test[0])/2;
var verif = tab_test[1] - toFind;
if (verif < ecart) valeur = 1;
if (verif >= ecart) valeur = 0;
break;
}
else {
j = Math.round(moitie/2);
if (toFind > tab_test[j]) {
tab_test = tab_test.slice(j, tab_test.length);
positions_test = positions_test.slice(j, positions_test.length);
}
else {
tab_test = tab_test.slice(0, j);
positions_test = positions_test.slice(0, j);
}
moitie = tab_test.length;
}
}
trace("Position" + positions_test[valeur]);
And SORRY FOR MY ENGLISH ...
Alexandre
function scrubit() {
var b_match = false
var f_percentage = loader.scrub._x/loaderwidth;
var i_selected = Math.floor(f_percentage*duration);
/* Guess that the key frame I'm looking for is about the same percentage through
the array of times/keyframes as the position that was selected in the "scrub" slider.
*/
var i_guess = Math.floor(f_percentage*times.length);
if (i_selected <= 0 || i_guess <=0) {
restartIt();
return;
}
do {
if(times[i_guess-1] <= i_selected && times[i_guess+1] >= i_selected) {
trace("match at " + times[i_guess] + " and " + positions[i_guess]);
bufferClip._visible = true;
ns.play( _streamerURL + "?vidID=" + _vidID + "&vidFile=" + _vidFile + "&vidPosition=" + positions[i_guess]);
trace("play " + _streamerURL + "?vidID=" + _vidID + "&vidFile=" + _vidFile + "&vidPosition=" + positions[i_guess]);
break;
}
else if (times[i_guess] >= i_selected) {
i_guess = i_guess - 1; }
else { i_guess = i_guess + 1; }
}
while (i_guess >= 0 && i_guess < times.length)
}
The next step will be to apply Newton's Method for further improvement.
Steve Savage -> Another approach that I thought before. The code works near perfect only if the "video encoding" adds keyframes as much as secondes ! But I doesn't thought about pourcentage ! Very good idea.
For example (a video of 100 secondes, more easy)
loaderwidth = 100;
loader.scrub._x = 10;
var f_percentage = 0.1;
var i_selected = 10;
//There is as much as keyframes than secondes (times.length = 100)
var i_guess = 10;
-->The code make one loop only ! So quick :)
//There is 2 keyframes by secondes (times.length = 200)
var i_guess2 = 20;
-->The code make 10 loops to find the good index.
//There is 1 keyframe by 4 secondes (times.length = 25)
var i_guess3 = 2;
-->The code make only one loop I think ! Cool !
With my code and same video :
1-4 loops
2-5 loops (better)
3-3 loops
Another example with a huge video (4000 secondes)
loaderwidth = 100;
loader.scrub._x = 10;
var f_percentage = 0.1;
var i_selected = 400;
//There is as much as keyframes than secondes (times.length = 4000)
var i_guess = 400;
-->1 loop
//There is 2 keyframes by secondes (times.length = 8000)
var i_guess2 = 800;
-->The code make 400 LOOPS to find the good index (ouch ! but better as actually)
//There is 1 keyframe by 4 secondes (times.length = 1000)
var i_guess3 = 100;
-->1 loop
With my code and same video :
1-12 loops
2-13 loops (better way only here)
3-10 loops
I think I haven't take the best examples here but ... I can say that your code works perfect with small files and/or with keyframes number <= secondes.
If we need precision and a lot of keyframes, my way can be quicker. But finally the two codes are really fast.
A BONUS : with my code, I work with float value (Math.floor not used) and find the nearest keyframe and not the "under keyframe" (ex : times[12] for 11.7 value instead of times[11] as actual).
So, I take note about your "pourcentage method" and I'm interested in Newton's method (but can't find a way to implement it correctly ...)
PS :
with this line : "while (i_guess >= 0 && i_guess < times.length)"
I think it should be no scrub in the last keyframe ... "times[i_guess+1]" is undefined if "i_guess = (times.length - 1)" ... so, "while (i_guess >= 0 && i_guess < (times.length - 1))" is the good way ...
!!! : I notice with this postscriptum that the actual method doesn't scrub correctly if we take a value of timeline > of the last keyframe (ex : last keyframe at 100 secondes and we search 100,34 secondes) because of comparaison "if( (times[i] <= tofind) && (times[j] >= tofind ) )" ...!
It's not a problem with my "slice method".
Alexandre
Alexandre
We have extended this player to an advanced level.
Please check below URL.
http://www.dearmyfriends.com/v13/popup.php?idx=390...
Points covered:
i) dvd kind of chapters ( list of intersting poitnsto jump directly to that video part).
ii) can be viewed in different sizes. ie 1x,2x etc
iii) Previous and Next Video buttons( Yes..the two korean buttons provide this)
iv)Exact loadbar showing what bytes loaded to browser.
v) Enhanced php to send bytes to browser
http://www.dearmyfriends.com/v13/popup.php?idx=390...
Thanks
Sudhi
http://fmx.exellen.com/v13/popup.php?idx=311&m...
Sudhi: your page does not contain embed tags for the swf, therefore the page only work in IR and not in Firefox.
Also can you make the source files available?
thanks
It is still under improvement, SO I cant open sources at this stage. If you have any thing to say , you can mail me.
http://fmx.exellen.com/v13/popup.php?idx=398
check above video, which is streaming at 2 MBPS.
I have added Embed tag, so it will work in other browsers too..
--Sudhi
<object type="application/x-shockwave-flash" data="scrubber.swf?file=video.flv" width="420" height="315" wmode="transparent" VIEWASTEXT>
<param name="movie" value="scrubber.swf?file=video.flv" />
<param name="wmode" value="transparent" />
</object>
Now from what I have gathered I need it to look like this
<object type="application/x-shockwave-flash" data="scrubber.swf?file=flvprovider.phpfile=" width="420" height="315" wmode="transparent" VIEWASTEXT>
<param name="movie" value="scrubber.swf?file=flvprovider.php?file=video.flv" />
<param name="wmode" value="transparent" />
</object>
and I have tried both and neither work? I get buffer that never buffers. Any idea?
Thanks for your help.
Roger
Here are the details:
I'm embedding the flash player on a website that uses PHP and MySQL to pull information about a house/property from a database.
There is a PHP variable called $ID which corresponds to the folder that the FLV file sits in on the web server. So there will be a main folder called "properties" with many subfolders inside ("1", "2", "3"....) Inside each subfolder will be a "name.FLV" file which I want the one player to play. The actual SWF Flash Player will sit in the root folder of the webserver.
When I showed videos in the WMV format I used URL's that looked like this to pass the variables.
http://www.domain.com/m.php?video=ID
Then the code for the embedded player would look something like this:
<embed src="properties/< echo $ID; ?>/name.wmv" ></embed>
My question is how do I use the variables that are in the URL to determine which FLV file my flash_player.SWF file plays?
Any help would be greatly appreciated.
Thanks.
Elliot
One problem that has already been mentioned but not solved yet: when the user watches a part of the video and then moves the slider to a previous point in the timeline the video gets downloaded again. I think that this could sum up quickly and waste a *lot* of bandwidth and that's the only reason why I'm hesitating to use this approach.
Do you think it would be possible to solve this problem? I haven't had an idea yet...
In a way this issue is apparent in all streaming server solutions: if a user seeks and plays the same part of a video 3 times then he will consume the bandwidth 3 times. The PHP approach is 'worse' in a way because you may be downloading more footage than you are actually consuming - when you seek to another point that entire process starts again and for every 10 seconds watched you may be downloading 30 seconds worth of footage - in this way a real streaming server is much more efficient. So yes, potentially the PHP method will waste bandwidth.
http://www.rich-media-project.com/products/test2
It is still under development but once again Rich Media Project guyes are pushing PHP technology to the next level...
This product would be perfect if only we can protect flv files from being downloaded.
The flv is deleted from the temporary Internet files but if i use a sniffer i can get the link to the php page with the variables required to download the flv (as a php file that just need to be renamed with an flv extension).
1) The swf can be encrypted, but i would still be able to sniff the link and download the file because the variables are sent to the PHP script using a GET method.
I don't think it would be possible to send variables using a POST method but someone has probably an idea concerning this point ?
2) The PHP script can ask for the HTTP referrer but once again it is easy to fake this data.
3) I thought about a cookie but the user would be able to watch the original webpage and download the movie at the same time.
4) Google Video, Youtube, Metacafe, Music movies can be downloaded easily so there is probably no solution to secure movie in flash.
Security is always a problem :(
i get no video in IE.. please help.. firefox works fine.
url: http://onetribedesign.com/bridal/chris.htm
the video on THIS page does NOT work in INTERNET EXPLORER either... only firefox!
thx for checking, but it's still not working for me. i have IE 6.0.2900.......... i also checked it in IE 6.0.2800........ neither will show video.. only audio...
another person told me they could see it in 6.0...
the coldfusion one works in my IE... but i can't use that :-(
any ideas on why I can't see it but you can? i checked IE settings and all is ok there.. :-)
Does the clip on this page work for you?
the clip on this page will work for me in firefox.. just not ie
same with my clips
I am however having a problem implementing...I think my error is in defining the $path variable in the flvprovider.php file.
I have $path = 'http://www.mywebsite.net/subfoldername/';
Is this correct?
If I target flvprovider.php directly in the browser I get the following error:
0ERORR: The file does not exist
Any help greatly appreciated!!
the path needs to be a path on disk, for example c:\myapp\myvideos - not a URL.
Stefan
Thanks...almost there.
I get the following using a script to determine my system path:
Path to server root: /dh/
Path to this file: /home/.test/clientname/sitename.net/mydirectory
So would the correct $path variable be?:
/dh/home/.test/clientname/sitename.net/mydirectory/
Thanks again!
Thanks
Could someone please post the content of scrubber.fla here so people without flash mx x.x are able to figure out what happens in there?
Or could anyone just post a sample html or php code fragment, which shows how to tell this thing which special xxx.flv file it should use (where to use parameters)?
(i can't belive its hardcoded in the .swf)
A version for MX 2004 is here: www.flashcomguru.com/downloads/scrubber.zip
all the PHP code is published also.
If your version of Flash is even older than MX 2004 that then you're out of luck, but I'm sure you can find someone to compile a version for you. But don't expect us to hand you everything on a golden plate, if you don't like the way the fla works then change it, that's why it's there. But usually yes, you need Flash to edit a Flash file...
first i wanted to say its an exellent work. actually i just wanted to know if im already able to handle parameters for the filename to the swf, which i already have. but its o.k. i have downloaded the 30 day trial of flash from adobe
All of this is very interesting. Can it be applied when there is only an audio channel within the FLV i.e. no image at all ?
From my understanding, metadatas apply only to video keyframe.
Barbara
Thanks
Barbara
1. I can say something like ns.play("myfile.php?vid_id=1234")
2. PHP will retrieve "vid_id", find the appropriate flv, and feed that flv directly back to the flash for playback.
Basically, I don't want to define the flv in flash. Rather send an id var to php and have php determin the flv based on that, then pipe the flv back to flash (via a fread). Is this possible? Do I make any sense? Sorry guys.
http://www.realitystorm.com/experiments/flash/stre...
http://www.flashcomguru.com/index.cfm/2006/6/18/li...
I only hardcoded the flv name for the demo, I didn't realize so many people would find it difficult to make dynamic... sorry.
first, thanks for all the infos and srcs, i was able to get this to run also... cool stuff...
im planning on using this stream way on a big site with about 1M unique users per day...
there could be much bandwidth saved, if it can switch to hdd/cache mode, if a full copy has been saved...
is someone able to edit/switch the code to import this function? it should really make sense and will reduce alot of $$$ traffic costs...
please post your opinions, or msn/icq number for more contact - im also willing to pay for this additional feature, shouldnt be so hard... (im a good coder also in php etc.., but like 10% flash knowlegde hehe)
guess alot of other users are intrested in the cached-after-fulldl solution, what do you think... who is able to do it :)
All looks great - i have a question - is this possible...
Can you send to the swf/flv/php a starting keyframe/timecode and an ending keyframe/timecode and then have a new .flv file produced on the fly dynamically of that subsection of the original .flv file?
I know this doesn't do that now but is this even possible with some coding so that a user can enter a start and end timecode and press "Generate Clip" and it creates a new .flv file of the movie between the start and end timecodes given?
My knowledge on flash is about 10% so any advice appreciated if that is at all possible?
I am having troube getting this working, can someone tell me how I use the variables, possibly post an example.
$seekat, $filename, $ext and $file
Let me also say that I'm not really interested in the partial streaming discussed in this article, although it is a very cool feature! But just getting larger files to initialize and run correctly.
It seems when the netstream.play() method is encountered, IE has an undesired pause/lock-up effect. The larger the file the longer the hickup. My animated buffering clip stops, and any attempt to resize, move or click on the address bar sends the browser into "Not Responding" mode. A varying number of seconds go by and then the video plays as it should and the browser goes back to normal. Firefox and Safari work fine. I thought it was just something wrong in my code but then I tried out your player and the same thing happens.
Has anyone else run into this or better yet solved this?
Here are some links to example files, some with my FLV player I wrote and some using the code posted here...
7mb file runs okay:
http://dev.vectorform.com/test/7meg-mine.htm
40 mb file, slight pause:
http://dev.vectorform.com/test/40meg-mine.htm
150mb file, very noticeable pause:
http://dev.vectorform.com/test/150meg-mine.htm
some of the same files with your FLV player...
http://dev.vectorform.com/test/150meg.htm
http://dev.vectorform.com/test/40meg.htm
thanks
I have a question though, hope its not stupid because im a complete newbie ;-)
Im setting up a website for me and mt "artist"friends where we can upload all kinds of media trough our php coded CMS into our MySql database...
Is it possible to upload the encoded flash video file, trough our CMS into our databse, and play it trough this videoplayer on our website (when requested?)
please help and thanks for developing...
Dirk
I've created such a plugin for the Xoops CMS, where you can stream FLV video files and even sell viewing access on a Pay Per View basis. Check it out here: http://xprojects.co.uk/modules/news/article.php?st...
I've also got the Flash player incorporated into a complete website hosting solution in http://xtotal.co.uk.
Cheers.
Does it make sense, should it work ?
Thanks
Parse error: syntax error, unexpected T_STRING in /home/restricted/home/fabiotokarski6565/public_html/flvprovider.php on line 21
I can't figure out what can be done to solve this problem.
Thanks
I've got it working with only a few concerns. The ns.setBufferTime command seems to be ignored by firefox as whatever i set it to it trys to play straight away which results in stuttering.
Also, when a video is playing i cannot move to another page (via simple hyperlink) unless i stop the video first.
Any ideas?
AddType video/x-flv .flv
http://blogs.ugidotnet.org/kfra/archive/2006/10/04...
;)
oh and nice php too... hahaha
i amon vacation and have no access to flash in english and need to have a player saved to .swf!
i still have the php etc but cant make the player! i need this back upon my site ASAP.
you can email me if you can help.
Is there an easy way to make the video autoplay? I've got it to work but firefox seems to ignore buffering and tries to play straight off. Am i missing something?
Also, what's the best way to play mutiple movies with this player? If i embed the menu in the player is there anything i should bear in mind? I've setup buttons that change the _vidURL but should i be resetting other vars?
I've also found that when a video is playing i can't visit other links on the site until the video has stopped. this doesn't happen on this page - could it be the bitrate of my videos?
Thanks!
Best regards,
Burak
Well, a real solution for security will never exist. SWF Encrypt is today the best solution, I think. It's not an easy what of obfuscating, just take a look. Streaming solutions are the less secure today. You can save any streams like this! FLV player with encoded files should be much better in this case. I am just searching for a solution like this.
Thx!
:)
I can not make recorded flv by fms2 seekable.
demiguru reported earlier this problem, it seems he got it working, but did not put up his solution.
other flv. (flash video encoded, then metataged by flvmdi) are seekable, its just the fms2 that do not work with me..
tried micheal's solution (changing php script for large files)
did anyone have this problem before?
any suggestions?
I suppose that, the FLV format headers in the flvprovider script do not match this codecs and this may be the reason they're not seekable...
Now I need to find the correct FLV format headers...
I also found out that in this section of the flvprovider:
if($seekat != 0) {
print("FLV");
print(pack('C', 1 ));
print(pack('C', 1 ));
print(pack('N', 9 ));
print(pack('N', 9 ));
}
you can replace the lines in {} with
print (fread($fh, 13));
that replicates the 13 first bytes from the .flv. Unfortunately this still does not work with fms2 recorded flv as I suppose there may be some more infos missing...
any help would be appreciated, thanks
Tim
I need some help implementing php streaming. So far, I have:
1. Downloaded the source files.
2. Changed the video file path in flvprovider.php
3. Downloaded flowplayer.
4. Injected metadata into the flv using Boraks' tool.
I've used flowplayer before but I'd like to use php streaming with flowplayer. Here's the code for a flowplayer instance:
<object type="application/x-shockwave-flash" data="FlowPlayerLP.swf" id="FlowPlayer" height="300"
width="300"><param name="allowScriptAccess" value="sameDomain"><param name="movie"
value="/FlowPlayerLP.swf"><param name="quality" value="high"><param name="scale"
value="noScale"><param name="wmode" value="transparent"><param name="autoplay" value="true"><param name="flashvars"
value="baseURL=http://www.xyz.com/videos&videoFile=/video.flv&loop=true">
</object>
How do I use flvprovider.php with flowplayer ? Do I set the location of the flv as flvprovider.php?file=videoFileName.
Need some help here...
Regards,
Vikram.
i need some testers.
anyone intersted? it will act as a live stream almost where it appears like a TV show... please email me at dynamitemedia@hotmail.com and tell me if your intersted.
or i can post the code here as well
also my server seems to be off the real time so you may or may not need that part.
i would appreciate anyone else testing this and telling me how it works.
you can also change how the video file is read but i will have the files named in that order. you can change it however you can
i think this could save bandwidth and especially if you want to schedule programs like i want to..
please send comments to me and test results
////////
////
copyright dynamitemedia@hotmail.com but can be edited or used however you choose with permsision 1st
i had another contributor but lost his email addy :( will look for it and add it
////
$path = '/home/videos';
$format ="flv";
// Server time
echo "<b>Server Date & Time:</b><br>";
echo date('m-d-y-H:i:s') ."\n";
echo "<br>";
//get the real localtime in mexico city
$differencetolocaltime=-22;
$new_U=date("U")+$differencetolocaltime*60.45;
$localtime= date('H:i:s',$new_U);
$protime = date('H:i',$new_U);
$VidPos = date('i:s',$new_U);
$vid_time = date('H',$new_U);
// round it and go back to last :30 on the schedule
$round_by = 60 * 30;
$rounded_time = ( round ( time() / $round_by) * $round_by);
$prog_id = date('m-d-y-H:i:s', $rounded_time-60*30);
echo "<br><b>Central Standard Time: </b><br>";
echo $localtime;
echo "<br>";
echo "<br><b>Program ID: </b><br>";
echo $prog_id;
echo "<br><br>";
echo "<b>Video Position:</b> <br>$VidPos";
echo "<br><br>";
echo "<b>Videos Path:</b> <br>$path";
$VidID = "$path/$prog_id.$format";
$VidPosition = $VidPos;
$vidID = $_GET["$VidID"];
$vidPosition = $_GET["$VidPosition"];
echo "<br><br>";
echo "<b>ID :</b> <br>$vidID";
echo "<br><br>";
echo "<b>Position:</b> <br>$vidPosition";
///
sorry about the multiple posts!
//
<? php
//
found the other contributer:
security improved by by TRUI
www.trui.net
play video by server or anytime you choose by dynamitemedia@hotmail.com
//
$path = '/home/videos';
$format ="flv";
//get the real localtime in mexico city
$differencetolocaltime=-22;
$new_U=date("U")+$differencetolocaltime*60.45;
$localtime= date('H:i:s',$new_U);
$protime = date('H:i',$new_U);
/*--->>*/$VidPos = date('i:s',$new_U);
$vid_time = date('H',$new_U);
// round it and go back to last :30 on the schedule
$round_by = 60 * 30;
$rounded_time = ( round ( time() / $round_by) * $round_by);
$prog_id = date('m-d-y-H:i:s', $rounded_time-60*30);
$vidID = "$path/$prog_id.$format";
$seekat = $VidPos;
$filename = $vidID;
$ext=strrchr($filename, ".");
$file = $path . $filename;
if((file_exists($file)) && ($ext==".flv") && (strlen($filename)>2) && (!eregi(basename($_SERVER['PHP_SELF']), $filename)) && (ereg('^[^./][^/]*$', $filename)))
{
header("Content-Type: video/x-flv");
if($seekat != 0) {
print("FLV");
print(pack('C', 1 ));
print(pack('C', 1 ));
print(pack('N', 9 ));
print(pack('N', 9 ));
}
$fh = fopen($file, "rb");
fseek($fh, $seekat);
while (!feof($fh)) {
print (fread($fh, filesize($file)));
}
fclose($fh);
}
else
{
print("ERORR: The file does not exist"); }
?>
Como fa
Can you Extract medadata off a flv file from PHP ? so you can display a file's get a file's framerate ect ?
thanks in advance
Fanno
flvtool2 seems to need the stdin to close before starting its output, implying that it needs the full file before creating its tags. (it must know the size?)
must the player either have the metatags OR the full file to start playing? Can I not play a file as its being created?
I am looking for ways to prevent/minimize the possibility for people from caching my flv video and I happen to find this site. I like Terry's solution but i do not quite understand his soln.
Can anyone kindly explain:
"how to moved the name of the file into the php script and set the file name with an identifier from the swf file. So the URL won't contain the flv file name."
Thanks.
I'm experimenting with streaming flv via PHP. I build a simple player, but keep getting this one problem. While scrubbing the video I sometimes get a distorted image, like this:
http://img224.imageshack.us/img224/690/untitled1eg...
The video stops playing, but Flash keeps loading data in the background. I'm using the On2 VP6 codec (compressed with the default 1Mbps profile in Squeeze) and the flv has the metadata injected with Buraks MetaData Injector.
Anyone an idea what can cause this problem?
1. A button to enlarge the video player. Either as a layered div over the top of my other content in the site or a popup window.
2. Put a basic time counter together so users can see where they are in the current video.
I will pay TOP DOLLAR for anyone that can help. I'm on icq if you use it: 24142711
thanks,
marc
We will try to improve the file. Pls provide us with the source code.
marc
i've tried this, but it doesn't work.
When i write the address
http://www.modelfinder24.de/flvprovider.php?file=t...
a download dialog will come and ask me, where to save "flvprovider.php. If i save it, the flvprovider.php have the size of the video, i think also the content, but it will not be shown!
best regards
Torsten
you need to hit the PHP file from the SWF (flash), not directly from your browser.
please check www.ahna.nl/test/
I made FLV video's and inserted META tags with Bulak's Meta Injection
The .swf player (my own and the original one with my .flv files) works fine in Macromedia Flash player and IE. In Firefox when i try to seek CPU load goes to 100%.
I am using this php streaming script. it streams well but while it is buffering if you click on a link, page doesnt change. it changes the page after it loads full flv file. i didnt user that scrubber.fla. is it because of it. or because of flvprovider.php
thanks
1) after uploading Audio / Video file, it should convert into .flv format, with our logo in the flash.(Example: break.com or myspace.com)
2) Capture screen shoot of the flash video in .jpg or .gif
3) Store the file name in mysql database.
4) Stream the same in flash & on each click save the info (# of hits) for the flash view in mysql db.
5) If require help in setting up streaming server (optional)
pankaj
First of all, very nice scripts!
Only one thing got me stumped. I'm serving up the PHP script from a Debian/Apache server. Whatever i change my $path to it does not seem to scrubble, movie starts fine but when i move the playhead it just stops.
My fullpath looks like:
/home/httpd/vhosts/mydomain.com/flv_test/
Anyone has any experience getting this to work on a NON-windows machine? thanx...
Also when visting fileprovider.php directly in the browser i always get the file-not-found error. Does it only work when calling it from flash?
If we look at how this system is broken into:
The user gets hold of the php file and download it via flashget or other stream/file downloader.
What will happen next: the downloader will use GET to download the whole flv stream.
However: we can change the system so that the php handler requires different querystrings at different time intervals. (this feature can not be mimicked by stream/file downloader)
The problem: Are we able to merge the flv files in the swf player so that at the front end there will be one smooth video?
This solution only increases the difficulty for the user to grab the file; determined user can at last use sniffers to download pieces of flv videos and decompile the player to learn how to glue the videos back together.
I too worked on this FLV streaming and it works in linux and on most windows but not all windows OS .
I opened the flv file in binary mode. The problem is with the fread() function in flvprovider.php returning the part of FLV file from seek position.
the fread function is not returning the content in correct format.
when i opened the actual FLV and FLV from the PHP file in a text editor i saw some characters changed to some other format and hence the flv is not playing.
Please help me in working it.
can you describe a little more? I see a download dialog too. What does "hitting the PHP file from the SWF (flash)" mean? Where can I find a sample swf file?
the swf can be copmpoiled from the fla contained here:
http://www.flashcomguru.com/downloads/phpstream.zi...
damian:
are you saying that you already have external XML which contains file info that you want to inject? Or are you simply looking to process FLV file in the usual way, but these files turn out to be very large?
The largest file we successfully injected is currently 700Mo.
thank you for your concern. can you show me a sample HTML file too?
i have a 1Gb FLV. when i try to "inject" it, FLVMDI runs out of memory. I have spoken to Burak about this and he is working on a fix. Any other workarounds?
Also, can someone point me to the actionscript code to load keyframe data from an external XML file, instead of the injected metadata.... i can hack my way through it but it'll take me an hour or more when i know i've seen it around here somewhere but i cant find it... thanks!!
D
I tried different things but nothing fixed this problem. It seems that the Fifefox Flash Plugin ignores the bufferTime and plays directly after start and so the plugin and the browser freezes. Sometimes it works fine i think when the speed of the server is enough so that the player can play immediately.
The unclear thing is that when the video starts from the begining ist works nearly fine but when i seek the firefox breaks down. Could this be a Problem with the Header of the Stream? I tried to send the complete header and metatags from the flv and then send the file from the right position but this didnt work. I dont know if there is a finish sign at the end of the metatags or something like that.
Maybe someone have a nother idea to solve this problem ... keeep going
fantastic stuff!
Nevertheless I have the same experience described above about Firefox: Once I try to seek, the movie jumps to the selected position but then it is only stucking. If the video is larger, the stucking goes on until Firefox freezes (see http://www.time-matters.com/test/imageDeutsch.htm). If the video is shorter it stucks but then comes back to normal (see http://www.time-matters.com/test/taube.htm).
Does anyone know why?
Robert
Has anyone
I have been experiencing the same problem mentioned above in mozilla and IE 7 .
it plays for 1 or 2 seconds and then stops.
is it the problem with mozilla or any buffering has to be adjusted in the PHP file?
does any one have any idea on it?
I have previously asked how to manipulate flv in PHP ( metadata ect ). With another guy i founed he created a tool for this. i have been working on improving this and i have added new features such as playback, and thumbs and preview runtime. And also have bandwidth limiting. This tool still need lot's of testing. whitch i hope some of you may wish to help with =), at this time there are a few known issues whitch i am trying to work out. such as:
Duratsion of perview not matching
Filesize in flash becomes -1 ? properly metadata issue.
Issue with Backplaying with lock when starting two movies at the same time.
This is the current documentation i have on it: http://fanno.dk/index.php?option=com_content&t...
I have one Showcase site to show it in action. Whitch since i am working on it from time to time MAY be not working:
http://test.fanno.dk/flv_test.php
But i d like to use this function with .flv-Files from a Video-Prodiver like youtube etc.
If i use the download-url of the .flv i could see the video but as soon as i seek i stops.
Is there a possibility to seek videos from another server?
i want just to let my clinets in my website to upload videos in any formats an those videos will be viewed in the website in a flash format, the probelm in the step of converting from video formats to flash viedo player
Now i try to do a player like the one available at the google video website. What i mean is you can enlarge the video full screen(not with the full screen method available in flash 9 because we want real fullscreen in a javascript popup windows) and continues the streaming of the video at the same point. Actually, i'm able to open the video full screen and restart at the same point. I do this with two swf files, the original scrubber and an adapted full screen version. I pass the parameters via a php url. The problem is: The scrubber doesn't move at the same point where he we're on the original video and when i scroll the scrubber. The video restart at the beginning.Here the script of my full screen fla file:
###
Note from Editor: I have removed your code, it was way too long and broke the page layout too
###
Can some help me please?
Thank you
BTW: my email is ftremblay666@hotmail.com
Best regards,
Holland Risley
PHP info identifies my document root as:
/home/khmsite/public_html
I have the flvprovider.php, the scrubber.swf, and my .flv file in a folder named "media" in the main public_html folder.
I have set the scrubber to the following:
var _vidName = "DocName.flv";
var _vidURL = "http://www.kathiehillmusic.com/media/" + _vidName;
var _phpURL = "http://www.kathiehillmusic.com/media/flvprovider.php";
And I have flvprovider.php set as follows:
$path = '/home/khmsite/public_html/media/';
I keep getting the "ERORR: The file does not exist" message and I've tried removing the "/" before and after paths, tried changing the "public_html" to "www" but nothing seems to work. I'd really like to use this and am very excited that it's available... more so if I can get it working!
I see some references to a lot of other stuff like FLVMDI ... do those need to be installed/configured as well... or is it really as simple as uploading the three files in this zip with the correct paths set?
header("Content-Length: " . filesize("your FLV file here"));
and it works.
Thanks!
you are a genius! today a ordered a streaming server for a client but now i canceled the order. thanks for your work. i tried a lot but never to put the filesize into the header. respect.
keep going.
But hard coding the file size in header function will work.
Does anyone know?
I'm traying the phpstream. It's really fine.
But a I can't to adapt the arrow of the scrubber.fla to my flv. I move the arrow but doesn't work.
I will be thankful if anyone tell me how I can to solve it. I'm using the same settings of golfers.flv.
What I have to change? Please
Thank you
Peter
I think I have to change something in the actionscript of the golfers.fla to adapt the arrow of the controlBar to a new video. But I don't know which is this change or other trouble.
I'm using the same settings of the golfers.fla but when I work with other video and I want to move the arrow and doesn't work. Only works in the beginnig and the end of the new video. Please tell me if I have to change something to adapt it.
Regards,
Peter
session_write_close(); before starting to stream data in the wrapper script otherwise the player will freeze your browser until the video is done downloading.
www.justquickit.com/movie.phtml
Many people asked about the issue, but it appears nobody is willing to answer? I suppose it's the position variable that is not passed properly?
Any advice would be greatly appreciated. I'm a newbie at this.
Kind regards
Here is the correct file
http://www.justquickit.com/video.phtml
Great stuff Stefan!! Thanks for sharing.
http://www.justquickit.com
1.flvprovider.php
2.golfers.flv
3.scrubber.fla
So, Plz.. tell me
ARE those enough to play .fla file ?
tell me what to do after downloading phpstream.zip file,,,
is any change required i php.ini file to play .fla file...
Waiting for regards..
* be able to tell the video file to the flash player as a parameter
* translate the player to spanish and do some design tweeks
* remove the PHP memory limit, as explained in a previous comment
Here is an example of the result (1h40 / 200Mo video):
http://socios.smo.org.mx/modules.php?op=modload&am...
To download the files:
http://socios.smo.org.mx/videos/flashphpstream.tar...
the player is inserted in a page this way (note the "?video=sesion20061205", which the video file to play):
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=
"http://download.macromedia.com/pub/shockwave/cabs/...=7,0,19,0" width="498" height="444">
<param name="movie" value="http://socios.smo.org.mx/videos/phpstream/scrubber... />
<param name="quality" value="high" />
<param name="menu" value="false" />
<param name="wmode" value="" />
<embed src="http://socios.smo.org.mx/videos/phpstream/scrubber... wmode="" quality="high" menu="false" pluginspage=
"http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="498" height="444" />
</object>
Thanks again!
PS: you may want to hide the buffering message before the user presses play. Nice job.
No special implementation, just the files in the package, with the tweaks already mentioned in the thread (the filesize fix posted by Michal Tatarynowicz and the firefox stuttering fix posted by Raghu), along with the slight mod (volume slider) to the player itself.
Good call on the pre-play buffer message. I hadn't even realized that.
would you mind posting the 'fixed' PHP script somewhere for download?
thanks
I have also implemented the Flowplayer anti-leeching feature by developing a php wrapper to perform authentication against the .flv request.
http://ffaat.pointclark.net/blog/archives/129-Flow...
It would probably be simple to combine the two to provide the anti-leeching and the mid-stream seeking function...I'll post more if I get it working.
-Rob A>
and i also wants to to play video using applet or flash player in php
so,plzzz help me
I've tried putting in the:
print (fread($fh, 10000));
... code.
I've used FLVMDI with the k switch on my videos. I've also tried it with the golfers.flv. Same result
But again, everything's fine on my WinXP laptop, but on the Linux webserver, it start playing but after using the scrubber, its constant "Buffering Video".
What am I missing on this other server?
When I use a php script to return the file in chunks it seems to keep the page in a "loading" state so that clicking links doesn't register until the FLV has loaded. Anyone else running in to this?
Ex: ns.play(getfile.php?vid=zzz)
it doesn't happen when you call your FLV directly. Ex: ns.play(vid.flv)
<?php
while(!eof($handle)) {
fread($location,8064);
}
?>
Sorry the code is at work, that's the php getfile (estimated) code returning the FLV file.
http://www.streetologyinc.com/network DOESNT FREEZE
Email me and i will send you a link to the site under development that does freeze using the php call. I don't think I can release the url here (its beta)
no it most likely will not.
can someone spare a moment and write a short readme file for those of us who are newbees ?
Thanks a million
I do have the same problem. The hyperlinks doesn't work when FLV content is from the PHP file. Any way to get around this.
Thanks
Yes u need Macromedia Flash
I downloaded the zip file.
unzipped, put it all in the same directory.
Set $path to the directory.
and embedded the video on a html page.
It just won't work.
am I missing some thing?
Olso can anybody have the youtube clone plz if forward to me.
http://doublewingsymposium.com/scrubber.html
I have a project where they don't use php on the server.
URGENT!!!!
Anyone who knows if it's possible to do ???
Speak to me.
Regards,
I am interested in getting this to work on my server. I am not an expert in PHP, but have been running a couple of Geeklog sites for a couple of years, and can fumble around with it to get things to work.
My problem is, that I do not understand how to get the files to be recognized. I changed the script to point to my directory with the flv file in it, and the ownership is the web user. I get ERORR: The file does not exist
When I try to open the php page.
Do I have to specify the file name somewhere in the script?
Thanks for any help at all.
Regards,
Rick
Just thought I would give a little more info on my server. I have Suse 10 running with Apache 2, MySql, and PHP 5.
My Geeklog site is running fine on this.
I just now installed Xoops and xStreamer and this works with flv files.
However, I would really like to use the solution described here on this page. It sounds very cool.
Thanks again,
Rick
The "Buffering" issue is driving me nuts. I changed the code to:
print (fread($fh, 10000));
... code.
But issue still persists. It shows buffering if the video is scrubbed. Nobody is giving an exact reply for it. Really frustrated :). Please show me where I am going wrong...please....
Thanx in advance
The new phprovider file in the updated link corrects the buffering issue:
http://www.flashcomguru.com/downloads/phpstream.zi...
But the flv file is cached in the users system as in progressive downloads. But rich-media php flv files does not cache the video files in users system, like the real streaming :). This project has got just scrubbing feature.
A firm in Germany has atlast introduced Digital Rights Management (DRM) for FLV files. Check it out here:
http://www.onlinelib.de/index_EN.html
VCS Live Broadcaster for Adobe" Flash" Player.
ns.seek(tofind);
ns.pause();
}else{
ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
};
Adding this to the scrub function might help to use the "normal" seek method once a file is fully downloaded.
I haven't tested this which large FLV files yet.
As its associated with the FLV file extension it kicks in tranparantly. to get the FLV file at a seek point simply add the parameter to the file *.flv?pos=1000 for example, now the webserver will return the file as the php one did.
I wanted to see if anyone might find this useful like me? if so and enough people want it i might consider building a release version.!?
ttfn, JBoi
Yes, I would be very interested in a ISAPI extension. Is there something you could share here?
The ISAPI Extension is installed per website, the only configuration required is the installation wihtin IIS but that is a trivial job.
You will need to make changes to the flash player though. you dont need as many variables, for example you only need the file name.Everything gets a little easier. :)
I'll see about putting somthing together for a release version. not sure if freeware, postcardware or licence yet. any thoughts?
How would you want to configure the extension? i can think about possibly implementing something.
ttfn, JBoi
Can someone please tell us what we are missing to get the flv files in the directory to be found?
Here is part of my video.php file.
Thanks again,
Rick
//full path to dir with video.
$path = '/var/www/html/home2/video3/';
$seekat = $_GET["position"];
$filename = htmlspecialchars($_GET["file"]);
$ext=strrchr($filename, ".");
$file = $path . $filename;
I have installed the ISAPI Extension on IIS6 server and also uploaded the Golfers.FLV file
http://www.jasonwhite.co.uk/files/golfers.flv
to get the file at a seek point simply add the parameter "pos".. eg.
http://www.jasonwhite.co.uk/files/golfers.flv?pos=10000" target="_blank">http://www.jasonwhite.co.uk/files/golfers.flv?pos=...
Have a play and test it out in your movie. you will need to slightly modify the movie file source to accomodate this.
This is just a sample to test proof of concept. I think it is quite a bit faster than the php solution, which I dont really like as it feels like a hack.. (im being a snob) :P
ttfn, JBoi
Ok swell! Seems to work just fine. I'm really curious about this ISAPI extension, since I'm not such a win-guru myself.
Could you possibly send me a hint or a pice of code for this? Many thanx..
lars [AT] agent-e.nl
in your scrubber.fla player file you can replace the following lines -
var _vidName= "golfers.flv";
var _vidURL= "http://domain/" + _vidName;
var _phpURL= "http://domain/file.php";
with just one line -
var _vidURL= "http://www.jasonwhite.co.uk/files/golfers.flv"
Now replace the following lines -
ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
trace("play " + _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
with -
ns.play( _vidURL + "?pos=" + positions[i]);
trace("play " + _vidURL + "?pos=" + positions[i]);
That should just about do it :P
Hope that helps, ttfn, JBoi
Thanks for your interest in the ISAPI, i'm not sure I will release the source code to it though. Although I will more than likely release the Extension itself.
What bits are you curious about, maybe I can answer some questions:)
ttfn, JBoi
Thanks big time for posting up how to PHPstream. Like most people who end up posting comments, I am another one that cannot figure out to work the application using my own FLVs.
It works fine with the golfers.flv. Even without $path defined in php file. So i figure it would work with my other FLV files.
With golfers it lets me skip to any part.
With my own FLVs it (also) doesn't seek, the buffer clip continues flashing and nothing is played.
Please help?
Big thank you in advance.
yup i injected the meta data. I followed your video tutorial that you made on injecting with flvmdi.
what's really funny now is....the application work with 'golfers.flv'. now if i rename it to 'whatever.flv' it won't work. how? ich weiss nicht.
help please?
after some hard reviewing. everything turned out alright. I didnt have to define the $path. and everything seeking great. Thanks a lot.
ooookay. so second problem that I've noticed already came up is 'streaming' flvs of 40MB. Doesn't work. no flashing buffer clip. it does:
pause at last point and if you let go of scrubber continue pausing.
press scrubber again and continue playing video.
i changed the script to
print (fread($fh, 10000));
but its still not performing. the change does handle small vids. any advice?
I appreciate the help from before.
First of all; this streaming solution is great! It all works fine for me when I use it on my own webserver.
Now I'm taking this to another level; I want to implement this flashplayer into my own website which is made in CakePHP. I can still watch the video, but the scrubber doesn't work anymore with Cake. It seems that something is wrong with the redirections of the flvprovider.php . (I had the same issue when I forgot to change the $path variable the first time I used this file)
Is there someone else who uses cake?
Or any suggestions to solve this problem?
Thanks!
I've looked around quite a bit, some developers say they have a solution, uptill now I have found none that actually work..
Have you tried adding something like "r="+random(999) to your flv string (ex http://something.com/golfer.flv?r="+random(99...
Thanks
http://www.aeon.jp/biz/
A FLV loads a swf??
When you click at the buttons loads another flv...
Does anybody know??
$path = '/var/www/test/';
/var/www/test# ls -anhl
total 5.9M
drwxr-xr-x 2 0 0 1.0K Jun 1 10:42 .
drwxr-xr-x 3 33 33 1.0K Jun 1 10:40 ..
-rw-r--r-- 1 0 0 994 Jun 1 10:43 flvprovider.php
-rw-r--r-- 1 0 0 2.3M Nov 2 2005 golfers.flv
-rw-r--r-- 1 0 0 2.6M Nov 4 2005 phpstream.zip
-rw-r--r-- 1 0 0 1.1M Nov 3 2005 scrubber.fla
test:/var/www/test# flvtool2 -U golfers.flv
test:/var/www/test#
It is possible to prevent caching of flv files and playlist. Please check my website and comment whether the flv or playlist has cached...
http://www.medicoexams.com/videotest/video.html
Regards
can i scrub the flv on server using php, whitout sending get request from client swf?
thanks,
// chall3ng3r //
No probs. I will set it up for you..if you want, even without the files caching on users server. You may contact me at my e-mail id:
shelleytvm@yahoo.com
how can i with php set that it changes videos dynamicly?
file=nev.fvd
i don't understand this... it plays every vid i put in that var, but i don't know how to use player for multiple vids :)
Is there a way to make flvmdi output offsets of the key frames in the unmodified source?
I have injected the flvmidi and the player works great except for whe I scribe ahead in the video it buffers and then stats the video from the beginning whether I scribe ahead of backward. Can anyone assist me with this?
Thanks!
Note, it's 2.2 an later, source needs to be changed if you want to port it to 2.0 or earlier. Not so flexible as a PHP script, but should provide much better performance, as PHP interpreter is not loaded for every seek request.
FYI,
lazycat
Excellent work by the way.
/**
*
*/
package com.egm.ui.action;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class StreamingVideoController
{
private static final Log log = LogFactory
.getLog(StreamingVideoController.class);
private static final int HEADERLENGTH = 9;
public static void handleVideoStreaming(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
RandomAccessFile raf = null;
OutputStream outputStream = response.getOutputStream();
try
{
String positionStr = request.getParameter("position");
// Default 0 if not passed in
positionStr = positionStr == null ? "0" : positionStr.trim();
String fileName = request.getParameter("file").trim();
if (log.isDebugEnabled())
{
log.debug("positionStr/" + positionStr);
log.debug("fileName/" + fileName);
}
long position = Long.parseLong(positionStr);
response.setContentType("video/x-flv");
// For now use hardcoded path
raf = new RandomAccessFile(new File(
"/" + fileName), "r");
byte header[] = new byte[HEADERLENGTH];
raf.read(header);
if (position > 0)
{
outputStream.write(header);
}
raf.seek(position);
log.debug("Start to streaming the file");
byte[] data = new byte[32768];
int noOfBytes = raf.read(data);
while (noOfBytes != -1)
{
outputStream.write(data, 0, noOfBytes);
data = new byte[32768];
noOfBytes = raf.read(data);
outputStream.flush();
}
//
log.debug("File streaming done");
}
finally
{
try
{
outputStream.close();
}
catch (Exception e)
{
log.error("Failed to close the http response out stream", e);
}
if (raf != null)
{
raf.close();
}
}
}
}
outputStream.write(Base64.decode("RkxWAQEAAAAJAAAACQ=="));
You need to have a Base64 class which will decode the string to byte. See this link for example.
This is fantastic. Thanks for the excellent work.
:D
www.flashcomguru.com/downloads/scrubber.zip
Just to reiterate the problem, your flash player loads an FLV using a gateway file (AS2 ex: play('getfile.php?vid=golfers')) the HTML page becomes unresponsive until the FLV loads entirely.
I tried changing content-type headers, I tried everything... and the only "solution" seemed to be this:
AS2 code: play('getfile.flv?video=golfers');
Use an htaccess file to make "getfile.flv" point to "getfile.php"
The call to getfile.flv?video=golfers will locate your golfers.flv file and output it like this: $location = 'uploads/golfers.flv'
header('Content-type: video/x-flv');
header('Content-Disposition: inline; filename="'.uniqid('vid').'.flv'.'"');
header('Content-Length: ' . filesize($location));
header("Location: ".$location);
Just print headers to trick flash player. If you found another way to do this, then please share.
I'm using PHP code to "stream" a flv file, masking the absolute address...
It worked for me... on Firefox!
In IE6, the "header("Location: ".$location);" crashes. It doesn't show the video. Maybe IE misunderstands the correct path...
http://www.flashcomguru.com/index.cfm/2007/8/14/ph...
http://flashcomguru.com/downloads/phpstream_update...
God knows how long i been looking for the page.
http://www.kaourantin.net/2007/08/what-just-happen...
the scrubber and provider will now be updated for the new metadata structures (which are quite different from FLV) from the onMetaData seek points array
unfortunately, still no news about selective HTTP ranges and caching
"C:/phpstream/video/"
but i still show nothing on the scrub.html
Do i still need to change anything on the actionscript for the .fla file?But i know nothing on action script.
I appreciate if anyone can help.
I have a Servlet that returns the files. In your app I have to set a video-dir. Can I change the video dir to the Servlet-Url
could php streaming be used by the flex videoDisplay component? if so, does anyone have a sample?
http://www.syn-rg.com.au/Creative/yudy/synrg_motio...
I have a simple question for you, when i replace the video file, the bluffering wont work. (you will see it when u drag the slider),I made my video file setting as .VP6, any solution?
thanks
header("Content-Length: " . filesize("your FLV file here"));
$path = 'C:\Program Files\EasyPHP1-8\www\uploads\golfers.flv\';
but the next line I still get a Parse error line 21
if((file_exists($file)) && ($ext==".flv") && (strlen($filename)>2) && (!eregi(basename($_SERVER['PHP_SELF']), $filename)) && (ereg('^[^./][^/]*$', $filename)))
it should be nothing wrong, can someone help me, or do I have to make html page?
thnx in advance
$path = 'C:\Program Files\EasyPHP1-8\www\uploads\golfers.flv\';
but the next line I still get a Parse error line 21
if((file_exists($file)) && ($ext==".flv") && (strlen($filename)>2) && (!eregi(basename($_SERVER['PHP_SELF']), $filename)) && (ereg('^[^./][^/]*$', $filename)))
it should be nothing wrong, can someone help me, or do I have to make html page?
thnx in advance
I want to make small apllication of showing video.
can anyone give me detail instruction how to do this ? (or how to configure code.)
in appserv when I run the script, it ask me download the video.
in ubuntu 7.10, it just display the binary weired character instead of playing.
http://courierwebcasts.com/vidplayer/scrubber.zip
I would appreciate an e-mail if you decide to use it, just to be able to pat myself on the back ;) (Go to http://www.courierwebcasts.com and click the contact us link at the bottom of any page) or post to this thread and let me know.
Included in the zip file is:
1. The source .fla
2. The font used for the playtime/duration (it's digital readout, available from http://www.1001freefonts.com)
Just a note of caution, that I tell everybody to whom I give the source.
I have a bad habit of not (thoroughly) commenting my code, so if you have any questions, feel free to drop me a line.
There may be a better way to accomplish some of the functionality...Im no real Flash genius. Let me know if you find anything that could be done better.
I wonder though if you could explain a little more about passing a GET variable through to the vidName variable in the FLA? The page that I have the swf loaded on is receiving a variable ?vidName=hollow.flv and I wondering how do I tie the vidName variable in the FLA file to this? Thank you again for any help you might be able to give.
Since you're using this approach, I'll assume you have PHP installed on your server.
<?php
//first, assign the get variable from page to $file
$file = $_GET('vidName');
?>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://fpdownload.macromedia.com/pub/
shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
'width','365','height','310','align','middle','src'
,'/scrubber/scrubber?vidName=<?php echo($file)?>','quality','high','bgcolor','#ffffff'
,'wmode','transparent','allowscriptaccess','sameDomain'
,'pluginspage','http://www.macromedia.com/go/getflashplayer'
,'movie','/scrubber/scrubber?vidName=<?php echo($file)?>' ); //end AC code
</script><noscript><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/
cabs/flash/swflash.cab#version=7,0,0,0" width="365" height="310" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="/scrubber/scrubber.swf?vidName=<?php echo($file)?>" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent" />
<embed src="/scrubber/scrubber.swf?vidName=<?php echo($file)?>" quality="high" bgcolor="#ffffff" width="365" height="310" wmode="transparent" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object></noscript>
the variable is being passed properly to the page but the swf continues to just buffer - I am wondering how is the variable being passed to the flash file without flashvars? In the comments within the FLA it says
//Declare vidName here, if not passing through a GET variable (all vidName are commented out)
and then the var _vidURL is
var _vidURL = "http://my.videourl.com/mediaflv/" + vidName;
but where does it obtain vidName from?
Thanks Lance - I appreciate your help.
The swf gets the variable from when you place the swf on the page. (Note the src, movie params, and the embed tag, the ?vidName = part). You could test to see if it's correctly retrieving the vidName variable by putting a dynamic text box on the stage, name it my_txt, and then add my_txt.text = "vidName" in the actionscript. That won't show the variable when you test the movie in flash, but it should show up when you run it in a browser, with ?vidName= at the end of the page URL.
You may want to try to hard-code the vidName variable to make sure that everything is working OK. By doing that, you can test the movie in flash to see that the error doesn't lie somewhere else.
Hope that helps.
"It is possible to prevent caching of flv files and playlist. Please check my website and comment whether the flv or playlist has cached...
http://www.medicoexams.com/videotest/video.html"
I tried video playing from link above and found that caching is appears, but when i close IE flv content is removed from IE cache.
Just wonder how to do that, think it's swf feature, am i right ?
I think I need to do some looking behind the scenes to find out how the requests are being made (to the web server) from the browser.
Did I can help in creating a list XML to choose videos?
Regard Tommy
Just a note: if your flv is larger than the maximum php script size in php.ini NOTHING will happen: blank page, no entry in access_log for flvprovider.php, etc. The fix is to change:
print (fread($fh, filesize($file)));
to:
print(fread($fh, 1024*8)); <== set to less than the max script size in php.ini
flush();
Once you've done that, it should fly right along.
hth,
Christofle
I would like to know how to implement the xmoov with jw flv player, I realy like this player and it has a lot of futures but I am not a flash expert and need to a know how to do this.
Does any one have implemented this before? Does any one have an example code ?
Thank you for our huge contribution!!
Jonathan
I'm using a workaround but read my data from the url itself... Is there a way to actually pass http params to the server script?
bin ein ziemlicher neuling/ahnungsloser in sachen php.
we genau binde ich das video in meine index.php ein?! hat jemand da ne explizite vorlage ? und wie rufe ich das video online auf ?
ein tutorial auf deutsch f
Everything you need is right here on this page!!
Someone could help me ?
Thanks.
scrubber.fla und der videodatei an sich ben
I'm running into THE problem with the page links not working while the the flv is loading, which is frustrating, since the page links work fine on this site with the same player. I found that the links DO work in the PC Safari, but not with Firefox or IE.
I read most of the post looking for the solution for this and haven't found any other articles on the internet describing that problem. Seems like it works fine for most and fails for the others. I've almost come to the conclusion that its a server issue.
... some time passes ...
I found that links to the same domain fail, while links to other domains succeed. This must mean that the server is refusing to process a second request for the session until the current request for the flv file is finished. Note that any request to the same domain (my domain) are refused if the same session is associated. If I open up another browser and go to the domain while the first browser is downloading, then there isn't any problem.
I really like the script. Thank you.
The last post describes the page link problem while the video is downloading.
continued:
The server creates a session lock when a session is created. My purpose for the flv provider is to validate some session information, and then deliver the flv if that information is valid (logged in). After the session in validated, then the video is output via the provider. If the session is not written and closed (via session_write_close();) then the lock remains. If the page link tries to restart a session with the same ID, then that session must wait until the feed provider closes it.
Anyway...
If you open a session before you output the flv, then make sure you close it before outputting the video.
session_write_close();
mutex
semaphore
lock
block
link hangs
broken links
broken hyperlinks
I have developed a player using XMOOV.php.
Actually i didn't change the php.The player is able to seek to any position in the cached file and it can start caching anywhere from the file.I have uploaded it in my blog.
http://logicmania-lab.blogspot.com/2008/01/flash-f...
visit this link to download the files
please let me know your suggestions and comments.
Thanks again!
i need to as that i wanted to convert videos into flash for avi, and other video formats ...
how doi use this code...i have plaed it in my www folder then i also reated another html doc inwhich i created a file input text field and named it'file' as on next page it is file ... then i executed it and browsed a file that was video with wmv extension ..but nothing happened so i need to ask how should i embed this code in my file please help me out. thanx
Added milisecond position seek, and cache future.
http://www.guarana.cc/kent/streamSource.php?v=0.4
--
Two quick questions: First, does the current Flash Video Encoder insert the metadata that xmoov-php needs to operate or do I still need to use the FLVMDI to inject the required data?
--
Second, I am concerned about the ability of xmoov to scale up. The web site says The most important factor to know is the number of simultaneous PHP connections your web-server allows. Internet video publishers wanting to broadcast live streams or serve thousands of simultaneous connections must rely on streaming server systems such as Adobe's Flash Media Server.
--
Is this still the case? My hosting company says that their grid system can support any number of simultaneous PHP connections. Does this seem likely? If the site is a big success, and if we a thousand simultaneous connections, is the xmoov-php approach going to become a problem?
Thanks,
Art
http://d.hatena.ne.jp/kent013/20080224/1203827752
I have experienced a various delay while scrubbing past or before buffered time. This delay is from when the video plays and when Netstream.Buffer.Full is dispatched. Sometimes they are right on and other times the video plays .5 - 2 sec before Netsream.Buffer.Full is dispatched. You can even notice it using the player above. You will see the file play while the buffer text is still showing. Is there a more precise way to determine when a file actually starts playing.
Thanks
Can any body help me to know that
how will u find a video is streaming or not using PERL please......
I've been looking at different dns settings and htaccess rewriterules but nothing seems to cut the case.
Any suggestion on how I could make this setup work?
I am not able to get this working. I am using EasyPHP as my php server and edited the scrubber.fla to point to http://127.0.0.1/folder/movie.flv The move starts to play and when i seek to a different location, the URL gets generated ( lay http://127.0.0.1/phpstream/flvprovider.php?file=go...
However, Nothing happens in the video. It just pauses. Does anyone know wat i am doing wrong? Is it ok to use EasyPHP as the PHP server?
Thanks,
-Vinay
Any help would be greatly appreciated.
Thanks,
-Vinay
There are bugs when you set the autostart to false.
The seek bar just looks very weird when the autostart is false.
Is there a workaround for this? Aside from having many, many servers is there a way to use Xmoov when you want to serve many simultaneous connections?
"golfers.flv" it plays, but when the scrub is dragged to a different portion in the timeline, the video doesnt start from that point. Rather it continues to play from the start.
Is there any particular way of conversion for a streaming video
please give a solution.
thanks
I have tried this pseudo streaming method and it works very good.
Thank you for all how has contrubuted to implement or update this script.
steps that I performed to make it working:
1. download phpstream_update.zip
2. open the scrubber_flash8.fla (or scrubber.fla) and modify the action script:
//----- BEGIN ------
var ns:NetStream = new NetStream (nc);
var domain:String = "http://your_domain.com/folder_where_xmoov_php";
var bandwidth = "mid"; //low, mid or high
var _vidName:String = _level0.movname;//"golfers.flv";
var _vidURL:String = domain + "/" + _vidName;
var _phpURL:String = domain + "/xmoov.php" + "?file=" + _vidName + "&position=" + 0
// ---- END ----
Note that _vidName become "_level0.movname" that's the name of the .flv video.
3. Publisch the fla (create the swf player)
4. Embedd the player into a html file:
// --- BEGIN ------
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cab...=7,0,0,0" width="400" height="300" id="player" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="player.swf" />
<param name="FlashVars" value="movname=test.flv" />
<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />
<embed src="player.swf" FlashVars="movname=test.flv" quality="high" bgcolor="#ffffff" width="400" height="300" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
// ---- END -------
- you must change test.flv to the name of your flv-video (2 times).
- player.swf is the saved name after the publisch of the fla file (2 times).
5. last changes to make in the xmoov.php:
// points to server root
define('XMOOV_PATH_ROOT','/path_to_xmoov.php/');
// points to the folder containing the video files.
define('XMOOV_PATH_FILES','relative_path_to_flv_video/');
sorry for my englisch and good luck.
Is there a way to make the player switch to using the local copy once the video file has completed the download?
This would eliminate many server roundtrips if users jump around alot in the video, or hit rewind a several times.
For the how to
I have Flash Player 9.0.124 installed on my desktop system, also running XP SP2.
I took the code from the download at
http://www.flashcomguru.co.uk/index.cfm/2005/11/2/...
Modified it to point to the directory I keep my movies in on the Apache server and put a PHP/HTML wrapper around it as follows: streamflv.html
<?php ob_start(); ?>
<html>
<head>
<title>Kurtz Family Web Site - Test</title>
</head>
<?
/*/
security improved by by TRUI
www.trui.net
Originally posted at www.flashcomguru.com
//*/
//full path to dir with video.
$path = 'D:/apache/htdocs/movies/';
$seekat = $_GET["position"];
//$filename = htmlspecialchars($_GET["file"]);
$filename = 'golfers.flv';
$ext=strrchr($filename, ".");
$file = $path . $filename;
if((file_exists($file)) && ($ext==".flv") && (strlen($filename)>2) && (!eregi(basename($_SERVER['PHP_SELF']), $filename)) && (ereg('^[^./][^/]*$', $filename)))
{
header("Content-Type: video/x-flv");
if($seekat != 0) {
print("FLV");
print(pack('C', 1 ));
print(pack('C', 1 ));
print(pack('N', 9 ));
print(pack('N', 9 ));
}
$fh = fopen($file, "rb");
fseek($fh, $seekat);
while (!feof($fh)) {
print (fread($fh, filesize($file)));
}
fclose($fh);
}
else
{
print("ERORR: The file does not exist"); }
?>
</body>
</html>
When I launch streamflv.html, I am asked if I want to open this with the default application, which for me is SeaMonkey. Then the borwser (SeaMonkey) displays the raw data rather than Flash player being invoked. I'm sure I'm missing some very basic concept here, like having to define an object for the movie, but all indications I got from reading posts here did not seem to indicate that was necessary.
Does anyone have an example of what the HTML should look like?
don't even think of adding an html wrapper!
the flvprovider file must not even output a single spurious character!
the flvprovider must start with '<?' and end with '?>' and must not employ output buffering at any time.
If you want an html page to present the video, you must create one which embeds the flash scrubber swf (which in turn will access binary data net-piped from flvprovider).
The flvprovider php should not be modified if you dont't know what it actually does (it's a binary provider, not a text/html provider !!)
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
<param name="movie" value="myContent.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="myContent.flv" width="780" height="420">
<!--<![endif]-->
<p>Alternative content</p>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
and perhaps an onClick event that invokes flvprovider.php. True, false or not even in the park?
I have it streaming to an external FLV viewer but I can't make it work inside the browser.
could you please post a URL to examine ?
Posted At : November 2, 2005 3:06 PM | Posted By : Stefan Richter | Related Categories: Applications
Following a really interesting thread on the chattyfig Flashcomm list I have now been able to put together a simple video player which is capable of requesting and playing parts of a flv video file that have not previously been downloaded.
This is a neat feature because it is usually only possible to play and seek to a part of a video that has already been downloaded unless you deploy a streaming media server.
Here's the working example. You need Player 8 for this but that's only because I encoded the video using VP6. The rest is compatible with Player 7.
I have uploaded my progress and included all sources.
It should be noted that due to the support of Buraks it was much easier to implement this idea. A new version of flvmdi injects an object containg two arrays into the flv's metadata. It contains the exact starting position in bytes and timecode of each keyframe. Using this information we can request any part of the flv file starting at a specified keyframe. Check this post for more info on flvmdi - the injection is NEEDED if you want the PHP seeking to work.
Thanks to everyone on the chattyfig list who contributed to this and also to Brian Bailey for blogging about his efforts. Thanks also to Lee Brimelow whose scrubber I have used and modified for this app.
*** UPDATE ***
I have made some small changes now:
- the 'buffering' no longer appears once the video has ended. This was done by simply introducing a new variable 'ending' and checking for a NetStream.Buffer.Flush message.
- loading bar shows the download progress again, although this is not that important as you can seek beyond that point anyway :-). But it will be good to further extend the app so that it will not request the file via PHP once it has loaded completely. We could seek normally once download is complete.
- source files have been updated
- another update (09/2007): updated sources by xmoov.com are now available at http://flashcomguru.com/downloads/phpstream_update...
UPDATE: Steve Savage has now ported this to Coldfusion: http://www.realitystorm.com/experiments/flash/stre...
Creative Commons License
This work is licensed under a Creative Commons Attribution 2.0 England & Wales License.
[Comments] Comments ( 426 ) | [Email This] Email This | [del.ico.us] del.icio.us | 289361 Views
Related Articles
* How to Stream H.264 Flash Video *Today* (December 18, 2007)
* Flash Video Streaming via PHP - Optimized by xmoov.com (August 14, 2007)
* Let it stream - with PHP (March 2, 2007)
Comments
[Add Comment]
Great stuff! I would add some logic so that if the video is already available it will load from the current stream and not start another to minimize server access. That being said this could definitely be very useful while waiting on Red5!
# Posted By Patrick Mineault | 11/2/05 4:03 PM
ah yes good point.
I am very excited about Red5. What I like about this approach is its easy implementation. A webserver and PHP - it doesn't get much easier than that.
# Posted By stoem | 11/2/05 4:12 PM
Cool thanks for putting this together. This could save some folks some serious $ on streaming fees... ;)
Also I noticed that the video doesn't really end well...gets to the end and flashes Buffing Video. Perhaps some simple check to autoRewind or something.
Thanks again!
# Posted By sean moran | 11/2/05 4:45 PM
Awesome! Now all I need is flvmdi for OS X and I'd be all set. Thanks so much for putting this together. This could be *huge* considering how many people there are out there with PHP on their boxes.
# Posted By Todd Dominey | 11/2/05 9:41 PM
Once again I applaud... good job man!
# Posted By Jake Hilton | 11/2/05 9:59 PM
Will you marry me? *kiddin* You are a GodSend! Thank you so much. Love your site. This will help ease my anxiety while waiting for Red5.
# Posted By C. Jason Wilson | 11/3/05 4:14 AM
Hi stefan,
I had checked your php file. You are reading whole flv file at a time, i think this will become then progressive download. You need to read file from the seek point. I will suggest you to improve your coding in php to read from any given location by clicking on progress bar while playing flv.
# Posted By Ritesh Jariwala | 11/3/05 4:52 AM
Ahh, just checked it you got seek point position too fine.
# Posted By Ritesh Jariwala | 11/3/05 4:56 AM
guys you are making me blush. I don't feel like I deserve credit - I don't know any PHP code, I just modified what was posted.
Glad to hear it's useful to you though. Make sure to email me if you improve it. I think Patrick Mineault's suggestion is a good one, once the file has been downloaded completely we should use the cached version and not request the file again.
# Posted By stoem | 11/3/05 9:20 AM
Trying on Safari I see that every time you scroll the playing position, the browser interprets the new call to php as an error.
Also, I think is not possible to replay the video from cache if you skip some part of the video, as the stream changes everytime you change the play position you get only the remaining part and not the full video, is this right?
anyway, good stuff, keep it going ;)
# Posted By freddy | 11/3/05 5:33 PM
Hi,
I tried to use this method with a huge video (68Mo, 40mn) and the player is freezing when i try to seek.
Do you think it comes from PHP script or actionscript ?
Anyway, very good job, i really like it and would like to enhance the player .
# Posted By Kimmy | 11/3/05 9:59 PM
Hi,
I think for a huge video, the search in the actionscript could get a big performance improvement by using binary search.
Best regards,
Burak
www.asvguy.com
# Posted By Burak KALAYCI | 11/4/05 12:13 AM
Hi kimmy,
Post the link of big flv somewhere, i like to test.
# Posted By Ritesh Jariwala | 11/4/05 4:12 AM
Hi everybody,
I think the problem do not come from actionscript as it freezes when i try to seek to the begining of the movie.
The actionscript routine should retrieve the number of the keyframe very quickly in this case so probably it comes from PHP.
I got another question, what should happen if a user try to play a file bigger than the space defined for Temporary Internet Files. Would it crash ?
And one more question : i can't understand why the movie will be downloaded even if you seek to the end of the movie at the begining.
# Posted By Kimmy | 11/4/05 11:37 AM
Sorry i got another question :
Why classic players are not able to read a FLV with keyframe location metadata injected in it ?
Regards
# Posted By Kimmy | 11/4/05 11:42 AM
Kimmy question 1: I don't think your temporary internet files play any role here. If the file is too big to be cached then it probably won't be cached.
I would also assume that the 'slowness' may come from PHP but I do not know.
Question 2: What do you mean by 'classic players'? The keyframe info can be read by any player which 'listens' for the 2 new arrays. However only flvs injected with flvmdi27b will hold this info.
# Posted By stoem | 11/4/05 11:46 AM
Here is the link for huge FLV file :
http://www.rich-media-design.com/test/scrubber.htm...
Concerning classic players, i understand that keyframe info can be read by player asking for this metadata. But what i mean is that with 'classic players' (not yours) i can read a FLV file without keyframe info metadata but not FLV file containing these metadata.
Strange as other players do not process such metadata so it should not create an issue.
Regards
# Posted By Kimmy | 11/4/05 1:45 PM
Hi,
i've tried ... everything works fine,
but I actually dont know how to use Buraks FLVMDI. I dont which metadata should I add to my FLVs.
With golfers.flv everything goes great. With my FLVs it doesnt SEEK.
Please tell me where is the problem
Thanks
Tom
# Posted By Tom Krcha | 11/4/05 4:39 PM
Tom,
I'll post an article shortly that shows you how it's done.
# Posted By stoem | 11/4/05 4:53 PM
thanks!
Kind regards
tom.krcha.com
# Posted By Tom Krcha | 11/4/05 4:55 PM
new blog post added, see homepage
# Posted By stoem | 11/4/05 5:30 PM
There's a problem in the PHP portion of the script, the lines:
while (!feof($fh))
{
print (fread($fh, filesize($file)));
}
..are causing the problem. When you fread($handle, $buffer_size), the interpreter allocates $buffer_size bytes for reading. This causes a problem with large files or, to be more specific, files larger than the memory available to the PHP script. Changing the above to this:
while (!feof($fh))
{
print (fread($fh, 10000));
}
Fixes the problem. You can use a much larger buffer (up to little less than your script memomry limit), but please do some performance testing first.
# Posted By Michal Tatarynowicz | 11/17/05 9:11 AM
thanks Michael,
your comments and fix is much appreciated. However I never claimed that this script is anywhere near production ready, it's merely a proof of concept. In fact I don't even know PHP very well so keep that in mind. Anything posted on my site is meant to be for demo purposes only.
Again, thank you very much for your comments.
# Posted By stoem | 11/19/05 1:10 PM
i try. but not working in file 15mb. flash not send post.
# Posted By mario | 11/21/05 1:00 PM
Hi,
Thanks to Michal's new PHP script, we were able to play a huge video using PHP streaming method
(about 90Mo / 40 Min).
Performance seem to be ok when several users try to get the video.
We are looking for a PHP expert that could enhance the script in order to increase performance.
Here is the sample (Flash Player 8 is needed as we used On2 VP6 codec) :
http://www.rich-media-project.com/test4/cool.html
# Posted By Kimmy | 11/22/05 9:40 AM
I am updating the downloadable files to reflect the changes proposed by Michal. Thanks!
# Posted By stoem | 11/22/05 11:36 AM
Hi threre!
I'm not an expert in PHP, so. I came here to ask about the path. I'd like to make this video works through the internet. How should I set this path: 'C:/.../clips/'
I tryied 'http://www.myurl.com/videos/' and I put my flv into the folder videos, but is not working.
I'll appreciate your help,
Thanks
Fabio
# Posted By Fabio | 11/30/05 4:25 AM
Fabio,
that path is a local webserver filepath, it cannot be substituted by a URL. It will only work if you have access to a webserver running PHP.
# Posted By stoem | 11/30/05 9:13 AM
ThanKs Stoem
It's working now!
Do you know where can I find a FLA sample with a component lists with xml to apply to this?
Best,
F
# Posted By Fabio | 11/30/05 8:23 PM
Stoem,
What should be wrong with my playear, when I drag the button on the progress bar the video doesn't go to the frame and the buffering message start blinking without stopping.
Thanks for your help,
Fabio
# Posted By Fabio | 11/30/05 10:22 PM
Am trying to build this seek-> call php functionality into the FLVPlayback component. Have hit a hurdle when trying to overload seek. Anyone have any ideas how to go about this?
# Posted By Rob Sandie | 12/2/05 7:06 PM
This is exactly what I need... But I need it for .NET. Has anyone converted the script to ASP.NET or Classic ASP?
# Posted By David | 12/8/05 8:22 PM
not that I know of.. I wish someone did though!
# Posted By stoem | 12/8/05 8:57 PM
When I try to open scrubber.fla in flash MX 2004
it says unexpectet file format. Is the zip file corruptet or ?
# Posted By Klaus | 12/16/05 6:38 PM
you may need Flash8 to open it
# Posted By stoem | 12/17/05 9:54 AM
Really good article !
I'm on a big scholar project with it but i try to find a way to use it with flvplayback (or netstream but i don't know how to inject cue point to the flv correctly, and dynamically) ... because of netstream doesn't support cuepoint adding ! ThX
Sorry for my english ...
# Posted By Alexandre | 12/17/05 7:54 PM
Hello everyone,
This is a real good one. I am trying to use the Media Server only for realtime streams for a project of mine so this could help. What could be some problems using this in a project with a lot of users? Has anyone tried? Thanks a lot.
# Posted By Can | 1/3/06 12:09 AM
Sorry, one more thing. Does this work with FLVTool2? a similar tool for adding metadata for flvs? could it?
# Posted By Can | 1/3/06 12:37 AM
We haven't tested this with a lot of users and big files so I am unable to comment.
I do not know FLVTool2 but I would imagine that it will not offer the functionality of flvmdi (which is needed to make this PHP solution work).
# Posted By stoem | 1/3/06 8:38 AM
"I do not know FLVTool2 but I would imagine that it will not offer the functionality of flvmdi (which is needed to make this PHP solution work)."
For everyone's information: FLVTool2 is the first tool that implement this feature. FLVMDI followed a day after since I've explained Nicolas (from FLVMDI) how this really cool feature works. He's as soon implement it in his version for others benefit of.
just my two cents on history.
Cheers!
# Posted By Fredz./ | 1/7/06 5:47 PM
Hi everybody,
Have you seen Rich Media Project amazing PHP player at :
http://www.rich-media-project.com/test4/cool3.html...
I have written a mail to this french company and they told me that PHP streaming components will be available soon.
Have someone heard about other products ?
David
# Posted By David | 1/7/06 6:15 PM
Technically they are either using the same technique as described in this blog entry. At best, they are also controlling the bandwidth rate at which the FLV is returned by the PHP page with the idea to not make the user waste the server's bandwidth.
Other than this, I think the link you posted looks like a great example of the usage of this PHP seeking technique that has been elaborated and enhanced by multiple peoples.
# Posted By Fredz./ | 1/7/06 6:25 PM
Hi Fredz,
"For everyone's information: FLVTool2 is the first tool that implement this feature."
I don't really care which tool implemented it first. For the record: Stefan Richter (Flashcomguru), asked about this to us on October 25, 2005. We releassed a beta version of FLVMDI with this feature on November 2, 2005.
I think "the idea" was important here; if it had occured to us, we would have implemented this years ago.
So thanks again Frederic and Stefan.
Best regards,
Burak
# Posted By Burak KALAYCI | 1/7/06 6:52 PM
Hey Burak,
Sorry I did a mistake, your right Burak.
"FLVTool2 is the first tool that implement this feature. FLVMDI followed a day after since I've explained Nicolas (from FLVMDI) how this really cool feature works."
Should be changed to:
FLVMDI is the first tool that implement this feature. FLVTool2 followed a day after since I've explained Nicolas (from FLVTool2) how this really cool feature works.
:)
Cheers
# Posted By Fredz./ | 1/7/06 7:29 PM
* Norman Timmler (of FLVTool2). Not Nicolas, gee I must be tired.
# Posted By Fredz./ | 1/7/06 8:18 PM
I'm wondering if this method can be used with the FLVPlayback component in flash 8. Could someone make an example fla file if it's possible? If it's not possible could you let me know why?
Thanks
# Posted By Seth | 1/9/06 7:34 PM
possible technically yes but too much work. It's much easier to roll your own player which supports the additional functionalities that are needed for the PHP way.
# Posted By stoem | 1/9/06 8:50 PM
Hi ! Just a question ? What was your VP6 parameters ?
VP6 allow to put keyframes every x frames/s but object keyframe doesn't work ... so using flvmdi !
For me after using flvmdi, I have too much keyframes (double or more) but i have de keyframe object, cool ... but don't really works on the player ...
I just want your settings when you encode video in VP6 ... which is the best codec for flv (i can't return to sorenson) ...
THX and sorry for my english !
# Posted By Alexandre | 1/17/06 11:13 PM
Alexandre,
As far as we are aware there's no bug with FLVMDI.
If you think any problem is related to FLVMDI, or, have a suggestion how we can improve it, please let me know (burakk at buraks.com).
Thanks,
Best regards,
Burak
# Posted By Burak KALAYCI | 1/18/06 2:06 PM
Burak --> I never say that ! FLVMDI is a very good and useful tool !
So, I think about something : it should be so good to delete all keyframes from a flv movie and to put keyframes with personnal interval (10 frames / s or 1 kframe / s ... for example) with FLVMDI ! We already can ? say me how ! :D
I just wanted to know how encode with on2 vp6 for flv streaming with php ... thanks.
Alexandre
# Posted By Alexandre | 1/18/06 4:33 PM
It took me a while to get this to work. I saw the 2 variables that needed changing in the fla file. I didn't realize there was a variable in the php file that you had to change. Then I didn't realize you have to use the flvmdi.exe on your flv file. -- so maybe a readme file that comes with the downloaded zip file stating what all needs to be changed would be nice for people.
But otherwise I seem to have it working. Thanks a bunch!
# Posted By Terry | 1/20/06 5:30 PM
Oh yeah,... I'd like to know if its possible to stop the full download of the video and just use these tools/scripts pretty much a streaming server. (There is a gray bar that indicates the cached download status of the full file).
In other words, I want to use this to stream my video, but when I take the video off the server, I don't want people to still be able to see the video from their cache (In other words copyright protecting it). Is this possible?
# Posted By Terry | 1/20/06 5:36 PM
If anyone wants it, I rewrote the while loop in the php file to rectrict output. Its not true streaming, but does limit the bytes per amount of time. It may not also be the greatest code. I'm not a great programmer.
I needed this, as I have a 30MB file to stream. And each time the user changes position (the way the php file originally works), the rest of the file from the scrub point gets re-downloaded. So if a user is in the first few seconds of watching and waits until the whole video downloads (all 30MB), and then the user scrubs back to the say the third second from the beginning, almost the whole 30MB will be downloaded again at the users FULL connection speed. I don't want to waste that much bandwidth.
The code below is limited to 30k/2sec or 15k/sec. Using 30k/sec is more of an average than 15k/sec as the limit is over 2 seconds instead of one, giving the download more of a chance to allow bursts to get the player the amount of file it needs to continue playing while the bandwidth limiting sleep is happening.
Hope this posts readable!
//set below to be your bandwidth
$bytes_per_timeframe = 30000;
$time_frame = 2;
while (!feof($fh)) {
// get start time
list($usec, $sec) = explode(" ", microtime());
$time_start = ((float)$usec + (float)$sec);
print (fread($fh, $bytes_per_timeframe));
// get end time
list($usec, $sec) = explode(" ", microtime());
$time_stop = ((float)$usec + (float)$sec);
// Sleep if output is slower than bytes per timeframe
$time_difference = $time_stop - $time_start;
if ($time_difference < (float)$time_frame) {
usleep((float)$time_frame*1000000 - (float)$time_difference*1000000);
}
}
# Posted By terry | 1/25/06 7:53 PM
my above comment does not know the true streaming rate of the video being loaded. It would be good if someone could write a function for the php file that gets the metadata info from the video file. (I'm not a good enough programmer to do that).
Also, my bandwidth limit above of 15k/sec is pretty low. Obviously you can change it to 100k/s for videos that need more bandwidth.
# Posted By terry | 1/25/06 7:57 PM
thanks for posting this. A better approach may be to move this logic to the client. Once the entire flv is cached the player switches to 'normal' mode instead of the PHP request. I'll try and add that sometime.
Thanks again.
# Posted By stoem | 1/25/06 8:10 PM
actually... my goal is not to allow the user to cache the file. I want to stream the file and not allow the user to keep watching it after I remove it from the server (for copyright protection purposes).
# Posted By terry | 1/26/06 1:18 AM
Kudos! As I search in google, I can only see this being done in PHP. Would you have any idea of doing it using C modules in the apache server? I seem to be having problems with the player recognizing from the partial .flv file inspite of adding the header: 4c46 0156 0001 0000 0009 00003 in hex followed by the actual data from the flv file starting from the requested offset.
Would be glad of any pointers and suggestions&
Thanks
# Posted By Sha | 1/27/06 1:24 AM
Having this embeded as a Apache module would really rock!
# Posted By fredz | 1/27/06 2:34 AM
Wouldn't it be possible to "stream" large files (e.d. 40mb+) with this trick?
Without loading the complete file into the player !?
Like that the php file sends chunks of the file to the player, and the player stats playing directly without having the complete 40mb loaded.
anyone ideas on this?
I tried some things with the code 'terry' posted above at 1/25/06 7:53.
But the video doesn't start directly, it starts when the complete 40mb file is loaded.
# Posted By Jeroen | 1/27/06 2:58 PM
Jeroen,
that is exactly what this script is supposed to do: making it possible to seek to a point in time that hasn't yet been downloaded. As you can see from the demo on the page this works well.
# Posted By stoem | 1/27/06 3:02 PM
Strange.
When I test it with a 40mb .flv file I have here, it doesn't start playing at all.
It does nothing.
# Posted By Jeroen | 1/27/06 3:14 PM
Hi everybody,
Concerning switching between local and PHP mode i found a working solution (still beta testing) but it is not really interesting with giant movies.
The main point is to be able to kill the php file in Temporary Internet Files folder.
Anyone has an idea on how we can make this :
From Flash ?
In the PHP script ?
# Posted By kimmy | 1/27/06 3:21 PM
Why are you so concerned about caching? Do you want to emulate some kind of DRM?
Still will always be flawed. We may be able to discourage local caching but at the end of the day the file you are playing is available online and for that reason it can be downloaded.
Have you experimented with the headers, trying to get the browser to expire the file right away?
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
Will that make any difference?
# Posted By stoem | 1/27/06 4:08 PM
Yeah. I tried headers, meta tags, all kinds of stuff. Sometimes the browser just won't reload the page.
I realize that its not going to be 100 percent. I just need to weed out the vast majority from being able to easily watch the file again, especially if their browser is too lazy to check for a new version.
However, I moved the name of the file into the php script and set the file name with an identifier from the swf file. So the URL won't contain the flv file name. In other words the url will be www.mysite.com/stream/flvprovider?name=clip1&position=2345. In the php file, clip1 equates to the flv file I want to play.
I also replaced the line in restartIt()
from...
ns.play( _vidURL );
to...
trace("play " + _phpURL + "?file=" + _vidName + "&position=" + 0;
the _vidURL is then no longer used, so I also removed the variable. (jeroen -- do this and I think your problem will be solved because now the file always comes form the php and is constantly regulated)
Since the php file streams the flv file from the backend, the actual flv file name is never seen by the viewer or their machine. If the person is smart enough to download the flv file by just entering the correct url parameters on the php file (www.mysite.com/stream/flvprovider?name=clip1&position=0), then they will be able to get the file as a download. However, they will have to save the file as an flv file and then create an swf file to play the flv file (or find an flv player). This all takes some intelligence, which weeds out a vast majority (80%) of the internet viewers.
# Posted By terry | 1/28/06 4:11 PM
also... as the player currently stands, if you scroll all the way to the end, you still get the "buffering". I solved this by getting rid if the "ending" variable, and put the following function in the videoStatus() function:
if (ns.time >= ns.duration - 3){
bufferClip._visible = false;
}
# Posted By terry | 1/28/06 4:15 PM
by the way... i'm concerned about cacheing so much because I want to sell "tickets" to viewings of my video. I don't have a lot of money and I don't want to pay for streaming servers or services at this point. So this script, as I have modified it to work, is a free pseudo-streaming server!
(Thanks to flashcomguru for posting his original code, or I would not be able to do this. I am hugely appreciative as it got me started.)
# Posted By terry | 1/28/06 4:21 PM
thanks Terry.
Would you mind sending me your updated code? stefan AT flashcomguru.com
I'd like to check it out and give it a test run. I think other people will also find it very useful. A cheap (if not totally reliable) way to achieve some DRM with flv files. Great stuff.
# Posted By stoem | 1/28/06 4:48 PM
I've also removed the _vidURL from the player. And modified some small things.
And i've moved the .flv file location outside the http docroot, so they're not accessible directly.
Also i've used terry's code earlyer with $bytes_per_timeframe = 256000;
The working demo i've setup now:
An flashvideo behind an pay per minute phone number.
If the viewer(caller) hangs up the phone, the flvprovider stop's sending blocks of the flv video, and the player stops playing after the current buffer ( 256000b) is empty.
It looks like it's working correctly now, and the viewer can't even watch the part he've already seen after hanging up the phone.
I'm going to clean up the code a bit tomorrow, it's kinda messy now ;)
# Posted By Jeroen | 1/28/06 8:42 PM
Jeroen,
please post your files so we can keep track of the modifications and additions that everyone adds to this.
Thanks!
# Posted By stoem | 1/29/06 11:50 AM
stefan -- i sent you my code.
also, i realized my post above with the line:
trace("play " + _phpURL + "?file=" + _vidName + "&position=" + 0;
should have been (I copied the trace instead of the line that actually does the work - but the idea is the same)
ns.play( _phpURL + "?file=" + _vidName + "&position=" + 0);
# Posted By terry | 1/30/06 12:35 AM
I have one flv recorded with fms and i want to play after that with php streaming solution but .... when I drag the button on the progress bar the video doesn't go to the frame and the buffering message start blinking without stopping. I use flvmdi to inject metadata on flv and i am able to read this data so metadata is corect ... Please tell me, what is wrong with my code ?
# Posted By demiurgu | 1/30/06 12:43 PM
make sure you use the latest version of flvmdi and use the /k switch
# Posted By stoem | 1/30/06 1:49 PM
i am using the latest version of flvmdi(2.70 flvmdi.exe size=241.664) and i am using the /k switch :( ...
# Posted By demiurgu | 1/30/06 2:15 PM
Hey Jeroen,
You seem to be on the same page with me...
I just realized that we can make the player even better by including whether or not the buffer is full in the variables that are sent to the php file.
In other words, we can check the current buffer time:
_bufferFull = 1;
if(ns.bufferLength<ns.bufferTime){
_bufferFull = 0; // False
}
then add it to the call to the php file:
my_ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i] + "&bufferFull=" + _bufferFull);
The php file then has the the ability (with a check of the incoming _bufferFull variable)to remove or increase the bandidth limit until the buffer is full!! Thus, increasing the amount of feedback and making the performance for the user better.
# Posted By terry | 1/30/06 4:59 PM
demiurgu -- did you set/change the $path variable correctly in your flvprivider.php file?
# Posted By terry | 1/30/06 5:03 PM
Hi,
this is the dreamsolution for my videosite!
But (I think) I'm in the same path-trouble as demiurgu:
"when I drag the button on the progress bar the video doesn't go to the frame and the buffering message start blinking without stopping. I use flvmdi to inject metadata on flv and i am able to read this data so metadata is corect"
What are the right $path?
Please, give me a hint. ;) thx!
# Posted By rex | 1/30/06 7:35 PM
Can someone please show a file path example for a linux box. I am having the same buffer issue as demiguru.
# Posted By YG | 1/30/06 7:35 PM
rex & demiguru -- the $path variable in your php file needs to be the path to the flv file.
For Linux, if you have access to the command line, navigate to the directory where your flv file is stored and type "pwd" (present working directory).
That comand will show your current path, which is the path to your flv file because you are in the flv folder. Set the $path variable to that output. (should be something similar in form to: /home/users/www/flv/ -- make sure you include the training slash if its not there)
# Posted By terry | 1/31/06 4:13 AM
yes i did ... i set $path in flvprovider. some time is working with golfers.flv sometimes is not working. With my flv never worked. The path is same for both. I am using IIS on win2003 server. Is there some problem with this ?
# Posted By demiurgu | 1/31/06 8:03 AM
@demiurgu:
I had some problems when I first tried the script with my own .flv file.
The reason why it didn't play the file was because apache/php didn't had the rights to access the file.
( I forgot to chmod the file )
@terry:
Indeed we're on the right page. I didn't had time the last 3 days to work on the code. So I've no progress on new things.
I won't have any time next week to work on it.( wintersports )
So I'll pick it up again after 12 Feb.
# Posted By Jeroen | 1/31/06 9:59 AM
thank you terry! I found the rigth path to my webspace on the site of my webhoster...
The next problem was the memorylimit of my php-host (16MB),
because my FLVs are 290 to 450 MB! (each)
The example golfers.flv run and seek correct - but my FLVs run only once and don't seek a later position.
The hint from Michal Tatarynowicz are the solution:
>>> print (fread($fh, filesize($file)));
to
>>> print (fread($fh, 10000));
@demiurgu
some time its run, somtimes not? Eventually it is the filesize (or a late seekposition) of your flv. Test the hint from Michal.
Thanks!
# Posted By rex | 1/31/06 12:20 PM
I have big files too (around 300 MB) and the solution posted above works ... I really thought about PHP memory file size limitation (often 16 MB) but without finding a solution (i'm idiot) ! Cool ...
But there is one thing : why choose 10000 instead of filesize ? it's in bits, if memory limit is 16MB, why not choose 16000000 (or a bit less) ? ;)
# Posted By Alexandre | 1/31/06 2:16 PM
10000 its not a 'golden rule' nor 'the correct answer'. But it works on my (and Michal's) system. ;)
You can theoretically use 16384. But the script also runs it self in the memory. A better value: 15360? (sorry for my very bad english!)
Btw. - its a integer (byte) and 1 MB == 1024 Byte...
# Posted By rex | 1/31/06 3:32 PM
Thank you for the file name stuff...
I am trying to implement the xml loader, the thumbnail previewer and the progressive functionality all in one.
(See the thumbnail preview and xml stuff on this site)
Here's what happens:
All five videos play when selected in the list (simple with the tutorial). I placed the srubit function inside the event listener.
Here is what happens:
1) All videos load and play the first time
2) Can scrub the first video
3) Cannot scrub any other video.
4) Scrubber resides on the same location as the first video WHY???
Do I need to reset some values. Is my code completely ridiculuos.
(I hope to port the xml from Php and be able to have it all dynamic...)
Here is a code snippet.
Sorry about the formatting...
//Tell Function to do stuff when a user selects an item
listListener.change = function( evtobj ){
// close any current stream
ns.close();
video.clear();
//create a new stream
ns = new NetStream(nc);
//"attach" (pipe) stream to this video object
video.attachVideo(ns);
//Build FLV file name
var flvfile = evtobj.target.selectedItem.data + ".flv";
var _phpURL ="http://www.name.com/Example12/flvprovider.php";
var ending = false;
var amountLoaded:Number;
var duration:Number = 0;
var loaderwidth = loader.loadbar._width;
loader.loadbar._width = 0;
//ATTEMPT TO RESET X VALUE TO RESET SCRUBBER
loader.scrub._x = 0;
// play selected flv
ns.play(flvfile);
//PULL METADATE FROM INJECTED ARRAY FROM FLVMDI
ns["onMetaData"] = function(obj) {
duration = obj.duration;
// suck out the times and filepositions array, this was added by flvmdi
times = obj.keyframes.times;
positions = obj.keyframes.filepositions;
}
//END OF METADATA FUNCTION
//SCRUBBING FEATURE CALLED WHEN USER MOVES SCRUBBER
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * loaderwidth;
loader.scrub._x = ns.time / duration * loaderwidth;
}
loader.scrub.onPress = function() {
clearInterval (statusID );
ns.pause();
this.startDrag(false,0,this._y,loaderwidth,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
scrubit();
this.stopDrag();
}
function scrubit() {
var tofind = Math.floor((loader.scrub._x/loaderwidth)*duration);
if (tofind <= 0 ) {
restartIt();
return;
}
for (var i:Number=0; i < times.length; i++){
var j = i + 1;
if( (times[i] <= tofind) && (times[j] >= tofind ) ){
trace("match at " + times[i] + " and " + positions[i]);
bufferClip._visible = true;
ns.play( _phpURL + "?file=" + flvfile + "&position=" + positions[i]);
trace("play " + _phpURL + "?file=" + flvfile + "&position=" + positions[i]);
break;
}
}
}
//END OF SCRUBBING FEATURE
}
# Posted By YG | 2/1/06 10:18 PM
YG -
It looks like when you change files, you play the file from the start, so I would expect the headers to get through.
Does everything work if you remove the scubbing? In other words can you change files and have each of them them start and play all the way through from the beginning of the video after changing videos?
One thing I might try (again I'm not a great programmer):
Destroy (or empty) the duration, times, and positions variables before putting the meta data of the new file in them (I'm not sure how the assignment works works, but maybe the new file information just overwrites as much of the arrays as there is information, leaveing any extra length on the array unchanged?)
# Posted By terry | 2/2/06 2:22 PM
Thanks for all your help. I debugged it... I realized I had left a setInterval method out of the scope of the function and it kept calling itself. Bad news for the other videos in the xml list. There are still some more bugs that need to be fine tuned but at least it functions...
# Posted By YG | 2/3/06 10:36 PM
YG - when you get your code working can you send it to me at: streamingflvcom AT dedicatedmanagers.com
(replace the AT with an @ and remove the spaces)
# Posted By Terry | 2/4/06 6:58 AM
The "buffering" thing I talk about above is silly. It wouldn't work. I realized when I tried to code it, that the swf file only sends information to the streamprovider.php once, so it doesn't have that type of feedback to tell the php file its continual current buffering status. The swf would just send the fact that the buffer is empty when it tries to reload each stream.
I would think for it to work, it would have to be implemented by a second call from within the swf file to another php file (the way you might load an xml file, or maby through another hidden NetStream?) that somehow communicates with the streamprovider.php (maybe it sets a flag in a file that the streamprovider.php opens and checks every few seconds? or maybe php files can somehow share variables and the swf just periodically calls another php file that injects the variable into the streamprovider.php? ) -- don't now if that makes sense, but if possible, coding it would be a little beyond me.
# Posted By terry | 2/8/06 4:32 PM
I have a new problem :(( i recorded an flv stream with fms. I replayed it and get some metaData information wich contained duration value. I appended some voice at stream with fms too, but the duration property was not changed. Is there some issue on fms? Is somebody who know that?..
Sorry for my spell.
# Posted By demiurgu | 2/10/06 2:07 PM
Can this be altered to work with subdirectories, or would it just be a simple case of passing in a url var that had the directory name, or a reference, in?
# Posted By Ian Winter | 2/13/06 1:47 PM
yeah, this can very easily work with subdirectories. You could hardcode them in PHP or pass them in via a variable.
# Posted By stoem | 2/13/06 2:55 PM
Hi,
it looks like keyframes.times and keyframes.filepositions are a large amount of numbers for each frame in the video. Macromedia's video encoder doesn't put this information in the Video, so your scrubber do only work with flvmdi.
On the Website of flvmdi they say, that they do this with a commercial 'flv-library', and they want to keep it secret.
Do you think there is a possibility to build the php to calculate the byte position from a given time position and do like flvmdi does, without having the metadata injected?
# Posted By jascha | 2/23/06 10:45 AM
I keep getting a "file do not exist" even thou I have set $path to the right dir. I have tried on my local windows machine running apache and I have tried on my linux server. None work. Any advice would be greatly appreciated :-)
# Posted By Kris | 3/5/06 11:15 AM
Hi,
Very great stuff, it works on the demo but not in my environment.
When moving to another position, I always got StreamNotFound. I got this message without having done any modification on the source code (except, of course, the URL).
Thanks in advance to provide any advise.
Cheers.
Xris
# Posted By Xris | 3/5/06 11:12 PM
it's very likely that the path to your clips folder needs setting up correctly. The sample files won't just run in any environment without modifications.
# Posted By stoem | 3/6/06 8:07 AM
Hi,
Actually, the problem was coming from the (fread($fh, filesize($file)); line.
Replacing the filesize by a constant fixed the problem.
Now, let's try to have it running with FLVPlayBack.
Did someone already succeed ?
Cheers.
Xris
# Posted By Xris | 3/7/06 2:42 PM
After many tests ... I think there is no way to stream FLV by PHP with FLVPlayback Component.
FLVPlayback needs a XML file (from Flash Communication Server) or a *.flv for the contentPath parameter. Any other extensions (php here) doesn't work.
Anyway, to get back metadata from FLV using FLVPlayback, I create a netStream connection and get them (ns.play() + onMetaData + ns.close()). There is no onMetaData method for FLVPlayback. You must use a listener like that :
var listenerObject:Object = new Object();
listenerObject.metadataReceived = function(eventObject:Object):Void {
trace("canSeekToEnd is " + my_FLVPlybk.metadata.canSeekToEnd);
trace("Number of cue points is " + my_FLVPlybk.metadata.cuePoints.length);
trace("Frame rate is " + my_FLVPlybk.metadata.framerate);
trace("Height is " + my_FLVPlybk.metadata.height);
trace("Width is " + my_FLVPlybk.metadata.width);
trace("Duration is " + my_FLVPlybk.metadata.duration + " seconds");
};
my_FLVPlybk.addEventListener("metadataReceived", listenerObject);
But I couldn't access to keyframes object by this method.
I think there is no way to stream FLV with FLVPlayback and this method. Sorry ! :(
# Posted By Alexandre | 3/14/06 6:56 PM
Hi alexandre,
I think in order to make this work with FLVPlayback we would need to modify a few of its classes. I am sure the metadata can also be added but right now the event may simply dispatch a hardcoded series of properties.
I will look into modifying another, simpler player to provide this functionality. FLVPlayback is good but has some baggage that we don't need for this PHP streaming scenario.
stoem
# Posted By stoem | 3/14/06 7:37 PM
FYI
here's a MX 2004 version of the scrubber.fla:
www.flashcomguru.com/downloads/scrubber.zip
# Posted By stoem | 3/15/06 10:52 AM
PHP Streaming with FLVPlayback:
http://philflash.inway.fr/phpstream
This is a beta version.
All sources are available.
Philippe
# Posted By PhillFlash | 3/17/06 4:59 PM
thank you, this is great. I know this is beta but want to point out that the scrubbing didn't work for me. Also the video would constantly restart after a few seconds.
# Posted By stoem | 3/17/06 5:07 PM
Hi,
This is a beta.
All is ok with Internet Explorer but with Mozilla Firefox
there are some bugs.
With Firefox, we will get "NetStream.Play.Stop" events
if there is a seek.
I'm working on a solution but the problem is difficult...
Philippe
# Posted By PhillFlash | 3/17/06 11:58 PM
Hey guys, im new to this video to flv/flash, whats the best solution if i want to play short video clips on a normal php server? Do i need a software to convert the video to flv, and then another sofware that can play the flash file on a web page? Im confused........Please help
# Posted By Jason Naga | 3/19/06 7:42 AM
This web site might be usefull as well if you want to generate FLV online :
www.post-television.com
The generated FLV contains the metadata to use PHP streaming.
Podawan
# Posted By Podawan | 3/21/06 1:48 PM
Well, I spent last weekend putting together the ColdFusion Version of the Script, and also a site to host it on at:
http://www.realitystorm.com/experiments/flash/stre...
The code probably needs some work, and the site's definitely does, but the code does work.
# Posted By Steve Savage | 4/1/06 4:50 PM
SWEET!
I thought it would never happen. Great stuff, I'll give it a try as soon as I the chance as most of my apps run on CF too.
PS: my real name is Stefan Richter ;-)
# Posted By stoem | 4/1/06 5:00 PM
Hi all,
Great program. Looks like it will be quite handy.
Just a thought. In the following line in the as code
if( (times[i] <= tofind) && (times[j] >= tofind ) ){
then ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
might want to put a check just before that and have something like this
if( (times[i] <= tofind) && (times[j] >= tofind ) ){
if(times[j]==tofind) // check upper boundary
i=j;
bufferClip._visible = true;
ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
}
Also, if anyone can point me to some code that reads/seeks binary files in asp i would be happy to change the code to work in asp.
With the php code:
print (fread($fh, filesize($file)));
Might be a good idea to check where abouts in the file you. Say if the flv is 10mb and u seek to the mid part of the flv then fread from mid to the length of the file won't it read 5mb of garbage ? Been awhile since i've used these functions so i'm probably wrong :)
Just curious you will never have the complete flv in the temp int folder ? Unless the user watches the whole video without seeking ?
Terry would it be possible to get a copy of the code you are working on ? Looks interesting. Email is benassi at tpg.com.au
# Posted By Ben | 4/2/06 9:51 AM
I write a new method to find the right position to stream the video when you call the function scrub_it.
In our project, we work with huge file (2 hours and 1 keyframe by second !) and the actual code seems to be optimized ton find the right position on the positions tab.
Instead of linear search on the tab, I thought to cut the tab in 2 parts while the searched value (tofind) is on one part. So, to be clear, if we have 3000 keyframes, we don't test 3000 times the tab as actual. In this code we have only 11/12 loops (3000/2^12) instead of 3000.
The code :
function scrubit() {
//Value can be a float ...!
var tofind = (loader.scrub._x/loaderwidth)*duration;
if (tofind <= 0 ) {
restartIt();
return;
}
var moitie = times.length; //get number of keyframes to test
var tab_test:Array = times; //Copy of the times tab
var positions_test:Array = positions; //Copy of the positions tab
var j = null;
var valeur = 0; //Index of the searched value in the tab
if (moitie > 0) {
//Showing buffer clip
bufferClip._visible = true;
/*************************
Here, we cut tabs on 2 parts. If value is superior of the value in the middle of the tab,
we delete (slice) the left part of the tab. If value is inferior, we delete the right of the tab.
We do many times and when the tab has only 2 values, we verify
*************************/
while (tab_test.length != 1) {
/************************
This if can be deleted if you want the inferior value (in the exemple, it will be 11 and not 12)
of the tab near the value to find.
Exemple : if tofind = 11.6 and the time tab has two value 11 and 12, it's the value 12 which
will be selected. We take this position and find the searched positions on the tab positions
************************/
if (tab_test.length == 2) {
var ecart = (tab_test[1] - tab_test[0])/2;
var verif = tab_test[1] - tofind;
if (verif < ecart) valeur = 1;
if (verif >= ecart) valeur = 0;
break;
}
else {
j = Math.round(moitie/2);
if (tofind > tab_test[j]) {
tab_test = tab_test.slice(j, tab_test.length);
positions_test = positions_test.slice(j, positions_test.length);
}
else {
tab_test = tab_test.slice(0, j);
positions_test = positions_test.slice(0, j);
}
moitie = tab_test.length;
}
}
trace("play " + _phpURL + "?file=" + _vidName + "&position=" + positions_test[valeur]);
ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions_test[valeur]);
}
}
Perhaps there is error(s) beacause I write it for the function scrub_it() quickly (I tested it correctly with my own tab not times and positions added to a flv).
Here is the original code :
var tab:Array = new Array(3,5,8,10,15,17,19,31,33,34,36,48,52,67,78.1,90,101,111,112,113,114,115,116,120,
121,130,131,132,145,189,190,193,215,234,235,245,253,256,456,478,500,511,512,513);
var positions:Array = new Array(3,5,8,10,15,17,19,31,33,34,36,48,52,67,78.1,90,101,111,112,113,114,115,
116,120,121,130,131,132,145,189,190,193,215,234,235,245,253,256,456,478,500,511,512,513);
var toFind = 234.6;
trace("Taille du tableau
# Posted By Alexandre | 4/3/06 7:30 PM
Sorry for the flood ... some caracters are not taken by the comment post ... i write again ....
Perhaps there is error(s) beacause I write it for the function scrub_it() quickly (I tested it correctly with my own tab not times and positions added to a flv).
Here is the original code :
var tab:Array = new Array(3,5,8,10,15,17,19,31,33,34,36,48,52,67,78.1,90,101,111,112,113,114,115,
116,120,121,130,131,132,145,189,190,193,215,234,235,245,253,256,456,478,500,511,512,513);
var positions:Array = new Array(3,5,8,10,15,17,19,31,33,34,36,48,52,67,78.1,90,101,111,112,113,114
,115,116,120,121,130,131,132,145,189,190,193,215,234,235,245,253,256,456,478,500,511,512,513);
var toFind = 234.6;
var moitie = tab.length;
var tab_test:Array = tab;
var positions_test:Array = positions;
var j = null;
var valeur = 0;
while (tab_test.length != 1) {
if (tab_test.length == 2) {
var ecart = (tab_test[1] - tab_test[0])/2;
var verif = tab_test[1] - toFind;
if (verif < ecart) valeur = 1;
if (verif >= ecart) valeur = 0;
break;
}
else {
j = Math.round(moitie/2);
if (toFind > tab_test[j]) {
tab_test = tab_test.slice(j, tab_test.length);
positions_test = positions_test.slice(j, positions_test.length);
}
else {
tab_test = tab_test.slice(0, j);
positions_test = positions_test.slice(0, j);
}
moitie = tab_test.length;
}
}
trace("Position" + positions_test[valeur]);
And SORRY FOR MY ENGLISH ...
Alexandre
# Posted By Alexandre | 4/3/06 7:34 PM
This is a very cool approach! I think we should implement this into the player. And we still need a better player too :-)
# Posted By stoem | 4/3/06 8:20 PM
I've been looking at the scrub function also, and wondered if there was a way to improve performance, instead of cutting the array in half, I created a initial "guess" of where the key frame I'm looking for may be in the time array:
function scrubit() {
var b_match = false
var f_percentage = loader.scrub._x/loaderwidth;
var i_selected = Math.floor(f_percentage*duration);
/* Guess that the key frame I'm looking for is about the same percentage through
the array of times/keyframes as the position that was selected in the "scrub" slider.
*/
var i_guess = Math.floor(f_percentage*times.length);
if (i_selected <= 0 || i_guess <=0) {
restartIt();
return;
}
do {
if(times[i_guess-1] <= i_selected && times[i_guess+1] >= i_selected) {
trace("match at " + times[i_guess] + " and " + positions[i_guess]);
bufferClip._visible = true;
ns.play( _streamerURL + "?vidID=" + _vidID + "&vidFile=" + _vidFile + "&vidPosition=" + positions[i_guess]);
trace("play " + _streamerURL + "?vidID=" + _vidID + "&vidFile=" + _vidFile + "&vidPosition=" + positions[i_guess]);
break;
}
else if (times[i_guess] >= i_selected) {
i_guess = i_guess - 1; }
else { i_guess = i_guess + 1; }
}
while (i_guess >= 0 && i_guess < times.length)
}
The next step will be to apply Newton's Method for further improvement.
# Posted By Steve Savage | 4/4/06 10:14 PM
Stoem -> Thanks :)
Steve Savage -> Another approach that I thought before. The code works near perfect only if the "video encoding" adds keyframes as much as secondes ! But I doesn't thought about pourcentage ! Very good idea.
For example (a video of 100 secondes, more easy)
loaderwidth = 100;
loader.scrub._x = 10;
var f_percentage = 0.1;
var i_selected = 10;
//There is as much as keyframes than secondes (times.length = 100)
var i_guess = 10;
-->The code make one loop only ! So quick :)
//There is 2 keyframes by secondes (times.length = 200)
var i_guess2 = 20;
-->The code make 10 loops to find the good index.
//There is 1 keyframe by 4 secondes (times.length = 25)
var i_guess3 = 2;
-->The code make only one loop I think ! Cool !
With my code and same video :
1-4 loops
2-5 loops (better)
3-3 loops
Another example with a huge video (4000 secondes)
loaderwidth = 100;
loader.scrub._x = 10;
var f_percentage = 0.1;
var i_selected = 400;
//There is as much as keyframes than secondes (times.length = 4000)
var i_guess = 400;
-->1 loop
//There is 2 keyframes by secondes (times.length = 8000)
var i_guess2 = 800;
-->The code make 400 LOOPS to find the good index (ouch ! but better as actually)
//There is 1 keyframe by 4 secondes (times.length = 1000)
var i_guess3 = 100;
-->1 loop
With my code and same video :
1-12 loops
2-13 loops (better way only here)
3-10 loops
I think I haven't take the best examples here but ... I can say that your code works perfect with small files and/or with keyframes number <= secondes.
If we need precision and a lot of keyframes, my way can be quicker. But finally the two codes are really fast.
A BONUS : with my code, I work with float value (Math.floor not used) and find the nearest keyframe and not the "under keyframe" (ex : times[12] for 11.7 value instead of times[11] as actual).
So, I take note about your "pourcentage method" and I'm interested in Newton's method (but can't find a way to implement it correctly ...)
PS :
with this line : "while (i_guess >= 0 && i_guess < times.length)"
I think it should be no scrub in the last keyframe ... "times[i_guess+1]" is undefined if "i_guess = (times.length - 1)" ... so, "while (i_guess >= 0 && i_guess < (times.length - 1))" is the good way ...
!!! : I notice with this postscriptum that the actual method doesn't scrub correctly if we take a value of timeline > of the last keyframe (ex : last keyframe at 100 secondes and we search 100,34 secondes) because of comparaison "if( (times[i] <= tofind) && (times[j] >= tofind ) )" ...!
It's not a problem with my "slice method".
Alexandre
# Posted By Alexandre | 4/5/06 12:06 AM
Sorry, 100.34 works because of Math.round ! But 100.75 doesn't work ;)
Alexandre
# Posted By Alexandre | 4/5/06 12:10 AM
Hi,
We have extended this player to an advanced level.
Please check below URL.
http://www.dearmyfriends.com/v13/popup.php?idx=390...
Points covered:
i) dvd kind of chapters ( list of intersting poitnsto jump directly to that video part).
ii) can be viewed in different sizes. ie 1x,2x etc
iii) Previous and Next Video buttons( Yes..the two korean buttons provide this)
iv)Exact loadbar showing what bytes loaded to browser.
v) Enhanced php to send bytes to browser
http://www.dearmyfriends.com/v13/popup.php?idx=390...
Thanks
Sudhi
# Posted By Sudhi | 4/5/06 8:09 AM
If you want to check a little large video , You can check this.
http://fmx.exellen.com/v13/popup.php?idx=311&m...
# Posted By Sudhi | 4/5/06 8:49 AM
thanks everyone for the work on this.
Sudhi: your page does not contain embed tags for the swf, therefore the page only work in IR and not in Firefox.
Also can you make the source files available?
thanks
# Posted By stoem | 4/5/06 10:13 AM
A little "Bug" here: When I try to scrub on a Mac OS X with Firefox the Video freezes and I cant reconnect to the Server until my session is timeout.
# Posted By nathan | 4/5/06 2:09 PM
Dear stoem ,
It is still under improvement, SO I cant open sources at this stage. If you have any thing to say , you can mail me.
http://fmx.exellen.com/v13/popup.php?idx=398
check above video, which is streaming at 2 MBPS.
I have added Embed tag, so it will work in other browsers too..
--Sudhi
# Posted By Sudhi | 4/7/06 4:51 AM
How do I implement the php file, do I need to use an include() statement?
# Posted By Brian | 4/10/06 5:21 PM
Guys I need some help. I have a 277 meg flv file that I have succesfully got to stream using the lighttd web server but I can't replace my apache2 linux server with that. I am running a linux box with apache2. I have the hacked scrubber.swf file that uses ?file to get the video parameter. I have the phpstream.zip found on this page. I have the video.flv file the flvprovider.php and the scrubber.swf all in a direcory on my webserver. I have a index.html with this object
<object type="application/x-shockwave-flash" data="scrubber.swf?file=video.flv" width="420" height="315" wmode="transparent" VIEWASTEXT>
<param name="movie" value="scrubber.swf?file=video.flv" />
<param name="wmode" value="transparent" />
</object>
Now from what I have gathered I need it to look like this
<object type="application/x-shockwave-flash" data="scrubber.swf?file=flvprovider.phpfile=" width="420" height="315" wmode="transparent" VIEWASTEXT>
<param name="movie" value="scrubber.swf?file=flvprovider.php?file=video.flv" />
<param name="wmode" value="transparent" />
</object>
and I have tried both and neither work? I get buffer that never buffers. Any idea?
Thanks for your help.
Roger
# Posted By Roger | 4/10/06 7:11 PM
My basic question is how to use one SWF Flash player that I create in Flash 8 to play a variety of FLV files which site in a variety of folders based on PHP variables that are passed to the HTML page in which the Flash player is embedded.
Here are the details:
I'm embedding the flash player on a website that uses PHP and MySQL to pull information about a house/property from a database.
There is a PHP variable called $ID which corresponds to the folder that the FLV file sits in on the web server. So there will be a main folder called "properties" with many subfolders inside ("1", "2", "3"....) Inside each subfolder will be a "name.FLV" file which I want the one player to play. The actual SWF Flash Player will sit in the root folder of the webserver.
When I showed videos in the WMV format I used URL's that looked like this to pass the variables.
http://www.domain.com/m.php?video=ID
Then the code for the embedded player would look something like this:
<embed src="properties/< echo $ID; ?>/name.wmv" ></embed>
My question is how do I use the variables that are in the URL to determine which FLV file my flash_player.SWF file plays?
Any help would be greatly appreciated.
Thanks.
Elliot
# Posted By Elliot | 4/11/06 7:22 PM
I really like this solution - thanks a lot for collecting all this info and offering the sources for download!!
One problem that has already been mentioned but not solved yet: when the user watches a part of the video and then moves the slider to a previous point in the timeline the video gets downloaded again. I think that this could sum up quickly and waste a *lot* of bandwidth and that's the only reason why I'm hesitating to use this approach.
Do you think it would be possible to solve this problem? I haven't had an idea yet...
# Posted By Anna | 4/12/06 5:46 PM
Yeah I think we have discussed this once before. The only way around this that I see is to monitor if the entire flv has been cached/downloaded already in which case you could request it in 'the old way' without going through PHP.
In a way this issue is apparent in all streaming server solutions: if a user seeks and plays the same part of a video 3 times then he will consume the bandwidth 3 times. The PHP approach is 'worse' in a way because you may be downloading more footage than you are actually consuming - when you seek to another point that entire process starts again and for every 10 seconds watched you may be downloading 30 seconds worth of footage - in this way a real streaming server is much more efficient. So yes, potentially the PHP method will waste bandwidth.
# Posted By stoem | 4/13/06 11:43 AM
Well it looks like there might be a solution :
http://www.rich-media-project.com/products/test2
It is still under development but once again Rich Media Project guyes are pushing PHP technology to the next level...
# Posted By Tom | 4/20/06 12:52 PM
Hi everybody and thanks for the great work.
This product would be perfect if only we can protect flv files from being downloaded.
The flv is deleted from the temporary Internet files but if i use a sniffer i can get the link to the php page with the variables required to download the flv (as a php file that just need to be renamed with an flv extension).
1) The swf can be encrypted, but i would still be able to sniff the link and download the file because the variables are sent to the PHP script using a GET method.
I don't think it would be possible to send variables using a POST method but someone has probably an idea concerning this point ?
2) The PHP script can ask for the HTTP referrer but once again it is easy to fake this data.
3) I thought about a cookie but the user would be able to watch the original webpage and download the movie at the same time.
4) Google Video, Youtube, Metacafe, Music movies can be downloaded easily so there is probably no solution to secure movie in flash.
Security is always a problem :(
# Posted By phil | 4/23/06 8:39 PM
if you put a file online then it will be downloadable, not much you can do about that. A progressive flv is always cached, even when run via a script. Some people have played with http headers that expire the content right away but a dedicated user can still grab the file. If you want some more 'security' (if such a thing exists) then you need a real streaming solution (FMS if you want to use Flash).
# Posted By stoem | 4/23/06 8:51 PM
hi.. i just did all the work to get this going for 12 different pages.. i tested it out on the first one.. np it worked.. but i forgot to test INTERNET EXPLORER!
i get no video in IE.. please help.. firefox works fine.
url: http://onetribedesign.com/bridal/chris.htm
# Posted By dewey | 4/27/06 6:21 AM
also,i forgot..
the video on THIS page does NOT work in INTERNET EXPLORER either... only firefox!
# Posted By dewey | 4/27/06 6:22 AM
video works fine for me in IE 6.2 and Firefox, however it stops working in both browsers once I seek
# Posted By stoem | 4/27/06 8:15 AM
me again...
thx for checking, but it's still not working for me. i have IE 6.0.2900.......... i also checked it in IE 6.0.2800........ neither will show video.. only audio...
another person told me they could see it in 6.0...
the coldfusion one works in my IE... but i can't use that :-(
any ideas on why I can't see it but you can? i checked IE settings and all is ok there.. :-)
# Posted By dewey | 4/27/06 5:21 PM
You got which version flash Player installed?
Does the clip on this page work for you?
# Posted By stoem | 4/27/06 5:25 PM
flash 8.0
the clip on this page will work for me in firefox.. just not ie
same with my clips
# Posted By dewey | 4/27/06 5:28 PM
Fantastic!
I am however having a problem implementing...I think my error is in defining the $path variable in the flvprovider.php file.
I have $path = 'http://www.mywebsite.net/subfoldername/';
Is this correct?
If I target flvprovider.php directly in the browser I get the following error:
0ERORR: The file does not exist
Any help greatly appreciated!!
# Posted By jim bachalo | 5/17/06 12:34 AM
hi Jim,
the path needs to be a path on disk, for example c:\myapp\myvideos - not a URL.
Stefan
# Posted By stoem | 5/17/06 9:30 AM
Stefan
Thanks...almost there.
I get the following using a script to determine my system path:
Path to server root: /dh/
Path to this file: /home/.test/clientname/sitename.net/mydirectory
So would the correct $path variable be?:
/dh/home/.test/clientname/sitename.net/mydirectory/
Thanks again!
# Posted By jim bachalo | 5/17/06 3:25 PM
sorry, I'm no good with *nix systems. Anyone else?
# Posted By stoem | 5/17/06 3:28 PM
I've been messing around with this script for a little while now. Using your example works fine. But when I try it on my own, I can move the scrubber to the middle of the loadbar and the video pauses and when I move it back to the beginning, it starts playing from the beginning. Now, when I move the scrubber, the trace is showing the file plus the position to play. I may have missed something about the PHP file in all of this. Has anything been updated since the posting
if($pos > 0) {
print("FLV");
print(pack('C',1));
print(pack('C',1));
print(pack('N',9));
print(pack('N',9));
}
Thanks,
Dmitry
I hope this link helps you guys out, it shows an example of it in action. Personaly i prefer this way as it seems to be more efficient than the script method.
have a look.
http://www.mediamodus.com/isapi-progressive-stream...
maybe it's crazy or completely insane my question but i am going with it.
my plan was to build a small website like you tube with my own player
i follow example on www.gotoandplay.com and i customize the player to respond to my own well some fency skins nothing+ nothing-
i upload and convert avi files using ffmpeg and php (workfine)
i stock my video in my databse etc...
what i want is to send the name of the video to my flash.swf in oder to play it
how do i do that what is the best way sendandload var or directly pass the variable to embed.
and secondly what is the thing about xmoov.php and all bandwith thing what does it
do cuz in the tutorial i don't really see those thing www.gotoandplay.com
or maybe i am completely out of bounds and i should give up my project cuz i am still searching for a solution and still can found nothing
i just have some lil knoledge in both flash and php but i need ot understand better here's my email mr_malice23@hotmail.com please contact me to help
maybe it's crazy or completely insane my question but i am going with it.
my plan was to build a small website like you tube with my own player
i follow example on www.gotoandplay.com and i customize the player to respond to my own well some fency skins nothing+ nothing-
i upload and convert avi files using ffmpeg and php (workfine)
i stock my video in my databse etc...
what i want is to send the name of the video to my flash.swf in oder to play it
how do i do that what is the best way sendandload var or directly pass the variable to embed.
and secondly what is the thing about xmoov.php and all bandwith thing what does it
do cuz in the tutorial i don't really see those thing www.gotoandplay.com
or maybe i am completely out of bounds and i should give up my project cuz i am still searching for a solution and still can found nothing
i just have some lil knoledge in both flash and php but i need ot understand better here's my email mr_malice23@hotmail.com please contact me to help
I want to use the solution from Lance, http://www.courierwebcasts.com.
Here is what I tried already:
I set up a .flv with the path and the name of the video in Actionscript 2.
I used flvprovider with the root and the path to scrubber.swf (and the video)
I injected code with flvmdi in the flv.
I embedded scrubber swf in my html page.
Result: The player is showing up at the webpage - but I get the message that the flv within the path was not found - but the flv with exact the right nae is in the right directory...
Every help is appreciated!
Thank you, splatt
Can you help me with my problem?
I want to autoplay a flv file and then play
the second one after playing the first.
How will i able to do it. Its my fourth day and i cant figure it out. please help. thanks
splatt
you might want to look at www.mediamodus.com if your thinking of doing a youttube type thing, there is a progressive filter and a video converter on the way. you can test the video converter at http://video.mediamodus.com
check it out. :)
Could you help me? I actually need a stepbystep tutorial how to use this solution.
I know nothing about flash, do I have to learn it to use this code?
Thanx in advance!
I have implemented it on my server. Everything I have done as per instruction but still its not working. When I execute file it shows blank page when I right click on player place it shows "Movie not loaded". Please let me what are thing I need to set to make it wokring. Its very urgent for me
Thanks in advance!
Regards,
SanjayG
On http://www.jeroenwijering.com/ I found one setup wizard according to that I have setup this on server.
Below is the details:
var so = new SWFObject('upload/player.swf','mpl','470','250','9','#ffffff');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addVariable('file','bunny.flv');
so.addVariable('streamscript','embed/xmoov.php');
so.addVariable('tracecall','printTrace');
so.write('preview');
this is my player code. I have player.swf and .flv file in same folder. xmoov.php in embed folder. In xmoov.php I have also set proper pathfor video. After this all If I click on play video I get below result
layer ready(id:mpl,version:4.0 r12,client:FLASH WIN 9,0,45,0)
CONTROLLER: RESIZE (height:230,fullscreen:false,width:470)
MODEL: TIME (duration:0,position:0)
MODEL: STATE (oldstate:undefined,newstate:IDLE)
CONTROLLER: PLAYLIST (playlist:[object Object])
VIEW: PLAY
MODEL: META (info:NetConnection.Connect.Success)
MODEL: STATE (oldstate:IDLE,newstate:BUFFERING)
CONTROLLER: ITEM (index:0)
MODEL: LOADED (total:4294967295,loaded:0,offset:0)
MODEL: BUFFER (percentage:0)
MODEL: LOADED (total:4294967295,loaded:0,offset:0)
MODEL: BUFFER (percentage:0)
MODEL: LOADED (total:4294967295,loaded:0,offset:0)
MODEL: BUFFER (percentage:0)
MODEL: LOADED (total:4294967295,loaded:0,offset:0)
MODEL: BUFFER (percentage:0)
MODEL: LOADED (total:4294967295,loaded:0,offset:0)
MODEL: BUFFER (percentage:0)
MODEL: LOADED (total:4169,loaded:4169,offset:0)
MODEL: BUFFER (percentage:0)
MODEL: BUFFER (percentage:0)
MODEL: BUFFER (percentage:0)
MODEL: BUFFER (percentage:0)
MODEL: BUFFER (percentage:0)
.....
And it goes in loop.
But in above javascript player code If I comment streamscript parameter then its working fine but I guess that is normal streaming.
Please advice. I am stuck on this not getting any way to make it working.
Thanks,
SanjayG
i cant help you on this one as im not a PHP guy, i use the ISAPI streaming option in IIS.
But now that you have posted in more detail im certain somone here could help :)
I just noticed your post is 2005 so maybe you did too since then :)
I see you're in Nottingham - I live just outside Leicester.
Could you drop me an email please: stefan AT flashcomguru DOT com
thanks
is where the file is on my server and the localhost box has a dir like this:
C:\Program Files\EasyPHP 2.0b1\www\phpstream_update\video\golfers.flv
can anyone help here?
regads
is where the file is on my server and the localhost box has a dir like this:
C:\Program Files\EasyPHP 2.0b1\www\phpstream_update\video\golfers.flv
can anyone help here?
regads
Windows 2003 Server
Windows XP
IIS 6
i run php, apache.. i think this method will work very nicely when i get it working - thanks for the link ez
Does anyone have a solution for this problem?
If you open a session before you output the flv, then make sure you close it before outputting the video.
session_write_close();
header ("Content-transfer-encoding: binary");
header ("Content-Type: video/flv");
header("Content-Disposition: attachment; filename=video.flv");
@readfile($url);
Thanks for your answer.
My shared hosting server doesn't allow users to execute their binary files so I cannot use this tools, I need PHP or Perl scripts :(
So can anybody help me?
My shared hosting server doesn't allow users to execute their binary files so I cannot use this tools, I need PHP or Perl scripts :(
So can anybody help me?
Its really great idea. But i have a prob. with the implementation. I uploaded all your source to my server, but when i point the browser to the file flvprovider.php it says an ERORR: The file does not exist.
I have uploaded my video to this path below :
http://www.smusiclive.com/phpvideo
In your script what is the path should i give to make this work for me.
Awaiting your guidance.
Thanks & Regards
Leo Amal
Every thing works fine for me, i just need to disable the right click menu option from the player. Kindly go through the coding and suggest me the script to disable the right click menu option on the flv player, also mention where to write that script.
<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona...">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sample Video</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var attributes = {};
var params = {};
// for fullscreen
params.allowfullscreen = "true";
params.wmode = "transparent";
params.showmenu = "false";
var flashvars = {};
// the video file or the playlist file
flashvars.file = "pcrf_promo.flv&logo=http://www.magnalive.org/logo.gif";
// the PHP script
flashvars.streamscript = "flvprovider.php";
flashvars.bufferlength = "3.8";
// width and height of the player (h is height of the video + 20 for controlbar)
// required for IE7
flashvars.width = "640";
flashvars.height = "320";
// width and height of the video
flashvars.displaywidth = "640";
flashvars.displayheight = "320";
flashvars.autostart = "true";
flashvars.showdigits = "true";
// for fullscreen
flashvars.showfsbutton = "false";
// 9 for Flash Player 9 (for ON2 Codec and FullScreen)
swfobject.embedSWF("phpsflvplayer.swf", "flashcontent", "640", "320", "9.0.0", "playerProductInstall.swf", flashvars, params, attributes);
</script>
</head>
<body bgcolor="#C4CCC7" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><div align="center"> <div id="flashcontent">
<div align="center">
<table width="52%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">To
view this video you need JavaScript enabled and the latest Adobe Flash
Player installed. <br />
<a href="http://www.adobe.com/go/getflashplayer/">Download the free
Flash Player now</a>.</font></div></td>
</tr>
</table>
</div>
</body>
</html>
Thanks in advance
i just tried this player but my player didn't stream but it starts well when i put move the scrubber it is not starting from the place i am using wamp server i don't know whether i have to configure apache httpd.
could u pls help me...
@flashObj, you need to inject the keyframes first for it to work, read closely :)
http://www.mediamodus.com/isapi-progressive-stream...
and
http://www.mediamodus.com/flv-meta-editor
ENjoy ;)
what site?
The message suggests to me that the flv file is 404'd.. check your paths
Add upload file field to web form, including php programming.
Add field to output form that has a link or button to play the uploaded video.
I didn't see a pause or stop function on your sample. Can that be easily included?
Your help is greatly appreciate. Thanks.
I still have problem with the path.
Can someone show me example??
plss
thx
I have a Flash website, the whole site done in flash (index.swf). There is a movie on the stage (vidPlayer_MC) into which I load an external .swf (player1.swf, player2.swf, player3.swf, etc.) which is basically this PHP streaming player.
I have buttons on the main timeline (of index.swf) which switch the current player which is loaded. Each button loads in a separate version of this player, each of which has hard-coded a single .flv video file it plays. I would rather have the buttons control the flv file and just use one external .wf player, or even better code the player itself as part of my main flash site instead of using an external .swf, but I don't know how.
For now, the first video to load runs great. I have injected the data and it scrubs fine, etc. The movie clip vidPlayer_MC loads in player1.swf automatically and starts playing. If you click a button to change videos, such as loading player2.swf into vidPlayer_MC, it seems to work fine until you try to scrub back and forth.
The little grabby bar on the timeline doesn't want to follow the mouse, but bounces around... mostly trying to stay put where it was on the timeline. If you can let go of the mouse button when the bar is not in the same spot, which requires trial and error and luck, it does scrub to that location - but you have no control over where/when that is in the video.
If you switch back to the original (player1.swf), it will now do the same error.
So... does anyone know what causes that, and how to fix it? Or better yet, how I could integrate this player into a much larger flash website without loading in an external swf file?
Thanks!
One issue is with Lance's modification to include the time elapsed / duration counters - he is no longer with the website linked to in his posts so I am not sure how to get in touch with him... maybe someone else here can help. The timer works fine until you scrub through the video, then it freezes at the time it was on (before you grabbed the scrubber), and never resumes counting. No idea why. Any help?
The other issue is in playing multiple videos through one player. I can use a button with the following script to change videos, but the audio from the first (or all previous if you changed multiple times) continues on... how do I stop one video before starting the new one?
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
on (release) {
_root.vidMC.theVideo.attachVideo(ns);
playButton._visible = false;
ns.setBufferTime(2);
ns.play("http://www.mysite.com/show4.flv");
}
I have a problem. I just started a web site. Now i want to give a space where any one ca add video.
I think they must be allowed to either upload or input a link which then either streams from another site (e.g. youtube)
or plays from our server.
Can you please Help me out. I am using PHP, Symfony framework and Apache.
Santosh P.
Bangalore, India
Can you explain me whats your problem to my mail id udhaya0000@gmail.com.
i think i can help you in this problem you can mail me your problem to my mail id udhaya0000@gmail.com
i sended to ur email id. plz find out..
[b]I have change the xmoov script like this:[/b]
// points to server root
define('XMOOV_PATH_ROOT', 'C:/Program Files/Apache Software Foundation/Apache2.2/htdocs'); //this is the path where my htdocs(apache server resides)
// points to the folder containing the video files.
define('XMOOV_PATH_FILES', '/phpstream/video/');//and this the video folder resided in the apache htdocs folder path
and
// INCOMING GET VARIABLES CONFIGURATION
define('XMOOV_GET_POSITION', 'start');// changed the position to start
[b]And below is the index(html) file I used to run the script.[/b]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<div id="flashcontent">
<strong>You need to upgrade your Flash Player</strong>
This is replaced by the Flash content.
Place your alternate content here and users without the Flash plugin or with
Javascript turned off will see this. Content here allows you to leave out <code>noscript</code>
tags. Include a link to <a href="swfobject.html?detectflash=false">bypass the detection</a> if you wish.
</div>
<script type='text/javascript'>
var s1 = new SWFObject('player-viral.swf',"ply","500","400","9.0.124","#FFFFFF");
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam("flashvars","file=bunny.flv&streamer=xmoov.php&autostart=true&start=3&id=1");
s1.write('flashcontent');
</body>
</html>
I placed the related video to be played in the video folder .
[b]This is my folder structure I used:[/b]
/videos/ //videos folder
xmoov.php //xmoov file
/flash/ //player41.swf
/script/ //swobject.js.
I followed all the steps of KLink, But its not playing the video its showing loading
And the server get request from the xmoov.[b]
And when the following link is placed on the browser[/b]
http://localhost/phpstream/xmoov.php?file=bunny.fl...
It gives an options to open and download the bunny.flv video file.
But its not playing.
Can anyone help me, I really tried for so many days,but the result is same.
Hope someone may have the same problem, before they get succeeded this streaming problem.
Ur suggestions are accepted, If I did any minor mistakes too.
I'm new to the php scripting so If I did any minor mistakes,please kindly help for this Streaming problem.
Thanks Inadvance.
$file = 'golfers.flv'l
If I put the URL of the script into my browser, it downloads just fine and plays in my adobe media player (I had to add another header line for content-disposition)... although when i try to play it in JW player.. It just says that it is not a valid XML file. sucks.
#1) My file was f4v and wouldnt play even if took out the code to check for the flv extension. I guess JW player can play f4v, but when using php streaming, it only lets you use flv.. had to re-encode... (those injectors dont work with f4v either)
#2) The scripting was a little different. See below.
For those of you trying to use JW player.. here you go:
http://www.inwayvideo.com/phpflvplayer/index_en.ht...
For those of you who are trying to hide the file name, people can still use FIREBUG plug to figure out the filename. However there IS a way to keep people from downloading it: .htaccess
Simple deny everyone in your .htaccess file from getting to the movie (except for 127.0.0.1). Because its the php script, and not the client, actually reading the file, the request is coming from 127.0.0.1 If someone figures out your filename they won't be able to get it.
Unless... they get it through the cache.. which pretty much makes everything here moot. Bummer.
I guess I'll have to go with a true streaming package
Could you add junk to the video file that you take into account for in your player. this of course wont prevent a determined person from "unjunking" the file but would stop casual "theft".
J
http://www.aboutspywareremoval.com
My issue is that I need to join more than one FLV file in the PHP stream. So I tried the following:
/////////////////////////////////////////
if($seekat1 != 0) {
print("FLV");
print(pack('C', 1 ));
print(pack('C', 1 ));
print(pack('N', 9 ));
print(pack('N', 9 ));
}
$fh1 = fopen("file1.flv", "rb") or exit("Could not open file1.flv");
fseek($fh1, $seekat1);
while (!feof($fh1)) {
print (fread($fh1, 16384));
}
fclose($fh1);
$fh2 = fopen("file2.flv", "rb") or exit("Could not open file2.flv");
fseek($fh2, $seekat2);
while (!feof($fh2)) {
print (fread($fh2, 16384));
}
fclose($fh2);
/////////////////////////////////////////
But didn't work. It streamed the part of the first file "file1.flv" successfully then stopped without continuing streaming the part of the second file "file2.flv". Am I missing pack() that should be written between the 2 streams?
Appreciate your help.
Thanks,
Raed Petro.
Hi Raed,
Its been a while since i wokred with the flv file format so this off the top of my head.
the FLV signature is the first 9 bytes of the file.
So in theory, all flv files after the first one need to have the first 9 bytes removed before streaming.
Thanks for your reply.
In my code I skipped the first 9 bytes from the second file. Actually I am trying to seek file2.flv from the middle via $seekat2.
Anyway I am still trying .. didn't giveup yet.
Thanks,
Raed Petro.
hi, yes i noticed that after I had posted :/ ( i'm not a PHP developer )
my next question is what meta data exists in the first flv file?
I suggest addding more time markers than really exist or somthing simular. At the moment the player will get the metadata and "know" how long the video is and stop. regardless that it is now longer.
Your thoughts?
Then doing the same with file 2 .. seeking it from the middle via $seekat2 (i.e. skipping its header/metadata) .. but the player doesn't like this part :-)
I think the problem is something linking "joining" the 2 parts .. may be at the end of the part first or at the beginning of the second part .. or may be something else :-)
I reckon that if there is meta data the player will stop when it thinks its the end of file.
Let me know if metadata still exists, what your attempting certainly seems dooable :)
I suspect your trying to deliever video adverts ?
I thought metadata in the header only. Sorry I am not very good in this issue, I know more about PHP .. not FLV and flash stuff.
Finally I got it working :-)
The problem was that every joined FLV must begin with a keyframe and ends with a keyframe. When I did this it worked fine.
Thanks Jason.
can you post your final code please to get this to work?
nice code!!
but can u give me the whole file like html file to php file !!
i mean whole code to run a video!!
its urgent!!
thnx in advance!!
pls
help me!!
thnx!! thnx!! thnx!! thnx!! thnx!!
nice code!!
but can u give me the whole file like html file to php file !!
i mean whole code to run a video!!
its urgent!!
thnx in advance!!
pls
help me!!
thnx!! thnx!! thnx!! thnx!! thnx!!
I tried blocking flv's for "preventing illigal views", but it gave me a lot of problems. So I started red5 hosting...
Put my name in the email and i might be able to help ;0)