Question

I am trying to build a video player application using Adobe Flex and libh264streaming. In small cased my little player works just fine.

However if the video is bigger about 200-300MB I am seeing bunch of issues:

  1. The browser get crashes.
  2. It never stops buffering, keeps downloading until it gets entire video (300M).
  3. CPU usage goes up so as browser memory consumption.

I guess 1. and 1. are caused 2. since the player needs more and more memory to store video.

I would like to have a cap on buffer size somehow and stop downloading video as soon as it reaches the cap. I think YouTube video player works just like that (looking at the player control in the bottom of the player).

Any ideas how to implement it in Flex?

Was it helpful?

Solution

What exactly is "libh264streaming" ? Searches for it on Google turn up only this thread with that exact text. From you description it sounds like it's not streaming the video at all but just providing for progressive download.

Progressive download is sometimes incorrectly referred to as streaming. It simply is a normal HTTP download of a file and as long as the video headers are at the beginning of the file, Flash will start playing the file as soon as it has the headers plus a certain minimum amount of video data (4 keyframes I believe). Progressive download traditionally does not provide bandwidth throttling or other advantages of streaming but recently some have provided implementations that download slowly which is closer to streaming and can start progressive download in the middle of the file (dynamically rewriting headers) to allow people to jump to the middle without downloading the entire thing.

The Flash Player only supports RTMP for streaming. This is a proprietary protocol supported by Flash Media Server and several open source options like Red5, rubyizumi. Adobe just two days ago announced that it will be publishing and provide open licensing for RTMP, so you should see more products with RTMP support in the near future. Streaming provides a two-way communication with client and server so server sends a requested number of frames as buffer, and client requests frames to fill buffer as needed. Server doesn't send more than is requested and server can seek to various points with only the buffer needing refreshed, not the entire video.

If you want to provide large files, you probably need a true streaming server. One alternative would be to break up the files into chunks, download them as needed and play them one after another. That would be complicated too, but doable.

HTH,

Sam


We're hiring! Developers and QA in Washington, DC area (or looking to relocate) should send resumes to careers@blinemedical.com.


OTHER TIPS

I was able to create a component on the base of 2 VideoDisplay objects that loads mp4 files in chunks (say with 1 minute buffer each). Secondary VideoDisplay starts loading video as soon as primary display reaches certain point (50% of the buffer size in my case). The component flips to secondary display as soon as primary video finishes.

That approach works pretty well using mod_h264_streaming. Seek operations work almost instantly.

I'm guessing part of the reason no one's answered this one yet is because there's no great answer for it. I'm certainly no expert in the arcana of Flash streaming, but in the interest of posting at least something in response for you, I'm guessing, from reading the docs and actually trying a few things myself, that what you're trying to do can't really be done with a VideoDisplay object and wholly within the Flex environment; it's probably something that needs to be handled on the server, or at least between the server and the client, such that the stream gets properly delivered and terminated, and the VideoDisplay object just operates normally.

Sorry, I wish I had a better answer for ya; if anyone else out there does, feel free to chime in.

It's hard to tell for certain, but it looks like the lib you mention provides some control mechanism to tell the server which chunk you wish to play (I'm getting this from the statement on their web page: ..."You have really long video clips and you don't want to re-encode them into smaller parts? We also support 'virtual video clips', so you can specify to only playback a part of the video or create download links to specific parts of the video."

To me, it seems you just need to add a control structure that allows you (tell the server) to get the video in chunks.

If that isn't possible for whatever reason, and you just have access to a raw stream of data:

I would need to know what interfaces you are using in flex to load the video, but in general, you would add a listener that receives ProgressEvent and check the bytes loaded (For a generic loader object)

Your other option would be to create your own socket with read and write methods, which you can use to check your byte counters as data comes in. You would put bytes read into a bytearray, and then when you have a usable chunk, you would need to convert that byte array into a suitable format for the player object...

Look at flash.net.Socket

(http://livedocs.adobe.com/flex/2/langref/flash/net/Socket.html)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top