How can I record live video with gstreamer without dropping frames?
Question
I'm trying to use gstreamer 0.10 from Python to simultaneously display a v4l2 video source and record it to xvid-in-avi. Over a long period of time the computer would be fast enough to do this but if another program uses the disk it drops frames. That's bad enough, but on playback there are bursts of movement in the video where frames were dropped instead of displaying the frames we were able to encode at a lower framerate.
The pipeline is v4l2src ! capsfilter ! tee ! queue ! xvidenc ! avimux ! filesink
and the tee also sinks to a queue ! xvimagesink sync=false
. I've tried adding videorate
in front of xvidenc
but that seems to make things worse.
I've considered spooling the uncompressed video to disk in this pipeline and encoding it in a background thread. What else could I do to solve this problem? Is xvidenc
or avimux
doing the wrong thing with dropped frames? Could I dramatically increase the size of the queue preceding my encoder?
Solution
tee
will block if either output blocks, so it's probably your bottleneck. I suggest to write the stream that takes longer to encode to disk and encode from there.
OTHER TIPS
and you need to write xvimagesink, not xvimagesync