通过构建不同的gstreamer管道,可以有多种方法来抓取视频文件中的缩略图,以下作一简单介绍。
1、从gdkpixbufsink中获取图像 该方法通过gdkpixbufsink的"last-pixbuf"来获取图像的pixbuf。
descr = g_strdup_printf ("uridecodebin uri=%s ! ffmpegcolorspace ! videoscale ! gdkpixbufsink name=sink", fileurl);
pipeline = gst_parse_launch (descr, &error);
if (error != NULL) {
printf ("could not construct pipeline: %s", error->message);
g_error_free (error);
return FALSE;
}
sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
switch (ret) {
case GST_STATE_CHANGE_FAILURE:
printf ("failed to play the file/n");
return FALSE;
case GST_STATE_CHANGE_NO_PREROLL:
printf ("live sources not supported yet/n");
ret