Plugin: shaffle video stream

Hi,

Following is a very simple shaffling video stream, the code is correct but the videostreamsink play the video in regular order and not shaffled, Is it because the sink put the frames back in order?

static GstFlowReturn gst_video_mixer_transform_ip(GstBaseTransform *trans, GstBuffer *buffer) {
GstVideoMixer *self = GST_VIDEO_MIXER(trans);
GstFlowReturn ret = GST_FLOW_OK;

// First, check if this frame should go into queue_a or queue_b
if (self->frame_skip_counter > 0) {
// Skip the frame in queue_b
gst_queue_push(self->queue_b, gst_buffer_ref(buffer));
self->frame_skip_counter–;
} else {
// Send the frame to queue_a
gst_queue_push(self->queue_a, gst_buffer_ref(buffer));
}

// Now, alternate between the two queues for output
GstBuffer *out_buffer_a = gst_queue_pop(self->queue_a);
GstBuffer *out_buffer_b = gst_queue_pop(self->queue_b);

if (out_buffer_a != NULL) {
// Push the frame from queue_a to the output
ret = gst_pad_push(GST_BASE_TRANSFORM_SRC_PAD(trans), out_buffer_a);
}

if (out_buffer_b != NULL) {
// Push the frame from queue_b to the output
ret = gst_pad_push(GST_BASE_TRANSFORM_SRC_PAD(trans), out_buffer_b);
}

// Free the popped buffers if they’ve been processed
if (out_buffer_a != NULL) {
gst_buffer_unref(out_buffer_a);
}
if (out_buffer_b != NULL) {
gst_buffer_unref(out_buffer_b);
}

return ret;
}

Note sure, though note that gst buffers have a Presentation Time Stamp (PTS) indicating when these should be displayed, so you may try to primarily swap these.

Thanks, indeed after swapping the PTS I managed to get the video played in a shaffle form.