如何使用 gstreamer 录制实时视频而不丢帧?
我正在尝试使用 Python 中的 gstreamer 0.10 同时显示 v4l2 视频源并将其记录到 xvid-in-avi。 在很长一段时间内,计算机的速度足以做到这一点,但如果另一个程序使用该磁盘,它就会丢帧。 这已经够糟糕了,但在播放时,视频中会出现突然的运动,其中帧被丢弃,而不是显示我们能够以较低帧速率编码的帧。
管道是v4l2src! 盖过滤器! 球座 ! 队列 ! xvidenc! 阿维穆克斯! filesink
并且 tee 也沉入 queue ! xvimagesinksync=false
。 我尝试在 xvidenc
前面添加 videorate
,但这似乎让事情变得更糟。
我考虑过将未压缩的视频假脱机到该管道中的磁盘,并在后台线程中对其进行编码。 我还能做什么来解决这个问题? xvidenc
或 avimux
是否在丢帧方面做了错误的事情? 我可以大幅增加编码器之前的队列大小吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果任何一个输出阻塞,tee 都会阻塞,所以这可能是你的瓶颈。 我建议将需要较长时间编码的流写入磁盘并从那里进行编码。
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.并且您需要编写xvimagesink,而不是xvimagesync
and you need to write xvimagesink, not xvimagesync