Reputation: 41
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.
Upvotes: 4
Views: 3116
Reputation: 3440
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 :)
Upvotes: 4