My setup is a series of gstreamer pipelines that plug and play (hopefully) with one another via Qt slots and signals, with the signals being emitted by appsinks and then being picked up again by apprcs. So it can look something like this:
filesrc -> appsink ====> appsrc -> compositor -> appsink ====> appsrc -> webmmux -> filesink
^
|
webrtcbin -> appsink ====> appsrc
(Obviously there's more to my pipelines than the above, this is just to give an idea of the kind of thing I'm doing)
The trouble is that I sometimes a listener needs to be started up before any sources join. It all works fine, apart from my recording. The complete recorder pipeline is:
appsrc -> videoconvert -> capsfilter -> videorate -> vp8enc -> webmmux -> filesink
^
|
appsrc -> audioconvert -> audiorate -> vorbisenc
The resulting recording starts blank, as if the recording started at the same time as the first component started. If the blank period is long, and the time of the actual recording that I want is short, then when I shut the pipeline down the recording won't actually have got to the interesting bit yet because it's not finished writing the nothingness to disk yet and I just have a long recording of blackness.
I can remove this blank period by adding gst_pad_set_offset(src_pad, offset_time); on to the src pads of the vorbis and vp8 encoders. (offset_time is the difference between the base time of the first component and the time when the recording should start) However, then when the recorder starts up the file is created immediately, but it remains empty for aaaages, while the webmmux buffers everything up, leading to huge memory usage, potentially crashing everything. I think this is because, as said on the gstreamer docs, "Buffers are played when their running-time is equal to the clock-time - base-time." so it's holding on to the buffers until the offset is cancelled out.
I've tried various different values for the recorder pipeline base_time, but it doesn't seem to make any difference. Also tried various permutations of settings on the appsrcs and webmmux (and everything in between) with no effect.