mp4 streaming with jwplayer and download speed limit - php

hi everyone i have a problem with my streaming. at the moment i have made jwplayer to open a php file (ex. movie2.php) and this php file gives to the jwplayer the movie file pice by pice by sleeping 1 second to limit the speed (this php file also checks referer and session and doesnt show the video path but that but these are not important for the problem) . until here everything is perfect but the problem is : I can not seek the video to a not loaded part and it is obvious the reason why . so can anyone tell me how should i do this ? i need to change this php file somehow to make it support the streaming or can anyone give me a script that supports the streaming and limit the download speed at the same time ??

Check the "start=" value passed to your php code. I've used the JW Player before, and it definitely supports seek. Apparently, a seek is more like a restart, and passes that 'start' to your php file. From there, your file just starts the playing at that point.
There's a couple other comments on that thread about handling the client side of the object to avoid a couple pitfalls. It may be a bit dated, but should be relevant.

Related

WAMP Server Streaming video MP4 start took to much time

I am using WAMP server 2.4. I am streaming MP4 videos. Whenever i request video to stream it took around 3-4 mins to start streaming and once streaming is started it works fine.
I am unable to figure out why it takes to much time to start streaming.
I have tried following link as well but it didn't solve my issue.
Load mod_h264_streaming.dll in Windows Apache2
Please help
Are you using Flash or HTML5 or else to playback the video?
It sounds like the browser/client is trying to get the full length file before playing it back. It could be due to the fact that your MP4 file is not properly formatted for the web (MOOV ATOM is at the end of the file and playback cannot begin without it). You can read there for more info.
I would suggest two things:
try with a short 10 sec file and see if it plays rapidly
try a software like handbrake (or MP4Box or ffmpeg if you are more advanced on file transcoding) to transcode your MP4 with the "web optimized" (aka "fast start") check box active.
Let us know if it works.

Streaming in PHP

I'm searching the best way to do what I'm trying to do, so I ask here... I have a webpage in PHP who's requesting a song by TCP to another server. The song is loaded into a temporary file on the server. While it's loading, I want to play it into the webpage OR into the user's favorite player. Is it possible to simply refer the file to the player, even if it's not fully loaded ?
Thanks !
EDIT:
I found a great open-source player named JW Player, seems to be able to do what I want, but I'm not sure how ...
its a little hard to understand what your asking.
PHP Does not have threads which will limit you in multiple tasks, but it is possible to do so
the problem is that if your fetching the file in the same php file that loads the player as a webpage then your going to have issues.
you will have to resort to several php pages to complete the task
Firstly the suer requests to the server the song he wishes to play, you will have to use ajax to infrom the server of the id, so you would ping a script on your server saying LOAD VIDEO ID XXXX in which that script starts downloading the video, you would then active the player to call another file that would read segments of the partially downloaded file and output it to the player.
it will get very complex and possibly very error prone, your best bet is to stream directly from server2
Yes possible but you should indicate size of file truely

What's the logic i need to make this work? PHP Video manipulation with third party control functionality

I am a php newbie so i may be completely off here. But this is what i want to do.
Have a user upload a video to my site.
This then has a 30 second clip from our database added to it.
Which can be downloaded by the user for upload on any third party websites. Essentially the video is a flv or mpeg4, etc. But now with the 30 second clip added on.
These are the key point that make this difficult though.
I would want for certain links that are attached to the video file that is downloaded to be clickable from whereever it is uploaded to.
I would want for the 30 second slot to not be fast-forwardable. (Like on the youtube ads). <- I know they use FLASH for that./ But i would need my videos to be functional anywhere and youtube videos cant do that without attachment to youtube.
(This is something i intend to build myself. I just need your help in figuring out HOW to do it.)
All answers are GREATLY appreciated.
Thanks Alot!!
The challenges you bring up are not something you would ideally fix with PHP knowledge per se. PHP doesn't offer any video editing capabilities of its own, so you would effectively have to use PHP to run some other utilities.
The only PHP aspect here, really, is receiving an upload from the user, executing an external command on the uploaded file, and providing it as a download again. Those are the only parts of this process that I think you can realistically do with PHP alone, and they are quite easy. If you want to figure those out before you figure out the video editing aspect, then find information about making PHP receive a file from the user, how to make a PHP script downloadable instead of a page, and how to execute external commands.
That said, there are command-line utilities out there which you can use PHP to run on the file. I suggest you check out 'mencoder'. I've only used it a couple of times myself to do some video encoding conversions, but that's the first thing that comes to mind. It doesn't matter what you find... provided that it's a command-line utility, you can make PHP use it, even if you're running Windows as a server (imagine that!).
In short; I recommend trying to find command-line utilities that support video manipulation first, forgetting about PHP for a while, then figuring out how to use them, and only then figuring out how to make PHP do what you have to do.
The part with links in the video + no fastforward is not possible in my experience with php or anything else if this is only a video file.
If you go for a full embeded player or at least youtube, then it's possible.

Read file as its being uploaded

By default you cannot access a file that is uploaded until it has been fully transferred to the server.
What is the best way to get round this and be able to access the 'byte stream' as the file upload is in progress?
I think the closest you will get to this in PHP is looking at the various progress bar solutions that give you progress bars while doing file uploads to a PHP script. I don't know any of them in detail (I waited until SWFUpload became available to do this in Flash) but if you can get an upload's progress, it's likely you can get the data chunks themselves, too. (Update: the APC based solution can't. It seems to give the upload progress only.)
Check out this question, especially this answer and this one.
None of the approaches runs in pure vanilla PHP, they all need Perl or APC or other server-side stuff to work.
Final update: A cursory glance at the Raditha Mega Upload progress bar's Perl code makes me think this is your best bet, as it seems to be interacting with the actual file that is being uploaded. No guarantees, though.
You will need to have some kind of buffer where new data will be appended and where you read in chunks. Then check if there is new data and read that again.

Streaming video file?

I need to stream an flv file.
Streaming should look like live streaming,
and I there should be a way to change the target file.
Sorry for my poor English.
If by "streaming" you mean "showing a flash-video clip", flv-streaming isn't really streaming, but it's a normal file transfer, with the flash player starting playback even if the file isn't completely downloaded to the client. Time seeking is implemented in a standard HTTP way, with a file download offset - if you scroll the video halfway on the timeline and it hasn't downloaded yet, the current download is (most often) aborted, and restarted with an offset of filesize/2 bytes.
So, you could be fine with just using plain old readfile() and fixing the HTTP mime-type headers appropriately with header(). But, since you'd need seeking, you need to parse the HTTP request and instead of readfile(), use fpassthru(), seeking the right place, instead.
tl;dr: Avoid handling this on the PHP side, and let Apache (or the httpd of your choice) handle this instead.
I'm not quite sure what you're asking about, but if you have a bunch of media files and want to play them with a Youtube-esque media player on your website, I suggest checking out Flowplayer - It has an amazing Javascript API that lets you do all kinds of cool stuff to the player, including handling stuff like playlists and programmatically changing the current video.
I recently used it on a project with great results.

Categories