[英]gstreamermm: How can I extract the last video frame of a Gst::PlayBin
我尝试使用gstreamermm 1.0提取视频的最后一帧,并使用示例https://github.com/GNOME/gstreamermm/blob/master/examples/media_player_gtkmm/player_window.cc进行了处理 ,但是我只得到了白色像素。
如何提取流的最后一个视频帧作为原始rgba或bgra数据?
void
MediaStream::setup ()
{
player = Gst::PlayBin::create ("player");
vsink = Gst::XImageSink::create ("vsink");
player -> set_property ("video-sink", vsink);
player -> signal_video_changed () .connect (sigc::mem_fun (*this, &MediaStream::on_video_changed));
}
void
MediaStream::on_video_changed ()
{
Glib::RefPtr <Gst::Pad> pad = player -> get_video_pad (0);
if (pad)
pad -> add_probe (Gst::PAD_PROBE_TYPE_BUFFER, sigc::mem_fun (*this, &MediaStream::on_video_pad_got_buffer));
}
Gst::PadProbeReturn
MediaStream::on_video_pad_got_buffer (const Glib::RefPtr <Gst::Pad> & pad, const Gst::PadProbeInfo & data)
{
const auto width = vsink -> get_width ();
const auto height = vsink -> get_height ();
std::vector <uint8_t> image (width * height * 4);
// Got no data
data .get_buffer () -> extract (0, image .data (), image .size ());
return Gst::PAD_PROBE_OK;
}
缺少的C ++的C版本工作正常:
const auto sample = gst_base_sink_get_last_sample (vsink -> Gst::BaseSink::gobj ());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.