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

Re: mpeg encoder



>My strategy is to dump raw frames to one big file while recording then
>process them out into individual pictures when done.

Is this significantly faster than writing one PGM file for each frame?

>I have the camera recording at a constant rate using the following algorithm:
[...]

I think it'd be neat to try this asynchronously. I don't think it's
that different than your usleep() approach, except it lets the kernel
keep track the time for you.

Have the user set a frame rate they want for the screen, and a frame
rate for recording to disk. Set up a timer to signal the process when
it's time to take a new snapshot, either for disk or screen. When it's
time to update the screen, catch the signal and do the camera protocol.
For disk just take whatever's in the frame buffer and dump it to disk.

If you're willing to live with the restriction that the frame rate for
disk recording has to evenly divide the frame rate for screen, then
you only need one timer, and just remember that every Nth screen update
you should write to disk. I think that's reasonable - I want 10fps on
my screen, 1fps to disk.

I've never written code like this, btw, but it'd be fun to try.

>The problem is with the disk access- it's killing me- it appears the
>system is not multitasking the disk io, instead it buffers up over
>several frames, then it writes to disk and a couple frames are lost.

You're not using stdio, right, this is kernel buffering? It's possible
that closing the file (ie: writing multiple files) might improve
things, not sure. I don't understand how the Linux kernel
buffers disk writes.

In general, though, this is going to be a problem. I think serious
video apps record everything in RAM, or have special disk controllers
that stream things better.

References: