Skip to content Skip to sidebar Skip to footer

Looping Playback Of A List Of Gst.sample With Gstapp.appsrc

I'm trying to write a simple music player using GStreamer. I want to play any arbitrary music file ABS_FILE_PATH, store the samples for other purposes and later loop over these ind

Solution 1:

I've found a working solution with help of the comment of thiagoss.

The GstBuffer struct documentation lists all the fields relevant for the timestamp

struct GstBuffer {
  [...]/* timestamp */
  GstClockTime           pts;
  GstClockTime           dts;
  GstClockTime           duration;
  [...]
};

where the presentation timestamp pts is the relevant value. Setting it to Gst.CLOCK_TIME_NONE before using the sample for a second time will solve the issue:

# loop over all samplesdefsamples(app_sink):
    samples = []
    sample = app_sink.pull_sample()
    while sample:
        yield sample
        sample.get_buffer().pts = Gst.CLOCK_TIME_NONE #unset the pts
        samples.append(sample)
        sample = app_sink.pull_sample()
    print('looping')
    for sample in itertools.cycle(samples):
        yield sample

Post a Comment for "Looping Playback Of A List Of Gst.sample With Gstapp.appsrc"