[Prev][Next][Index][Thread]

Re: mpeg encoder



Russ Nelson writes:
>Hmmm...  I'm hoping that the MPEG encoder can deal with frames that
>don't arrive at a constant rate!  If it needs a constant rate, then we
>need the QCam driver to throttle back the frame rate until it can
>predict that it will really be able to generate the frame rate that
>it's asked to, even in view of changing system load.

MPEG encoders are really, really slow. I believe software encoders are
too slow for realtime video. I don't remember exactly, but on a
Decstation 3100 the encoding was something like 20 seconds a
frame. Even given two orders of magnitude improvement, that's still
only 5fps. If you have MPEG hardware the story is entirely different,
but if you can afford that you aren't going to mess around with a $100
camera.

One fun thing about MPEG is that it encodes based on *future* frames,
as well as previous ones. There are three MPEG frame types: I, B, and P.
I is Independent: it's just an encoded image, doesn't depend on other
frames (a sync point). P depends on the Previous frame: something like
a set of deltas from the previous frame, only more complicated. B is
Bi-Directional, and depends both on the previous frame and the next.
One possible frame type pattern for an MPEG is IBBPBB. The 0th frame (and
the 7th, and the 14th, and..) is independent. Frame 1 depends on 0 and
2, 2 depends on 1 and 3, 3 depends on 2 (but not 4, thank god), etc.

All this goes to say that if you're encoding with IBBPBB, you need to
pretty much have six frames in memory before you write anything out.
MPEGs often go to needing 15 frames in memory. B frames are really
cool, and are the main magic in MPEG's tightness, but encoding is not cheap.

I think FLI or AVI might be reasonable alternatives if you want to
stream compressed video. I've never seen an encoder for them, but I
could imagine getting 30fps on a fast Pentium if you're writing to RAM
(don't know about disk). Quicktime also is a nice format in terms of
quality/space tradeoff. I don't know anything at all about quicktime
encoders.

Yahoo has a lot of MPEG info on
http://www.yahoo.com/Computers_and_Internet/Multimedia/Video/MPEG/Technical_Information/

References: