0
在此先感谢。如何从appsink缓冲区中获取正确的视频帧数或时间位置
我想从rtsp摄像机录制视频,同时 处理通过新样本信号从appsink获得的视频帧。 然后,在一个单独的应用程序中,我读取录制的视频并显示与处理帧有关的信息。
文档说buffer-> offset有视频帧号,但不适用于我,它总是有相同的号码。
我有这样的管道:
rtspsrc location=rtsp://10.0.0.1:554/video.sdp latency=100 ! rtph264depay ! tee name=t
! queue ! vaapidecodebin ! vaapipostproc format=rgba ! appsink name=appsink t.
! queue ! h264parse ! mp4mux ! filesink sync=false name=filer location=/home/VideoDB/2017-09-04_16:33:46.mp4
代码示例:
GstFlowReturn GstVideoSourcePrivate::newSample(GstAppSink* sink, gpointer user_data)
{
....
GstSample* sinkSample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
if (sinkSample) {
GstBuffer* buffer = gst_sample_get_buffer(sinkSample);
// I need this position to be the same as the recorded video
// or get the frame video sequence number, so that we
GstClockTime pos;
gst_element_query_position(self->pipeline(), GST_FORMAT_TIME, &pos);
...
}
...
}
你好,你有没有试着用'GST_BUFFER_PTS(缓冲)'为了得到缓冲时间戳?你也可以将'rtspsrc'元素的'use-pipeline-clock'设置为'true'吗? – Ahresse