views:

2591

answers:

7

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: a) the browser get crashy b) it never stops buffering , keeps downloading until it gets entire video (300M) c) CPU usage goes up so as browser memory consumption

I guess a) and c) are caused b) since the player needs more and more memory to store video.

So 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?

Thank you

A: 

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.

Christian Nunciato
A: 

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)

Aaron H.
+1  A: 

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 [email protected].


Sorry I typed it totally wrong. What I meant is mod_h264_streaming http://h264.code-shop.com/trac.
A: 

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.

A: 

Hi Rogovskiy,

That sounds like a really good approach. Is there any glitch when you switch between the two video displays or did you manage to get it seamless?

Regards

Arjen
There is a little glitch in audio - video plays seamlessly. For right now I am going to ignore it with buffer size about 3-5 minutes users shouldn't mind it more than Hulu commercial interruptions. ;)
A: 

Hi Rogovskiy,

Thanks for the answer. Do you have a link to your demo of the dual buffering setup? Being the author of the mod_h264_streaming module, I'm always looking for cutting down on the video seek times and this looks very promising.

If I can help out in any way, let me know, I'd be happy to help.

Regards,

Arjen

Arjen
A: 

Hi: I am having same issue with progressive download. VideoDisplay downloads complete file before it starts playing. Someone mentioned, I quote, "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). " How do i have headers in the beginning of FLV file. Size of my flv I am trying to play is 30mb

Thanks

Rajeev