如何在 gstreamer 中暂停视频录制
我创建了一个管道,如下所示:
v4l2src -> tee -> queue -> encoder -> avimux -> filesink
tee -> queue -> v4l2sink
现在我想暂停录制(保持环回,但暂停编码器),当我恢复时,我希望重新编码文件从我恢复的位置继续。 我尝试使用 gst_element_set_state: 如果我暂停管道,环回就会停止。 如果我暂停编码器,gst_element_set_state的返回值是可以的,但编码器并没有真正暂停。 我暂停了avimux,编码器也一样。 有人可以帮忙吗?非常感谢。
I created a pipeline as this:
v4l2src -> tee -> queue -> encoder -> avimux -> filesink
tee -> queue -> v4l2sink
Now I want to pause the recording(keep loopback, but pause encoder), and when I resume, I expect the recoding file continues from where I resume.
I tried to use gst_element_set_state:
If I pause the pipeline, the loopback stops.
If I pause the encoder, the return value of gst_element_set_state is ok, but the encoder not really pauses.
I paused the avimux, same with encoder.
Can anyone help? Thank a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请查看 gst-plugins-bad 中的camerabin/camerabin2。不幸的是,你想做的事情有点复杂。我会解释一下。对于初学者,您需要将 src-pad 放入队列中,将其设置为leaky=downstream 并阻止 src-pad。这会暂停视频。您也可以在队列后使用阀元件以获得相同的效果。如果你幸运的话一切都很好(avimux 应该是这种情况)。对于其他格式(mp4mux),您需要记住暂停时最后一个缓冲区的时间戳(通过 pad-data-probe),并且当您在取消暂停后获得第一个新缓冲区时,从时间戳中减去暂停时间。否则,生成的视频将会暂停。这是因为 mp4 容器中的视频流可能很稀疏。这也会影响其他格式。理论上,您也应该能够通过在取消暂停后(在第一个缓冲区之前)向下游发送新段事件来处理此问题,但我还没有尝试过。再次检查它是如何完成的,特别是在camerabin2中。还可以考虑使用camerabin2:)
Please take a look at camerabin / camerabin2 in gst-plugins-bad. What you want to do is unfortunately a bit complicated. I'll explain. For starters you will need to get the src-pad on the queue, set it to be leaky=downstream and block the src-pad. This pauses the video. You can also use the valve element after the queue for the same effect. If you are lucky everything is fine (should be the case for avimux). For other formats (mp4mux) you will need to remember the the time-stamp of the last buffer when pausing (via pad-data-probe) and when you get the first new buffer after unpausing, subtract the pausing time from the timestamps. Otherwise you will have a pause in the resulting video. This is due to the fact that video streams in mp4 containers can be sparse. This also affects other formats. In theory you should also be able to handle this, by sending a new-segment event downstream after unpausing (before the first buffer), but I have not tried that. Again check how it is done especially in camerabin2. Also consider just using camerabin2 :)