How to do Flash pseudo-streaming?
Asked Answered
A

3

7

I need to build something that starts serving a H.264 encoded video to a flash player halfway through the file (to support skipping to a point in the video that has not been buffered yet).

Currently, the videos are in the FLV container format, but transcoding is an option. I managed to re-write the file header and metadata information for a given byte offset. This works for older videos, but not for H.264 encoded files. I suspect this is because the video tags inside the file also have to be altered, which is not feasible (it would take too much processing power).

What is the "proper" way to do it?

Apophasis answered 15/9, 2008 at 9:55 Comment(1)
Interesting question...I'm going to be doing this myself in the coming weeks too. Could you elaborate on the problems you are having with the FLV approach? I would have thought it would work OK...Spina
E
2

The flash player can only start playing H.264 video once it's downloaded the MOOV atom. Existing pseudo-streaming providers just give you an FLV header - either the first 13 bytes of the file or a hardcoded one - and then serve the file from the given offset. If you want to make an H.264 pseudo-streamer, you'll need to have it output the FLV header, then a MOOV atom, and then serve the rest of the file from the given offset. If you don't use an FLV container, you won't need the FLV header, but you'll still need the MOOV atom.

Unfortunatley, I don't think you'll be able to use the MOOV atom from the file on disk; the information it contains won't be right for the file fragment that you serve. So you'd have to parse the existing atom and generate one of your own which was appropriate to the served part of the file.

If there are complicated structures within the H.264 file it could be even more complicated to pseudo-stream. If parsing the file isn't feasible, I'm afraid you may not be able to pseudo-stream your media.

Euchromatin answered 19/9, 2008 at 12:30 Comment(0)
S
3

@yoavf - I think the OP is interested in server-side aspects of streaming on-demand h.264 inside of FLV files. Reuse of existing players would be nice for him, I think. Or maybe that is my own needs coming out? <:S

From yoavf's second link, there is another link to Tinic Uro's What just happened to video on the web? . A relevant quote:

Will it be possible to place H.264 streams into the traditional FLV file structure? It will, but we strongly encourage everyone to embrace the new standard file format. There are functional limits with the FLV structure when streaming H.264 which we could not overcome without a redesign of the file format. This is one reason we are moving away from the traditional FLV file structure. Specifically dealing with sequence headers and enders is tricky with FLV streams.

So, it seems one can either tinker with ffmpeg encoding (if that is how you are getting your FLVs, like I am) or one can get into the new format. Hmmmm....

Spina answered 15/9, 2008 at 11:10 Comment(4)
Like I said, transcoding / remuxing is an option. But I can't just chop up a file and expect it to work, afaik. I'd like to know what the best approach is.Apophasis
I chop up non-264 FLVs just fine! :) Prepad the FLV header and it works perfectly.Spina
Yes, non-264 I got working - it's easy. but no luck with 264. And you're right - I'm talking server side (and we're already using JW ;) )Apophasis
if you figure it out, please let me know :D I'm gonna being doing this soon enough...Spina
E
2

The flash player can only start playing H.264 video once it's downloaded the MOOV atom. Existing pseudo-streaming providers just give you an FLV header - either the first 13 bytes of the file or a hardcoded one - and then serve the file from the given offset. If you want to make an H.264 pseudo-streamer, you'll need to have it output the FLV header, then a MOOV atom, and then serve the rest of the file from the given offset. If you don't use an FLV container, you won't need the FLV header, but you'll still need the MOOV atom.

Unfortunatley, I don't think you'll be able to use the MOOV atom from the file on disk; the information it contains won't be right for the file fragment that you serve. So you'd have to parse the existing atom and generate one of your own which was appropriate to the served part of the file.

If there are complicated structures within the H.264 file it could be even more complicated to pseudo-stream. If parsing the file isn't feasible, I'm afraid you may not be able to pseudo-stream your media.

Euchromatin answered 19/9, 2008 at 12:30 Comment(0)
E
0

two things you can do:

1) use lighttpd and it's mp4 streaming plug-in that'll generate the required streaming container on the fly

2) create a keyframed FLV and use a psuedo-streaming script (like XMOOV) to stream your file.

if you need mp4/aac you can just put them inside the FLV container, much to adobe's chagrin, but it works.

Eldest answered 15/12, 2008 at 16:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.