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