Appsrc buffer timestamping problems

LC lienes.cirules at gmail.com
Fri Apr 7 07:04:53 UTC 2017


Hello, 

I got problem with pipe like this: ("appsrc name=source ! video/x-raw,
width=1920, height=1080, framerate=50/1, format=BGR ! videorate !
videoconvert ! x264enc ! avdec_h264 ! videoconvert ! autovideosink"

I have essentially this code: 

  g_signal_connect(appsrc, "need-data", G_CALLBACK(cb_need_data), NULL);

static void cb_need_data(GstElement *appsrc, guint unused_size, gpointer
user_data)  {
 // ...
  cv::Mat frame;
  cap >> frame;
  height = frame.rows;
        width = frame.cols;
        auto data = (guchar *)frame.data;
        size = frame.elemSize() * width * height;

        buffer = gst_buffer_new();
        memory = gst_allocator_alloc(NULL, size, NULL);
        gst_buffer_insert_memory(buffer, -1, memory);
        gst_buffer_map(buffer, &map, GST_MAP_WRITE);

        memcpy((guchar *)map.data, data, gst_buffer_get_size(buffer));

       GstClock *pipe_clock = gst_element_get_clock (GST_ELEMENT
(pipeline));
                pipets_out = gst_clock_get_time (pipe_clock); // get current
pipe clock
                pipets_out -= gst_element_get_base_time (GST_ELEMENT
(pipeline)); // subtract pipe base time

      GST_BUFFER_PTS(buffer) = pipets_out;

     gst_buffer_unmap(buffer, &map);
     gst_buffer_unref(buffer);
}

If i add videoerate, it reports Got buffer with GST_CLOCK_TIME_NONE
timestamp, discarding it. If i take videorate out, i got first frame and
than it freezes. 

I also made test on this pipe : 
                                "appsrc name=source ! video/x-raw,
width=1920, height=1080, framerate=50/1, format=BGR !\
                                 videoconvert ! video/x-raw, format=UYVY,
width=1920, height=1080, framerate=50/1 !\
                                 identity name=appsrcid silent=false !
autovideosink")
And i got smooth playback. 

Note that i used pipe running time to timestamp buffers because i need good
synchronisation with alsasrc that will be added to stream. 

What is wrong with my way of timestamping new buffers ? How to make it
correct ? 

Thanks in advance! 




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Appsrc-buffer-timestamping-problems-tp4682567.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list