FlashComGuru Home streaming portalInfluxisCDNImediaseeUvault
                                                                                       Forum Index | Active Topics | Register
                                                                                                          List Overview | List Archives
                                                                                                                           About this site | Advertise
 

home

Adobe AIR (10)
Applications (36)
Books & Training (10)
Collaboration (15)
Components (8)
Events (69)
Flash Player (23)
Flex (32)
FMS (100)
General (119)
Hosting (5)
Jobs (14)
Off topic (36)
Press Releases (18)
Site Check (11)
Tools (46)
Videos & Players (67)

Follow me on Twitter

 
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.zip

UPDATE: Steve Savage has now ported this to Coldfusion: http://www.realitystorm.com/experiments/flash/streamingFLV/index.cfm

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

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 of the zip file?

Thanks
# Posted By Scott | 5/18/06 7:13 PM
Is it possible to use this project without a macromedia flash ide?

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)
# Posted By tester | 6/12/06 1:04 AM
yes, you can use scrubber without Flash - but you first need to create a swf that can take external parameters, that's why I published the fla source.
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...
# Posted By stoem | 6/12/06 9:14 AM
hi, thank you for your fast response,
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
# Posted By tester | 6/12/06 11:14 AM
Hi,

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
# Posted By Barbara | 6/20/06 1:13 PM
very good question... I don't know the answer
# Posted By stoem | 6/20/06 1:19 PM
yes you can i just tried with a mp3 encoded as flv
# Posted By Korben | 6/26/06 1:39 PM
I also tried, but when encoding the mp3 with no images (i.e there is no keyframe), it can't succeed. Could you put your mp3 encoded in flv somewhere ?
Thanks

Barbara
# Posted By Barbara | 6/26/06 1:42 PM
Great job! I'm a designer(novice/intermediate programmer) and wanted to use this script but would like the PHP to feed the flv to the swf directly. So...
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.
# Posted By Wes O'Haire | 6/29/06 12:48 AM
Yes you can, in fact that's what I do for my version of the script, both the Coldfusion script I made, my modified PHP script, and modified player all use a vid_id instead of the vid name, I did this to make the script more secure.

http://www.realitystorm.com/experiments/flash/stre...
# Posted By Steve Savage | 6/29/06 12:37 PM
here's another adapted player
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.
# Posted By stoem | 7/3/06 7:45 AM
Please see this announcement regarding an alternative method of streaming via PHP. One that does not require metadata injection.
# Posted By mcnaz | 7/9/06 6:37 PM
# Posted By mcnaz | 7/9/06 6:37 PM
hello all...

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 :)
# Posted By BANGER | 7/20/06 12:35 AM
Hi,

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?
# Posted By nethost | 7/24/06 10:27 PM
Hi,

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
# Posted By novice | 7/25/06 6:06 AM
Great job guys on the selected streaming solution! I was wondering if I could tap into some of your expertise in this area for a problem I've been having with larger files, 40mb+ in IE only (6.0.2900).

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
# Posted By shonuff | 7/27/06 11:17 PM
Regarding the pause/lockup problem in IE. I think I've narrowed it down possibly to the ActiveX Control Update for IE as the culprit (you know the one that makes you "click to activate and use this control"). I just tried on a machine that didn't have the update and the loading works fine with no pause/lockup occuring. I'll have to test out on IE 7 then as well.
# Posted By shonuff | 7/28/06 12:14 AM
Hi, I 'm using this player with an flv on my server that is larger than the actual component (component is 240x320 and flv is 480x640). Is there a way to dynamically set the video stream to match the size of the player? Right now it is only displaying the top left portion of the flv.
# Posted By wes O'Haire | 8/8/06 8:59 AM
Wes, yes that's possible but not something I can explain right here. I suggest you post in the forums.
# Posted By Stefan | 8/8/06 9:07 AM
Will do
# Posted By wes O'Haire | 8/8/06 9:14 AM
is the updated source now able to directly play from the hdd once its cached, else then reloading from server over and over?

thanks
# Posted By banger | 8/8/06 10:34 AM
no that's something you have to add yourself - unless somebody has added it?
# Posted By Stefan | 8/8/06 10:36 AM
This is some revolutionary stuff!
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
# Posted By Dirk | 8/10/06 9:06 PM
Hi 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.
# Posted By mcnaz | 8/14/06 9:42 AM
The metadata information is used to seek within the video. Let's imagine the file is not injected, but the player knows the 2 mandatory tables (positions and times) from an external source.
Does it make sense, should it work ?

Thanks
# Posted By Al | 9/9/06 12:28 AM
I'm having this problem at server

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
# Posted By Gilberto | 9/11/06 4:11 AM
Hi, i need to know how can convert Movies (MPEG, avi, wmv) to FLV "ON THE FLY", maybe with PHP... Please it's possible?
# Posted By Santiago | 9/21/06 1:35 AM
Thanks, this is great!

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?
# Posted By josh | 9/22/06 2:46 PM
Josh, I had the same problem in Firefox with the Blaze Beta Debug Player installed instead of WIN 9,0,16,0. You also might want to put a .htaccess file in your html directory with:

AddType video/x-flv .flv
# Posted By Eric | 9/24/06 2:19 AM
FLV streaming video with ASP.NET 2.0 / IIS and HTTP handler

http://blogs.ugidotnet.org/kfra/archive/2006/10/04...
# Posted By Francesco Meani | 10/5/06 12:07 AM
Can this extract the metadata from an FLV file? This is what I'm trying to do in PHP.
# Posted By Tony | 10/15/06 6:52 AM
cool wideo....

;)

oh and nice php too... hahaha
# Posted By little king | 10/19/06 3:28 PM
could anyone help me?

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.
# Posted By yunuen | 10/21/06 6:40 PM
Hello,

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!
# Posted By Jo | 10/24/06 10:00 AM
I've chacked many solutions like this. All of them icluding this one has the problem, that the FLV file is cached on the clientside. What about to somehow encode the FLV and while opening it decode it again. It would be enough to make this for the header. I am really newbie to Flash. What do You think. Is this possible? This would help us much better, becouse even the file is in the hands of the users, they can not play it so easily. With encoding the flash (SWF Encrypt 3.0) it's almoust impossible to decode the video file.
# Posted By Istvan | 11/1/06 5:35 PM
FLV file being cached on the client site may be a feature rather than a 'problem' depending on from where you look at it. You should use a real streaming solution to prevent caching. This solution makes 'progressive download' FLVs seek-able. As for SWF obfuscators, you shouldn't rely on them much, your SWF will be decompile-able sooner or later.

Best regards,
Burak
# Posted By Burak KALAYCI | 11/1/06 5:51 PM
Yes, I know. But as I read at the comments, some of You also search for the way how to hide these files from the users. This is the point in my case also. The seeking is not neccessary for me.

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!
# Posted By Istvan | 11/1/06 8:42 PM
what of obfuscating -> way of obfuscating

:)
# Posted By Istvan | 11/1/06 8:44 PM
hello,
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?
# Posted By pitu | 11/5/06 5:54 PM
concerning the fms2 recorded flv's I found out that they have a different audio & video codec than the golfers.flv used for the exemple.

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...
# Posted By pitu | 11/5/06 9:17 PM
My question is, how can we make this work on HTML and not PHP? also how can we convert avi, mov, and other media files to flv so streaming is possible? might be noob questions, but its for a friend of mine streaming photo shop tutorials on his site and im trying to help http://www.divisionbell.com
any help would be appreciated, thanks

Tim
# Posted By Divisionbell | 11/5/06 11:13 PM
Hi:

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.
# Posted By Vikram | 11/6/06 7:25 PM
i have created a PHP script using the time of server etc to start playing based on the servertime.

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
# Posted By yunuen | 11/6/06 8:21 PM
this may be sloppy but im new to php scripting... or too any for that matter,lol

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";

///
# Posted By yunuen | 11/6/06 8:35 PM
nd then here is the flvprovider.php

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"); }
?>
# Posted By yunuen | 11/6/06 8:44 PM
As I make to extract thumbnail JPG of video FLV to add in my site http://www.ortubes.com
Como fa
# Posted By orTubes | 11/7/06 6:34 PM
gr8 Wrk Dude
# Posted By SAbi | 11/8/06 5:51 AM
Is there a linux-version (or something similar) of Buraks FLVMDI?
# Posted By Simon | 11/15/06 5:35 PM
i have been looking around, i think they questing was asked earlier in this thred but dit not see a reply to it..

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
# Posted By fanno | 11/16/06 3:41 AM
Is it possible to stream flv which is being created live (e.g. from /dev/video0 to stdout via ffmpeg).

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?
# Posted By Uther Pendragon | 11/20/06 4:33 AM
The PHP file seems to be empty. What's up?
# Posted By Darren Spidell | 12/1/06 1:06 PM
try again, teh php file is definitely fine, i just downloaded the zip
# Posted By Stefan | 12/1/06 1:32 PM
hi

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.
# Posted By JS | 12/6/06 5:07 AM
Hi!
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?
# Posted By Sander | 12/10/06 2:22 AM
Hi, I am new to Streaming flv video via PHP. For whatever reason when I move the seek slider to a new position, the player does not move to that position. It sits there... I can only play the video from the start. Can anyone suggest why the seek functionality is not working.
# Posted By Peter G | 12/13/06 4:27 PM
I've got this running beautifully on my site. Is there anyone out there that could add two bits of functionality to my flash player? I will provide the modified source.

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
# Posted By Marc B | 12/15/06 12:47 AM
Hi Marc,

We will try to improve the file. Pls provide us with the source code.
# Posted By pr | 12/15/06 6:30 AM
How can I contact you? I don't see any email address... thanks,

marc
# Posted By Marc B | 12/15/06 7:43 AM
Hi,
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
# Posted By Torsten | 12/17/06 8:12 PM
you need the PHP file from the SWF (flash), not directly from your browser.
# Posted By Stefan | 12/17/06 8:43 PM
sorry that's meant to read:

you need to hit the PHP file from the SWF (flash), not directly from your browser.
# Posted By Stefan | 12/17/06 8:44 PM
I have the player working with my own backend CMS. Only problem is that the scrubbing is not working cause the meta headers are different. I make FLV's in Adobe Premiere (AVI to FLV) Can Someone tell me how to edit the FLV?
# Posted By Vincent | 12/18/06 10:14 PM
I mean how to edit the flvprovider.php so it works?
# Posted By Vincent | 12/18/06 10:15 PM
It works in IE but doesnt in firefox. I changed the scrubit() to the newer one someone posted here.

please check www.ahna.nl/test/
# Posted By Vincent | 12/18/06 11:46 PM
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%.
# Posted By Vincent | 12/19/06 12:20 AM
Hi,

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
# Posted By Tuna Y1lmaz | 12/22/06 1:57 PM
can somebody help me get some output on this matter is it possible to convert any audio/video file to .flv once its get uploaded on server ...is there any PHP script is there ..if yes pls let me know any url or any script which does the same what i wanted ...heres what i want to do

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
# Posted By pankaj | 12/30/06 9:32 AM
Hi,
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?
# Posted By Lars | 1/2/07 9:27 PM
Anyone on a solution for linux-boxes?
# Posted By Lars | 1/3/07 4:10 PM
For the DRM issue:

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.
# Posted By Jie | 1/3/07 5:43 PM
ok, all is working fine now on a different linux machine..
# Posted By Lars | 1/3/07 6:06 PM
hi all.
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.
# Posted By raghu | 1/5/07 7:03 AM
Hi Stefan,

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?
# Posted By Mustafa | 1/5/07 8:33 PM
Has anyone been able to inject or create an external XML files for keyframe metadata on VERY LARGE FILES? ie. files around 1Gb? FLVMDI and FLVTOOL2 cannot do it... and we "stream" large files. Any help or consultants appreciated (we arent stingy, we will pay for people to help us, but we appreciate free advice also ;) ).
# Posted By damian todaro | 1/6/07 9:05 PM
mustafa:
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?
# Posted By Stefan | 1/6/07 9:49 PM
Regarding your large file, do you have one available somewhere for some testing ?
The largest file we successfully injected is currently 700Mo.
# Posted By Chris | 1/6/07 9:50 PM
Hi Stefan,

thank you for your concern. can you show me a sample HTML file too?
# Posted By Mustafa | 1/7/07 3:52 AM
hey guys,

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
# Posted By damian todaro | 1/7/07 10:09 PM
Did anyone solve the problem withe the fifefox stuttering?

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
# Posted By RudiX | 1/9/07 9:28 AM
Hi,

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
# Posted By chobbert | 1/11/07 10:06 PM
Hi all,

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?
# Posted By raghu | 1/12/07 4:59 AM
Hi again,

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
# Posted By Fanno | 1/12/07 4:31 PM
Hi, the sample Works fine.
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?
# Posted By DarthVader | 1/13/07 1:28 PM
Did anyone solve the firefox stuttering problem. I still got it and can't get it too fix. Has it something to do with the headers?
# Posted By Vincent | 1/16/07 8:15 PM
Hello;

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
# Posted By Shaimaa | 1/17/07 12:08 PM
Can try http://ffmpeg.mplayerhq.hu/ for converting. But not manny shared host's have this.
# Posted By Fanno | 1/17/07 3:09 PM
Hi! i love the injector software it<s very cool!

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
# Posted By Frank | 1/17/07 10:41 PM
When running this demo script in Firefox on OS X I am constantly getting - 'NetStream.Buffer.Flush' events from the PHP written FLV. Has anyone else experienced and/or solved this?

Best regards,

Holland Risley
# Posted By Holland Risley | 1/22/07 8:20 AM
A little help would be appreciated.

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!
# Posted By Craig | 1/28/07 2:33 AM
Oh... I forgot to ask... is there anything that needs to be installed other than the three files for this to work?

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?
# Posted By Craig | 1/28/07 2:39 AM
hi guys, solved the firefox stuttering problem. just added the following code to the flvprovider.php file.

header("Content-Length: " . filesize("your FLV file here"));

and it works.

Thanks!
# Posted By Raghu | 1/30/07 1:58 PM
Hi Raghu

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.
# Posted By RudiX | 1/30/07 2:49 PM
In some environments filesize() results in overflow if the FLV file is large.

But hard coding the file size in header function will work.
# Posted By Raghu | 1/31/07 12:35 PM
Is there a way to implement DRM with flv videos?
# Posted By cheap_web_hosting | 2/2/07 1:10 AM
If attempting to seek appears to result in being stuck buffering - depending on your PHP settings, the problem could be caused by a parse error from the shorthand "<?" in the PHP file. Change it to "<?php" and it might fix your problem.
# Posted By Alexi | 2/2/07 6:24 AM
no, flv does *fortunately* NOT support DRM.
# Posted By Stefan | 2/2/07 9:12 AM
hi this is srikanth iam learning php and iam trying to play a video file in my website with php if any one is having the code for that please help me.
# Posted By srikanth | 2/2/07 12:47 PM
Very slick indeed, I think this is similar to what google may be doing as well. When watching video at google video, if you were to add #1m10s("1 minute and 10 seconds") to the end of the url it will jump to 1 minute and 10 secounds into the movie. I am wondering if they are simply adding a new cuepoint every second when they transcode the flv file. Although, I know adding cuepoints also increases the files size.

Does anyone know?
# Posted By crazyred | 2/6/07 9:39 PM
Hi
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
# Posted By Peter | 2/7/07 11:36 PM
As for as my knowledge in ggole they will first upload the video as same as file normal file uploading but when it comes to display the movie in the webiste at that time only they will install some servers with the help of those servers it converts to FLV video. I don't know exactly is it correct or not. if is it correct then i don't know what are servers they required.
# Posted By srikanth | 2/8/07 5:02 AM
How can i determine the current time frame of Influxis flash player and make another script or movie clips perhaps to load?
# Posted By jason | 2/8/07 9:15 AM
Hello

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
# Posted By Peter | 2/8/07 1:10 PM
Gr8 one.. Finding this one very useful.. Thanx a lot.
# Posted By Shyam | 2/12/07 1:43 PM
If your using this method with php sessions, make sure you
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.
# Posted By will griffin | 2/12/07 10:09 PM
I'm considering adding video streaming to my site using php. I came across this great info on the subject. However, I can not get the buffering and scrubbing to work, see example below!

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
# Posted By Thomas | 2/17/07 10:28 PM
I got the link wrong above..sorries.

Here is the correct file
http://www.justquickit.com/video.phtml
# Posted By Thomas | 2/17/07 10:32 PM
I've found the error in my code.

Great stuff Stefan!! Thanks for sharing.

http://www.justquickit.com
# Posted By Thomas | 2/18/07 2:32 PM
I have downloaded the phpstream.zip file with three file....

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..
# Posted By Jignesh | 2/19/07 7:30 AM
I hacked a bit the fla and php files to :
* 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>
# Posted By Ric Flomag | 2/20/07 9:10 PM
Why is it that only your golfers.flv can be parsed using the arrow and my flv gets stuck and only does play and stop ? I use the Riva FLV Encoder to make my flv movies...Which one did you guys use?
# Posted By Sandbird | 2/21/07 3:02 PM
read closely: you need to use flvmdi on your flv to inject the keyframe metadata
# Posted By Stefan | 2/21/07 3:09 PM
You can also use flv4php if you wish to generate metadata for flv runtime(with php).
# Posted By fanno | 2/21/07 10:08 PM
Thanks guys, i'll look into these.
# Posted By Sandbird | 2/22/07 7:45 AM
Great stuff! We've implemented it on our site, http://www.courierwebcasts.com, and it works really well. I tweaked the player a bit, so it has a volume slider, and am passing the video filename through a GET variable in the page call, but everything has been roses since the install.

Thanks again!
# Posted By Lance | 2/28/07 8:16 PM
nice one Lance. Did you use a particular implementation or did you use the files posted on the site (in the post above)?

PS: you may want to hide the buffering message before the user presses play. Nice job.
# Posted By Stefan | 2/28/07 8:37 PM
Thanks for the positive feedback.

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.
# Posted By Lance | 2/28/07 9:46 PM
Lance,
would you mind posting the 'fixed' PHP script somewhere for download?

thanks
# Posted By Stefan | 3/1/07 10:36 AM
The php script has been used with Flowplayer http://flowplayer.sourceforge.net/

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>
# Posted By Rob A | 3/5/07 8:14 PM
Well im new to PHP. Im trying to get the file to play but i cant get the PHP code to work for me. What exactly do i need to do to get the Golf flv file to play.
# Posted By Nathan | 3/8/07 4:35 PM
I keep getting the same buffering problem where the scrubber cannot be moved ahead of the video without getting stuck buffering. I have used flmvdi several times with the /k extension but that did not change anything. I also tried the suggestions posted above but nothing changes the fact that the file get's stuck buffering indefinitely in either i.e. or firefox. Any help would be greatly appreciated.
# Posted By Michael | 3/9/07 7:35 AM
i am trying to make thumnails of video using php but i acn't so if any one can help plz do contact me,,
and i also wants to to play video using applet or flash player in php

so,plzzz help me
# Posted By shrawan adhikari | 3/9/07 12:58 PM
I've gotten everything to work just fine on my LocalHost machine running PHP and IIS. However, on a server running under Linux and Apache, it starts out fine, but when I move the scrubber, it says "Buffering Video" and never stops.

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?
# Posted By krs | 3/15/07 4:16 AM
This is not "Streaming", its "Progessive". nc.connect(null) means you are downloading and playing the FLV. nc.connect(yourserver) means you have software to send packets of FLV at a time.
# Posted By Christian | 3/15/07 11:18 PM
Christian, thanks for stating the obvious...
# Posted By Stefan | 3/16/07 8:30 AM
Yeah sorry, I guess that's why it says "streaming" in quotes. I only retort because I'm having problems with progressive dl and in searching for it I keep hitting threads that throw the terms around loosely.

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)
# Posted By Christian | 3/16/07 9:03 AM
I am using a FLV player now with progressive downloading. This is costing a lot of data traffic. Does implemting this PHP 'fake' streaming method will spare me datatraffic?
# Posted By Vincent | 3/16/07 10:51 AM
Vincent,
no it most likely will not.
# Posted By Stefan | 3/16/07 11:07 AM
Is this possible to achieve? IE: To only download a limited amount in the buffer ahead!
# Posted By Vincent | 3/16/07 3:05 PM
i wannt to have a applet to play video.could anyone help me how to make thumnails of an mpg using phpo script
# Posted By shrawan | 3/17/07 9:55 AM
Hi guys,
can someone spare a moment and write a short readme file for those of us who are newbees ?
Thanks a million
# Posted By Jeniffer | 3/18/07 5:20 PM
I concur with Jennifer. I'm a total newbie and cannot figure out how to make this thing work. I keep getting the error that it cannot find the file. I know this is because I don't know where to put the filename in the php file. I'm a video editor by trade.
# Posted By Heather | 3/18/07 6:31 PM
thumbnails with ffmpeg(-php)
# Posted By Vincent | 3/19/07 10:28 AM
Hi Christian,
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
# Posted By Raghu | 3/20/07 5:25 AM
flash 101 - what can I do with the .fla file ? must I have a proprietary sofwate for that?
# Posted By Gizzy | 3/20/07 9:21 AM
@Gizzy

Yes u need Macromedia Flash
# Posted By Vincent | 3/20/07 8:28 PM
I still can't get this to work.

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?
# Posted By mike | 3/21/07 11:35 PM
ok, I got it to play, but it won't seek
# Posted By mike | 3/22/07 12:03 AM
You my man are a genius. I implemented your idea to get a proxy working that could actually play youtube videos through a proxy. My school recently blocked youtube and now everyone uses my proxy. Even teachers!
# Posted By Mike M. | 3/23/07 1:16 AM
lol how cool, always glad to hear about real life experiences and use cases :-)
# Posted By Stefan | 3/23/07 8:27 AM
can anybody help me in making thumnail frm video via php.
Olso can anybody have the youtube clone plz if forward to me.
# Posted By shrawan | 3/24/07 7:44 AM
I am trying your flv player and the buffer does jump to work ahead any ideas. Here is the link.

http://doublewingsymposium.com/scrubber.html
# Posted By rob | 3/31/07 7:33 AM
ASP version again - are there anybody out there who have made the asp version of flvprovider.php.
I have a project where they don't use php on the server.

URGENT!!!!
# Posted By PRIX | 3/31/07 7:44 PM
check the comments, someoen made a .Net version
# Posted By Stefan | 3/31/07 8:21 PM
ASP (classic) - a script that functions like the flvprovider.php
Anyone who knows if it's possible to do ???
# Posted By PRIX | 4/1/07 12:12 AM
Prix!! I can do it.
Speak to me.
Regards,
# Posted By Shmai | 4/1/07 11:53 PM
Hi All,
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
# Posted By Rick78 | 4/10/07 1:09 PM
nothing
# Posted By scuty | 4/10/07 8:26 PM
is not working for me ether! it doesn't find the file! does anyone find any solution to this?
# Posted By scuty | 4/10/07 8:28 PM
Hi Again,
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
# Posted By Rick78 | 4/10/07 9:20 PM
Hi,

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
# Posted By shelley | 4/16/07 4:29 AM
Hi,
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.
# Posted By shelley | 4/16/07 5:45 AM
Hi,

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.
# Posted By Shelley | 4/16/07 5:51 AM
if(ns.bytesLoaded / ns.bytesTotal == 1) {
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.
# Posted By Agent-E | 4/16/07 1:37 PM
I have written a ISAPI extension that replaces the need for the php file. this means if your server supports ISAPI this should work for you. and in theory much faster.

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
# Posted By JBoi | 4/16/07 11:32 PM
@ JBoi

Yes, I would be very interested in a ISAPI extension. Is there something you could share here?
# Posted By Agent-E | 4/17/07 7:23 AM
I'm also interested. Could this be configured per website or only server wide?
# Posted By Stefan | 4/17/07 8:35 AM
@ Agent-E & Stefan,

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
# Posted By JBoi | 4/17/07 9:13 AM
I guess configuration would be fairly easy, I don't think I'd need a special tool for that. As far as license goes, please try and make it freeware and ask people to give credit if possible. I find this pays in the long run.
# Posted By Stefan | 4/17/07 9:20 AM
Hi Again,

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;
# Posted By Rick78 | 4/17/07 11:18 AM
Stefan & Agent-E

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
# Posted By JBoi | 4/17/07 12:25 PM
@ 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
# Posted By Agent-E | 4/17/07 7:06 PM
@ Agent-E

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
# Posted By JBoi | 4/17/07 8:32 PM
Thanx JBoi... but i was talking about the ISAPI extension itself, not the flash code :)
# Posted By Agent-E | 4/17/07 9:13 PM
Agent-E, my bad, i assumed you meant the flash. :S

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
# Posted By JBoi | 4/17/07 9:59 PM
I have the same problem demiguru reported way back. Vidoe plays but I can't seek the video - "Buffering Video" message flashes and video stops. I'm using IIS on my own machine with PHP installed, have set the .flv path in flvprovider.php to the correct directory. I'm using the golfer.flv from the example.
# Posted By tfair | 4/23/07 5:35 PM
Hello,

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.
# Posted By netbouy | 4/25/07 12:30 PM
did you give your FLV the treatment of FLVMDI? Check the post for details... I've added some more info and a link to another one of my posts. You need to inject the keyframe metadata or the PHP seeking won't work.
# Posted By Stefan | 4/25/07 12:44 PM
hallo stefan.

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?
# Posted By netbouy | 4/25/07 12:55 PM
did you change the reference to golfers in your FLA/SWF?
# Posted By Stefan | 4/25/07 1:26 PM
hi there Stefan,

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.
# Posted By netbouy | 4/25/07 2:38 PM
i think this fread stuff has come up before - I am not sure which setting is ideal here or why - maybe someone else can advise.
# Posted By Stefan | 4/25/07 2:44 PM
Hi there,

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!
# Posted By Remy | 4/26/07 10:44 AM
Wondering if there is any answer to the problem I posted April 23rd. Problem was: the golfer.flv does not search once I move the playhead -- video stops and "Buffering Video" message flashes but that's all.
# Posted By tfair | 4/30/07 5:48 PM
Has anyone come up with a solution to prevent FLVs from caching on the users computer? Or at least making it more difficult to get the FLV once it has been cached..

I've looked around quite a bit, some developers say they have a solution, uptill now I have found none that actually work..
# Posted By Agent-E | 5/2/07 12:59 PM
Does anybody know how to make the flv loads a swf file after play all the way.
# Posted By Juliano | 5/19/07 10:36 PM
"prevent FLVs from caching on the users computer?"

Have you tried adding something like "r="+random(999) to your flv string (ex http://something.com/golfer.flv?r="+random(99...
# Posted By book | 5/29/07 2:46 PM
MY flv (big size) still not working. Which encoder do you use to convert avi to flv?

Thanks
# Posted By Eugene | 5/29/07 3:02 PM
did you run flvmdi to insert your keyframe attributes to the flv?
# Posted By book | 5/29/07 3:07 PM
Anybody....Anybody could explain me how did they make sites like.

http://www.aeon.jp/biz/

A FLV loads a swf??
When you click at the buttons loads another flv...

Does anybody know??
# Posted By Juliano | 5/29/07 4:13 PM
Hello i just get a: ERORR: The file does not exist

$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#
# Posted By Lars | 6/1/07 9:46 AM
Hi,
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
# Posted By shelley | 6/3/07 3:06 PM
I was wondering if anyone has gotten this approach to work with an FLVPlayback component in AS3?
# Posted By Nicolas Elizaga | 6/3/07 4:53 PM
It would like to mount an equal site to orTubes (http://www.ortubes.com), that works with videos in FLV and flash, but I do not know for where to start. If somebody to know where I acquire applicatory informs me please. Grateful.
# Posted By Katia Kamiko | 6/7/07 4:23 PM
When i downloaded this code and make run in my local system, but i can see this sort of junk output in my explorer.
# Posted By Qurban Ali | 6/8/07 8:23 AM
is there a possibility or has anyone done this.

can i scrub the flv on server using php, whitout sending get request from client swf?

thanks,

// chall3ng3r //
# Posted By chall3ng3r | 6/10/07 10:10 PM
Hi Katia Kamiko,

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
# Posted By Shelley | 6/12/07 5:13 AM
ok, it's work fine, but, how can i change videos... in action script, there is var var _vidName = "golfers.flv";

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 :)
# Posted By bXa | 6/15/07 1:45 PM
I've tried every possible path with my Unix server, and I still get the file not found error. Are there any *nix users that have gotten this to work that can tell me what they put as the path? I'm flabbergasted.
# Posted By tony | 6/20/07 1:46 AM
Why is it necessary to modify the source .flv? Is it enough to identify key frames without tagging them, output the appropriate offsets and use the PHP to generate the appropriate header, perform the seek to the appropriate offset and dump the file to the connection?

Is there a way to make flvmdi output offsets of the key frames in the unmodified source?
# Posted By David Harrison | 6/20/07 6:43 AM
Great work! But how can we add a timer? I mean, to show how many minutes:seconds the clip has and how many are left? I've see that guy at rich-media-project did it.
# Posted By just_me | 6/21/07 3:42 PM
Hello,
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!
# Posted By BORAT | 7/2/07 9:01 PM
There is an apache 2.2 module replacing flvprovider.php at http://journal.paul.querna.org/articles/2006/07/11...
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
# Posted By lazycat | 7/3/07 2:12 PM
Does anyone have a working java/jsp version? I attempted to port this php version to Java but it failed when it comes to seeking. The failure is due to incorrect header writing because if I always set the position at 0, everything works fine. I've read the FLA file spec and tried to follow it. I've also read the red5 source code. But couldn't get it to work. I have my source code attached. The current version attempts to read the header from the original file (the first 9 bytes). Any advice is greatly appreciated.

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();
         }
      }
   }
}
# Posted By Xia Tian | 7/19/07 2:07 PM
Just found a solution myself by following the link in your article to Steve Savage's Coldfusion port. The trick is to write the following to the outputStream.

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.
# Posted By Xia Tian | 7/19/07 2:27 PM
In the comments, several people posted questions or solutions to the problem of passing in the name or identifier of the file to be played into the swf file. Unfortunately, the source code link in Ric Flomag's post is invalid now. I would be very much interested in knowing how in the swf, therefore, the action script, we can get hold of the file name. I'm clear on how in the html, we can use query parameter or FlashVars, but couldn't get the whole think to work. Thanks in advance for any advice.
# Posted By Xia Tian | 7/19/07 6:42 PM
yes Flashvars is the way to go. All variables passed to the SWF that way are accessible in Actionscript on _root.
# Posted By Stefan | 7/19/07 10:25 PM
My question is, im looking for a flash script that has roll overs like http://www.softe.org see the buttons above, where you mouse over something happens and on mouse out goes back to norman, what is this called? Thanks
# Posted By Free Spyware Software | 7/21/07 11:33 PM
Aside from installing PHP with IIS, are there comparable methods/program for MS IIS server?
# Posted By Bonal | 7/23/07 6:43 PM
I have made a modified version of this player that works very well. I changed the player to read a xml file that is built dinamicly on a php script and this xml loads the file to play. On the file that generates the xml I'm checking if the position is passed. In that case it will use the current php script of the package for loading the video. For loading the player and the script at same time I'm using a javascript that passes the xml path as parameter to the flash video player and can change the size of the player on the fly. The javascript is the ufo.js that you can find on the web.
# Posted By Cristiano | 7/25/07 9:52 PM
christiano, can you share your version?
# Posted By Stefan | 7/26/07 8:41 AM
Bonal, yes there are other methods. I use an ISAPI Extension that i built. I find this to be very fast, in fact faster than php and asp versions as it does not have to be interpreted first, just solid native compiled.

:D
# Posted By JBoi | 7/26/07 9:40 AM
Is it possible for someone to post an fla that'll open in MX 2004? Thanks!
# Posted By Bob | 7/29/07 1:58 PM
Never mind. I found it on another page. Here's the link for the MX 2004 version:
www.flashcomguru.com/downloads/scrubber.zip
# Posted By Bob | 7/30/07 2:27 PM
Found a "solution" to the "slow page response when loading large FLV" problem.

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.
# Posted By Christian / Jon | 7/30/07 6:31 PM
To Christian / Jon:

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...
# Posted By Tersis | 8/2/07 3:46 PM
note that I have just posted a new article with some new info:
http://www.flashcomguru.com/index.cfm/2007/8/14/ph...
# Posted By Stefan | 8/14/07 3:46 PM
Wonderfull! Many thanks and good luck for you!
# Posted By Nelson Reis | 8/28/07 4:38 AM
the updates sources by xmoov.com are now available at
http://flashcomguru.com/downloads/phpstream_update...
# Posted By Stefan | 9/3/07 10:21 AM
I have made a player at www.braintv.ro which uses this technique. Check it out. I made it capable of seeking to parts of movie which are already loaded. Easy actually. Thanks for this mini tut. It was extremely helpful.
# Posted By Mocanu Ciprian | 9/7/07 8:50 AM
It's more than great!!
God knows how long i been looking for the page.
# Posted By Igor | 9/14/07 7:29 AM
Is it possible to get this script in Perl ? I am not a perl freak but I need it in Perl for someone!
# Posted By askingForPerl | 9/16/07 8:33 PM
Tinic Uro a.k.a. Kourantin (an Adobe flash engineer) haas posted information about the latest Flash 9 player with mov/mpeg4/h264/3gp support
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
# Posted By Sandro Bilbeisi | 9/18/07 9:09 PM
I'm new in php but need to build an php project on video streaming and happy to find this page. But somehow, i dunno why it doesn't work for me even i try to stram ther 'golfers.flv'. I have change the path to
"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.
# Posted By melanie | 9/19/07 9:56 AM
Hello is it possible to get the flv-File out of a Database?
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
# Posted By Michael | 9/26/07 1:23 PM
hi,
could php streaming be used by the flex videoDisplay component? if so, does anyone have a sample?
# Posted By Sal | 9/27/07 5:43 PM
In the future its got to get easier to stream flash videos. I wonder how you could use this to develop a video podcast
# Posted By Drupal | 9/28/07 12:35 AM
Ofcourse websites in future will tend to use php flv streaming. Even large videos can also be streamed in this manner. For example... rest is comment spam
# Posted By Hayden | 9/29/07 5:44 PM
ok enough is enough. If you post one more link to this site I'll have to take action. What you are doing here is comment spam.
# Posted By Stefan | 9/30/07 7:22 PM
i'd like to play some flv video in a frame, but when i put in the dir phpstream some flv files the script will answer with : NO videos in dir ... how can i bypass this problem ?!
# Posted By Pawel | 10/2/07 1:30 PM
Hi Stefan

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
# Posted By Jarrod | 10/8/07 8:03 AM
If one does not add the Content-Length header to the output from the .php file the bytesLoaded and bytesTotal inside the Flash Application will not work properly!

header("Content-Length: " . filesize("your FLV file here"));
# Posted By Naicu octavian | 10/8/07 3:12 PM
I fill the path, it should be good
$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
# Posted By howah | 10/9/07 8:22 AM
I fill the path, it should be good
$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
# Posted By howah | 10/9/07 8:23 AM
I am new to php.
I want to make small apllication of showing video.
can anyone give me detail instruction how to do this ? (or how to configure code.)
# Posted By sachin | 10/18/07 7:39 AM
This a a very interesting article. Some very valuable information is available her for some quick fixes to our regular processes
# Posted By Syed Nazir Razik | 10/18/07 1:16 PM
We've updated the player on our site again (http://www.courierwebcasts.com See orig. post from 2/28/07). Added playtime/duration, improved volume bar, got rid of the load bar (since as Stefan pointed out, there's not much need for one), and made it so if a user is scrubbing to a cached position of the video, the player will seek without calling flvprovider.php. Total filesize of swf: 9K. Let me know what you think; I can make source .fla available if anyone wants it.
# Posted By Lance | 10/25/07 3:26 PM
nice job, would you mind sending me a copy of the player? stefan AT flashcomguru.com
# Posted By Stefan | 10/25/07 3:32 PM
Excellent work with the player Lance. I'd love to check out the .fla file if I could
# Posted By Dennis Plucinik | 11/8/07 4:54 PM
hi, why the video is not played?
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.
# Posted By kk | 11/9/07 6:46 AM
Lance, it looks great and works very smoothly. I would love to see that fla as well!
# Posted By Evan | 11/19/07 8:18 PM
Thanks for all the kind words on the player. To anyone who wants it, you can download the CourierWebcasts.com vid player from:

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.
# Posted By Lance | 11/19/07 8:34 PM
Hi Lance - thank you for the amazing code - one question though - what is the flvprovider.php file for and where does it come from?
# Posted By Dan | 12/4/07 4:18 PM
That's the file that makes the whole thing work (and what this article is about). It essentially lets a user scrub to a point in the video that hasn't been downloaded to their computer yet. Basically a way to "stream" flash video on the cheap. flvprovider.php can be found by downloading the source files at the top of this page. Read the article and comment thread to make sure you're using it properly.
# Posted By Lance | 12/4/07 4:46 PM
Thanks Lance - that was a silly question and I appreciate your response.

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.
# Posted By Dan | 12/4/07 4:51 PM
Essentially, just put ?vidName=YourFLV.flv after the call to the flash on the page. I've included sample code below. You may need to change it a bit to match the location of your swf and the way you're putting the swf on the page. This method uses AC_FL_RunContent function that is generated when putting an swf on the page with Dreamweaver CS3. That gets rid of the annoying "Click to activate and use this control" ring around swfs in IE.

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>
# Posted By Lance | 12/4/07 5:02 PM
Sorry, should have broken up the lines a bit so the page doesn't vomit outside the margins.
# Posted By Lance | 12/4/07 5:03 PM
Thanks Lance - I feel that I am close to joy here...

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.
# Posted By Dan | 12/4/07 5:59 PM
Dan,

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.
# Posted By Lance | 12/5/07 4:53 PM
Posted By shelley | 6/3/07 3:06 PM

"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 ?
# Posted By tulip | 12/6/07 9:48 AM
I've got this script all working, but with a custom SWF and custom Skin for the SWF. One thing that I've noticed is that with a large FLV the swf starts loading the video when the page loads, that's normally fine except that when you click on a link on the page with the video the browser waits to finish loading the video before it will allow you to navigate away from the page.

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.
# Posted By Clayton | 12/8/07 5:20 AM
Hello Lance:
Did I can help in creating a list XML to choose videos?
Regard Tommy
# Posted By Tommy | 12/10/07 3:47 PM
Greets,
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
# Posted By Christofle | 12/11/07 1:18 AM
Hi All, thanks for all of your comments I was able to implement your ideas. But only one thing more I need to rock.

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
# Posted By Jonathan | 12/11/07 3:53 PM
How does one pass parameters to the server from the script above ? The flash component can't take a url to an flv file and put parameters such as ?file=whatever

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?
# Posted By Alex Wallace | 12/20/07 7:45 PM
could you help me implementing a timer into this flv?
# Posted By meshkowich | 12/22/07 3:41 PM
thanks for it . its really good
# Posted By software download | 1/3/08 11:13 PM
hallo,
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
# Posted By elbepower | 1/9/08 7:50 PM
Wann du wirklich mit Flash oder PHP arbeiten wollte soll man vielleicht besser zum ersten die Englische sprache lernen.

Everything you need is right here on this page!!
# Posted By LJ | 1/10/08 8:36 AM
I try to do this in Java. I dont know to translat function pack() in java.

Someone could help me ?

Thanks.
# Posted By Nicolas | 1/10/08 12:58 PM
the java code pasted above pretty much worked... why not try that?
# Posted By Alex Wallace | 1/10/08 7:23 PM
werden noch mehr dateien als flvprovider.php
scrubber.fla und der videodatei an sich ben
# Posted By elbepower | 1/10/08 10:58 PM
could it be posible to perform the keyframe-timestamp search all in php? that could allow us to not depend on flvmdi.
# Posted By Genaro Rocha | 1/11/08 2:29 AM
I pseudo-solution for my problem follows my inquiry.

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.
# Posted By naglma | 1/17/08 12:44 AM
LINK PROBLEM SOLUTION

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
# Posted By naglma | 1/17/08 1:04 AM
http://www.learnerstv.com is an excellent implementation of php flv streaming
# Posted By Jane | 1/17/08 7:25 AM
Everything seems ok but i do not know how to implement all the stuff and how to use this php file for streaming. Can anyone please send the documentation to integrate php file, fla and flv file? Any help will be appriciable.
# Posted By Andrew Brook | 1/17/08 12:46 PM
Question: How can we do to use the same process with flv audio stream (flv without video) because flvtool2 don't insert keyframes times<->position in the FLV metadata header. Any idea ??
# Posted By ETIENNE | 1/17/08 1:38 PM
I have a question. I want to make flv load automatically ( I mean the first still of a film). How can I do it?
# Posted By Marc | 1/20/08 12:49 PM
Hai.
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.
# Posted By logicmania | 1/23/08 3:46 PM
Great work!! If you need a flex sample, check out my article: http://labs.flexcoders.nl/2008/01/28/flex-sample-s...
# Posted By Maikel Sibbald | 1/29/08 6:22 AM
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 Oyun indir | 2/8/08 8:04 PM
Hie
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
# Posted By atifah | 2/11/08 8:13 AM
I made similar code.
Added milisecond position seek, and cache future.

http://www.guarana.cc/kent/streamSource.php?v=0.4
# Posted By kent | 2/19/08 5:54 PM
very cool, thanks for sharing it
# Posted By Stefan | 2/19/08 7:33 PM
We are really impressed with the power and ease of xmoov-php and we are thinking about incorporating it into our Flex application.
--
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
# Posted By ArtKohn | 2/20/08 1:25 AM
hi, I wrote a simple manual for the script above.

http://d.hatena.ne.jp/kent013/20080224/1203827752
# Posted By kent013 | 2/24/08 4:47 AM
omg you are a genius!
# Posted By Rob | 2/26/08 5:05 PM
Actually, we're using this method at http://www.moovie.ru for few months :) You can check it. There are 7 minutes of all movies free for preview :)
# Posted By Sergei | 3/1/08 9:49 PM
Not only does max script in php.ini need to change, but also max input time, and max execution time.

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
# Posted By Geoff | 3/7/08 6:55 PM
Hi,
Can any body help me to know that
how will u find a video is streaming or not using PERL please......
# Posted By shekar | 3/12/08 1:20 PM
Is there a way (/workaround) of passing a URL instead of a local file path? The problem is that we're using Amazon S3 for our media storage and have our php files on our own server since S3 doesn't run php.

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?
# Posted By Marc | 3/14/08 3:43 PM
Hi,

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
# Posted By Vinay | 3/15/08 4:02 AM
Oh.. there is a mistake in the previous posting.. the url generated is http://127.0.0.1/folder/flvprovider.php?file=movie...

Any help would be greatly appreciated.

Thanks,
-Vinay
# Posted By Vinay | 3/15/08 4:33 PM
Hi,

There are bugs when you set the autostart to false.

The seek bar just looks very weird when the autostart is false.
# Posted By billh | 3/16/08 5:04 AM
I am worried. I have heard it said that Xmoov is not a viable solution for larger scale delivery because it puts too big of a stress on server resources. Specifically, with each call Xmoov reserves an apache/php process during the entire time the video is playing. Furthermore, I hear that apache is set by default to handle a maximum of 256 concurrent clients.
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?
# Posted By ArtKohn | 3/17/08 4:29 AM
I was wondering if someone could post an example of what their code looks like after they have successfully implemented this method.
# Posted By Kevon | 3/20/08 3:32 PM
If another video is replaced instead of
"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
# Posted By vimal | 3/27/08 6:13 AM
Does anybody know how to add metadata to .flv file with script? I'm not interested in using already created programs
# Posted By Vova | 4/18/08 1:38 PM
Hello,

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.
# Posted By Nejd | 4/22/08 4:22 PM
Awesome job. However, I also have scalability concerns with this. I noticed in firebug that each time you move the file progress indicator that a new file is pulled down from the server.

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.
# Posted By Andy | 4/22/08 10:17 PM
Thanx Nejd
For the how to
# Posted By JOKERz | 4/23/08 4:17 PM
Hi, I'm new in the field of streaming. I've downloaded the code "phpstream_update.zip" and unzip and upload these files on the server. but when I open the xmoov.php page it shows nothing. do i need to place any other flash object to the page (in javascript)? or something else need to be done. Pease help
# Posted By Murtaza | 4/25/08 12:15 AM
This is my first attempt to stream a flv file from my Apache Server running on Windows XP SP2.

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?
# Posted By Rich Kurtz | 4/28/08 8:41 PM
No.No!

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 !!)
# Posted By Sandro Bilbeisi | 4/28/08 9:14 PM
Thanks you Sandra, for the info and for not making me feel too bad. As I said, this is all very new to me. Where can I find an example of what the html should look likt then. I'm guessing it will need something like:

<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?
# Posted By Rich Kurtz | 4/28/08 11:05 PM
Sandro, sorry for the typo in my previous post.

I have it streaming to an external FLV viewer but I can't make it work inside the browser.
# Posted By Rich Kurtz | 4/29/08 3:51 AM
@Rich Kurtz:
could you please post a URL to examine ?
# Posted By Sandro Bilbeisi | 5/2/08 2:29 PM
Does this work with SWF videos too? I'm going to try it.
# Posted By Cyllya | 5/5/08 7:40 PM
'Streaming' flv video via PHP, take two
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
# Posted By dizi izle | 5/18/08 7:40 PM
I've chacked many solutions like this. All of them icluding this one has the problem, that the FLV file is cached on the clientside. What about to somehow encode the FLV and while opening it decode it again. It would be enough to make this for the header. I am really newbie to Flash. What do You think. Is this possible? This would help us much better, becouse even the file is in the hands of the users, they can not play it so easily. With encoding the flash (SWF Encrypt 3.0) it's almoust impossible to decode the video file.
# Posted By dizi izle | 5/18/08 7:44 PM
Can some explain, why I need to declare this when pos >0? Wouldn't this print out html\text headers instead for flash headers? I am a newbie, please advice.

if($pos > 0) {
print("FLV");
print(pack('C',1));
print(pack('C',1));
print(pack('N',9));
print(pack('N',9));
}
# Posted By ldang | 5/22/08 4:12 AM
I'd really appreciate if someone could post a simple example of entire html page that includes php code and everything else needed.

Thanks,
Dmitry
# Posted By Dmitry | 5/27/08 3:18 PM
hi again, its been a while since i last posted. I talked about an ISAPI solution instead of php.

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...
# Posted By Jboi | 5/28/08 12:27 PM
oh just to clarify, the isapi solution does not require you to have any scripting knowledge at all, so another bonus! just point your video player and go.
# Posted By Jboi | 5/28/08 12:31 PM
here we go

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
# Posted By val | 5/30/08 9:14 PM
here we go

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
# Posted By val | 5/30/08 9:14 PM
Hi, It`s really a great Idea to stream video with php. But I struggle with this stuff now for some days - and can`t get it fly.
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
# Posted By splatt | 6/1/08 2:07 PM
Hey, thats great. youre awesome.
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
# Posted By Aeon Aries | 6/5/08 6:10 AM
What are/is the advantage/s of this over the regular flash streaming?
# Posted By Alfie | 6/7/08 9:25 AM
the advantage is that you do not need a streaming server
# Posted By Stefan Richter | 6/7/08 10:13 AM
Hi again, is there an read me for this out there? I haven't got it until now - despite all these comments here...

splatt
# Posted By splatt | 6/8/08 3:42 PM
to val,

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. :)
# Posted By Jboi | 6/13/08 12:43 AM
Hi

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!
# Posted By zsoli | 6/14/08 2:03 AM
zsoli, you dont need to know flash to do this.. just download the player from here and away you go. there is no need to code anything for this.
# Posted By Jboi | 6/14/08 9:03 AM
Has anyone addedd a fullscreen mode to this scrubber? cheers
# Posted By Jboi | 6/16/08 4:17 PM
Hi,

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
# Posted By SanjayG | 6/18/08 12:49 PM
SanjayG, which advice did you follwo exactly?
# Posted By Jboi | 6/18/08 12:53 PM
Thanks Jboi for taking this into consideration.

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
# Posted By SanjayG | 6/19/08 9:45 AM
Hi 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 :)
# Posted By Jboi | 6/19/08 10:17 AM
I modified your PHP flv streamer.
I just noticed your post is 2005 so maybe you did too since then :)
# Posted By maht | 6/26/08 9:21 PM
thanks for posting maht.
I see you're in Nottingham - I live just outside Leicester.

Could you drop me an email please: stefan AT flashcomguru DOT com

thanks
# Posted By Stefan Richter | 6/26/08 10:42 PM
i have been trying to get phpstream_update to work with no luck i had changed a few params in the php file i.e. the server root etc and keep getting this msg "ERROR: xmoov-php could not find (golfers.flv) please check your settings." (http://127.0.0.1/phpstream_update/video/golfers.fl...)
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
# Posted By olly | 7/12/08 9:35 PM
i have been trying to get phpstream_update to work with no luck i had changed a few params in the php file i.e. the server root etc and keep getting this msg "ERROR: xmoov-php could not find (golfers.flv) please check your settings." (http://127.0.0.1/phpstream_update/video/golfers.fl...)
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
# Posted By olly | 7/12/08 9:41 PM
@Oly, the easiest way to do this is grab a copy of myflv from www.mediamodus.com wack it on your server then just call the flv file, job done. :)
# Posted By JBoi | 7/12/08 9:45 PM
yeah that method does look nice but you need this:
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
# Posted By olly | 7/12/08 9:59 PM
This script is awesome, it is simple, short and amazingly useful. Thanks to all of whom were able to do this
# Posted By Guillermo | 8/21/08 1:32 AM
hi, pls help the noobie.. it does not play in my server. it just simply says ERORR: The file does not exist. i have already changed the path to $path="/var/www/phpstream"; which is golfers.flv is located..
# Posted By dustro | 8/22/08 7:50 AM
I'm using the xmoov php flv streaming script with 768kb/s movies but when the movie is playing and i click on a link without stopping the movie first. The page keeps on loading and loading. Only when i hit the stop button i will go to te next page.

Does anyone have a solution for this problem?
# Posted By Ronnie | 8/30/08 12:23 AM
Problem solved:

If you open a session before you output the flv, then make sure you close it before outputting the video.

session_write_close();
# Posted By Ronnie | 8/30/08 1:00 AM
I managed to port the code to work on Ruby on Rails. Any feedback is appreciated. You can find it <a href="http://faisaldajani.blogspot.com/2008/09/flash-str...">here</a>
# Posted By Al-Faisal El-Dajani | 9/1/08 9:05 AM
$url = ''; //Url flv
header ("Content-transfer-encoding: binary");
header ("Content-Type: video/flv");
header("Content-Disposition: attachment; filename=video.flv");
@readfile($url);
# Posted By wallpaper | 9/1/08 6:15 PM
I'm sorry, but I don't get the point: Is this tool for using on a standard webspace with support of php & co, or I need a special red5 / adobe streaming server?
Thanks for your answer.
# Posted By Gregor | 9/12/08 11:49 AM
Does anyone know about same MetaData injection tools or something like this, but written in PHP or Perl?

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?
# Posted By anonymous | 9/15/08 5:08 PM
Does anyone know about same MetaData injection tools or something like this, but written in PHP or Perl?

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?
# Posted By anonymous | 9/15/08 5:09 PM
Hello,
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
# Posted By Leo | 11/7/08 3:32 AM
Hello Friends,
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
# Posted By reshma | 11/12/08 9:29 PM
hi,
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...
# Posted By flashObj | 11/17/08 5:47 AM
@ reshma, the right click menu is specified in the fla file itself. go into it and edit the actionscript.

@flashObj, you need to inject the keyframes first for it to work, read closely :)
# Posted By Tony | 11/28/08 2:54 AM
hi tony i already injected metadata in the flv i want to know what config i need to in server
# Posted By flashObj | 11/28/08 7:01 AM
need help, try to watch video from website but always prompted "videostream not found:flv"
# Posted By blindman | 1/16/09 12:05 PM
@ blindman

what site?

The message suggests to me that the flv file is 404'd.. check your paths
# Posted By Jason | 1/16/09 12:32 PM
How long would you estimate that it would take to implement the following using php:

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.
# Posted By Rita | 1/16/09 2:34 PM
hello there

I still have problem with the path.
Can someone show me example??
plss

thx
# Posted By one | 2/7/09 5:16 PM
I am having a few issues, I hope someone can help...?

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!
# Posted By karossii | 2/26/09 8:12 AM
Hi, I am having a few issues integrating this streaming player into a flash site. I have added all of the components of the player into a flash based website, and it works fine - other than two issues.


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");
}
# Posted By karossii | 3/2/09 9:25 PM
Hi,

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
# Posted By santosh | 3/6/09 6:49 AM
Hi Santosh,

Can you explain me whats your problem to my mail id udhaya0000@gmail.com.
# Posted By flashObj | 3/6/09 7:02 AM
Hi karossii,

i think i can help you in this problem you can mail me your problem to my mail id udhaya0000@gmail.com
# Posted By flashObj | 3/6/09 7:06 AM
Thank you, I am mailing you now.
# Posted By karossii | 3/6/09 7:24 AM
Hi udhaya
i sended to ur email id. plz find out..
# Posted By Santosh | 3/6/09 8:15 AM
I used xmoov.php to achieve streaming.

[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.
# Posted By venukumar | 3/12/09 2:04 PM
The example doesent even work?
# Posted By Jakob | 4/14/09 2:09 AM
Thanks, demo is now fixed (PHP was throwing an error after I moved servers).
# Posted By Stefan Richter | 4/14/09 9:09 AM
For the life of me, I just can't get this to work. Instead of making the filename a parameter I just hard code it in my php script in the same folder as the php script:

$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.
# Posted By Brian Lorraine | 4/22/09 8:53 PM
I answered my own question. There were two problems I had with the JW player.

#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...
# Posted By Brian Lorraine | 4/22/09 11:00 PM
Hey can any one help me how syndicate videos with ads in php . ???
# Posted By Usama Ayaz | 4/23/09 2:40 PM
It's official. there is no way to keep it from caching. I've tried everything including adding it to the header, but it STILL caches no matter what.

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
# Posted By Brian Lorraine | 4/24/09 6:48 PM
@Brian Lorraine

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
# Posted By Jason | 4/24/09 8:13 PM
Right what walked looking for. Thousand thanks for the contribution
# Posted By diseƱo web | 4/28/09 3:56 AM
I did enjoy it. Great post. Love all the information you provided.

http://www.aboutspywareremoval.com
# Posted By colx | 5/24/09 12:33 PM
Hi,

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.
# Posted By Raed Petro | 5/27/09 10:01 PM
@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.
# Posted By Jason | 5/28/09 10:33 AM
Hi Jason,

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.
# Posted By Raed Petro | 5/28/09 11:17 AM
@Raed

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?
# Posted By Jason | 5/28/09 11:21 AM
I think the player will play the output file regardless the metadata in it. I thought of this cause in the PHP code it is print("FLV"); print(pack('C', 1 )); ... etc (which I think it is just a fake header) then seeking the FIRST file from the middle via $seekat1 (this means it skipped the metadata of the FIRST file) and yet still the player can play this part of the FIRST file.
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 :-)
# Posted By Raed Petro | 5/28/09 12:08 PM
I cant see where you are removing the metadata from the first file. test the theory by saving the FLV file back to disk after you have modified.. then open in a meta editor such as http://moo.to/MTI1MA

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 ?
# Posted By Jason | 5/28/09 12:16 PM
Yes the metadata exists in the output file .. I tested it using the meta editor in your link.

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.
# Posted By Raed Petro | 5/28/09 11:19 PM
hi Raed Petro,
can you post your final code please to get this to work?
# Posted By Stefan Richter | 5/29/09 9:01 AM
hey!!


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!!
# Posted By barot | 6/12/09 12:46 PM
hey!!


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!!
# Posted By barot | 6/12/09 12:49 PM
Flashon.nl gives you red5 hosting.....
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)
# Posted By Jochum | 6/20/09 8:50 PM