If you are playing long videos – like more than 20 minutes or so – using xmoov.php then you may notice a small problem, such as the videos not playing. If so then the solution is very simple. You just need to increase the amount of memory that PHP can access.
I’m using WAMP and by default the PHP.ini file gives it 128MB to work with. I upped that to 1028MB and now I can play videos that are in the 90 minute range.
In WAMP you can change the memory limit by opening the PHP.ini file – locate it by clicking on the WAMP server icon in the system tray -> PHP -> php.ini.
Now search for “memory_limit”. Change the max amount of memory a script my consume and you should be good to go.
Addendum
In the comments below a user – Mike – suggested that the problem lies with the last line of code in the xmoov.php file.
print(fread($fh, filesize($file)));
change it to something like:
print(fread($fh, 8192));
That could help as well.





Is that really feasible on a production server with a reasonable amount of hits?
@cosmin, I have no idea. But if you have long videos, and you're using xmoov then you don't have many options. But it's certainly something to think about if you're business is thinking about using xmoov. I'd research how well xmoov will scale with your expected traffic.
How did you figure out it was that? Where you getting any fail events in Flash?
@Allen, I used my superior intellect. Okay, that's obviously a lie. :0
It was actually a client who knows a heap more about PHP and servers than I do. They were hosting the videos that wouldn't play. We knew that it wasn't the player because it did work for some of the videos. We knew that it wasn't the data because we checked it over and over. I thought it might have something to do with the videos themselves and that the metaData wasn't added correctly but even so, the videos should be able to play you just wouldn't be able to seek through them. So the server guys said, "It must be a memory issue." And the problem was solved.
I just tand into the same issue streaming HD movies that were around 300-500megs in size. The issue is the last line in xmoov:
print(fread($fh, filesize($file)));
change it to something like:
print(fread($fh, 8192));
I have no idea why they are trying to do a fread on the whole file, but that's where the memeory issue comes from. Make that change in xmoov and change your php memory_limit to 64 MB and it should work fine. You might be able to even use less memory than I did.
@Mike, thanks for the suggestion. I added it as an addendum to the post so that people are more likely to see it.
i had this problem and watching logs in my server i saw it was the memory and also the max execution time in php.
I also had problems when trying to seek to a new positions in the video because it takes too much time to move the playhead , do you guys have the same problem ?
or is it just my server ?
@paranoio, The seeking happens very fast. I've not noticed a lag on any of the servers that I've set this up on.
i also face the same issue as faced by paranoio. So for checking whats happening i used the complete="restart()" in the control. Where restart contains this lines:-
Alert.show("Restarted");
vidwin.play();
while playing the video the funtion restart was called several times. i expected it to get called as the complete video is finished playing.
Dont know whats wrong with the server. But this doesnot seems to work for me.
Please help.
Well i investigated some what more and found that i am not getting the content-length in the response header. don't know the reason but could this be an issue?
Any solutions?
@sanjeev, where are you looking for the content-length? The header? Is that the same as the meta-data? If so then some encoders don't add the meta-data correctly. Maybe you should try another encoder.
Well here is the catch, i have used matrix.flv, the same video u have in ur examples. and it worked in my server. but i dont know y it didnt work on clients machine.
Also on browser it seems to have problem. when i tried using
wget -S "http://www.<client server>.com/streamer.php?file=matrix.flv&position=0"
it downloaded it well also i am able to seee the content-length in the header
@sanjeev, what is the header. Is that what you call the metaData? Because that's the only place I know of to get the content length.
If it works on your server, and obvously on mine, then there is something strange going on with your client's server. I don't know much at all about servers so I probably won't be able to help. I'd just suggest that you check various settings/files on your client's server to make sure they are the same as your server.
Thanks a lot for this post! I changed the last line of my XMOOV script, as you described and it solved my problem playing large FLV's :)
I've looked around your site and you obviously know your stuff. I'm wondering if you have any ideas for another problem I'm having. When using XMOOV pseudo streaming I’m getting a problem where there is a discrepancy between the calculated position of the scrub icon (on the JW player) and the download display. The download display can either be ahead or behind the scrub icon depending on which part of the timeline is selected.
See the example here: w**.angling.tv/test/
Any help would be greatly appreciated.
Thanks.
@clegg, yeah, I see that it's off. In my experience it's usually just a simple mistake with the positioning of the elements. Are you sure that you are adding the distance from the left edge of the stage?
I think the positioning is ok. I've used various skins for the JW player, including the default one and the problem occurs with all of them.
Interestingly, someone in another forum tested my example using LightTPD and Nginx with the mod_flv_streaming modules. The problem still occurred then. I think there must be something not quite right with the JW player and pseudo streaming.
Any suggestions of an alternative FLV player? One that works well with the XMOOV script. I see XMOOV haven't released theirs yet.
Thanks
@clegg, can you make your own video player. There isn't all that much code involved. I have a few sample video players here on my blog. One of them even uses xmoov.
I think I would struggle to make my own player. My coding knowledge is around zilch. Customizing an existing skin is about my limit. Also, I don't have much time to invest.
I am willing to pay for a player that does a good job.
@clegg, Why don't you email me the feature list your looking for and I'll see what I can do. My email address is visible on the contact page.
Ok – thanks. I will have a think and get in touch.
Hey! remember me
i got through the issue, the server i was deploying my code was giving issue due to gzip compression on. I used .htaccess to switch it off for this module. Now i m getting "Content-Length" in the header and the streaming works fine.
Thanks a Lot for the samples u have provided.
@sanjeev, awesome. I'm glad you got it working. Isn't it sort of crazy that the .htaccess file could mess up something like getting the Content-Length? Sometimes I just hate computers. :)
Just wanted to say thank you for the post – and Mike's comment. Thanks to you guys I've fixed what was a rather puzzling problem.