<div dir="ltr">I am using GStreamer 1.6.3, Centos 4.7.5<div><div><br></div><div>It may be a local problem as the test program you provided gave me the same error message:</div><div><div>Failed converting frame.</div><div>Error : Cannot find any image encoder for caps image/bmp</div></div><div><br></div><div>I was able to build my own pipeline and save an image, essentially using the same code as gst_video_convert_sample</div><div>and the other routines below that. In build_convert_frame_pipeline, for the get_encoder part, I used </div><div><br></div><div>GstElementFactory *bitmap_factory = gst_element_factory_find("avenc_bmp");</div><div>GstElement *encoder = gst_element_factory_create(bitmap_factory, "bitmap_elem");</div><div><br></div><div>Then I used encoder as it already appeared in build_convert_frame_pipeline.</div></div><div><br></div><div>I am going to test with some newer versions of GStreamer, but I had hoped to keep 1.6.3 as it has proven to be</div><div>very stable for my applications.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 29, 2017 at 5:37 AM, Antonio Ospite <span dir="ltr"><<a href="mailto:ao2@ao2.it" target="_blank">ao2@ao2.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, 27 Dec 2017 11:06:58 -0700 (MST)<br>
jackson80 <<a href="mailto:jackstuff3@gmail.com">jackstuff3@gmail.com</a>> wrote:<br>
<br>
> Looking at gst_video_convert_sample: It first validates inputs and extracts<br>
> caps from src; then it calls build_convert_frame_pipepline. This routine<br>
> creates elements needed for a conversion pipeline. Then this routine calls<br>
> get_encoder. This immediately calls gst_element_factory_list_get_<wbr>elements.<br>
> From the debug output supplied by gst_plugin_feature_list_debug, I can see<br>
> the only encoders found were jpegenc, pngenc, and pnmenc. Since none of<br>
> these encoders match bmp, this is where it fails.<br>
> Is there any other way to see if libav is correctly incorporated with the<br>
> rest of the gstreamer software?<br>
> Or do you think I should try manually building a conversion pipeline?<br>
><br>
<br>
</span>A simplified version of your test program works here (Debian unstable,<br>
GStreamer 1.12.4) and can save bmp files using<br>
gst_video_convert_sample(), so you might be experiencing a local<br>
problem.<br>
<br>
IIRC we didn't ask the usual questions: what GStreamer version? What<br>
system?<br>
<br>
I am pasting the test program below:<br>
<br>
/*<br>
* Compile with:<br>
* gcc -ggdb test.c $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-video-1.0 gtk+-3.0)<br>
*/<br>
<span class=""><br>
#include <gtk/gtk.h><br>
#include <gst/gst.h><br>
#include <gst/video/video.h><br>
<br>
</span><span class="">/* Structure to contain all our information, so we can pass it around */<br>
typedef struct CustomData {<br>
</span> GstElement *pipeline;<br>
GstElement *source;<br>
GstElement *sink;<br>
<span class=""> GstElement *convert;<br>
GstElement *caps;<br>
<br>
GstState state;<br>
GstStateChangeReturn ret;<br>
} CustomData;<br>
<br>
void save_images_cb(GtkWidget *widget, CustomData *data) {<br>
<br>
int i;<br>
GstCaps *caps;<br>
GstSample *from_sample, *to_sample;<br>
GError *err = NULL;<br>
GstBuffer *buf;<br>
GstMapInfo map_info;<br>
char pic_location[50], command_string[256];<br>
<br>
g_object_get(data->sink, "last-sample", &from_sample, NULL);<br>
if (from_sample == NULL) {<br>
printf("Failed getting sample.\n");<br>
return;<br>
}<br>
</span> caps = gst_caps_from_string ("image/bmp");<br>
<span class=""><br>
if (caps == NULL) {<br>
printf("Failed getting caps.\n");<br>
return;<br>
}<br>
<br>
</span><span class=""> to_sample = gst_video_convert_sample (from_sample, caps,<br>
GST_CLOCK_TIME_NONE, &err);<br>
gst_caps_unref (caps);<br>
gst_sample_unref (from_sample);<br>
<br>
if (to_sample == NULL && err) {<br>
printf("Failed converting frame.\n");<br>
printf("Error : %s\n", err->message);<br>
return;<br>
}<br>
</span> sprintf(pic_location,"/tmp/<wbr>sample_a.bmp");<br>
<span class=""> buf = gst_sample_get_buffer(to_<wbr>sample);<br>
if (gst_buffer_map (buf,&map_info, GST_MAP_READ)) {<br>
if (!g_file_set_contents(pic_<wbr>location, (const char *) map_info.data,<br>
map_info.size, &err)){<br>
printf("Could not save image %i.\n", i);<br>
}<br>
}<br>
</span><span class=""> gst_sample_unref (to_sample);<br>
}<br>
<br>
<br>
int main(int argc, char *argv[]) {<br>
CustomData data;<br>
GstStateChangeReturn ret;<br>
GtkButton *temp_button;<br>
GtkWidget *vid_window, *main_window, *big_window, *button_window,<br>
*pic_button;<br>
int mkdir_status, wd;<br>
</span> GstCaps *caps;<br>
<span class=""> int i;<br>
<br>
/* Initialize GTK */<br>
gtk_init (&argc, &argv);<br>
<br>
/* Initialize GStreamer */<br>
gst_init (&argc, &argv);<br>
<br>
main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);<br>
gtk_container_set_border_<wbr>width(GTK_CONTAINER(main_<wbr>window),0);<br>
g_signal_connect (G_OBJECT (main_window), "delete-event", G_CALLBACK<br>
(gtk_main_quit), NULL);<br>
gtk_window_set_default_size (GTK_WINDOW (main_window), 900, 600);<br>
gtk_window_set_title(GTK_<wbr>WINDOW(main_window), "Test Program");<br>
big_window = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);<br>
pic_button = gtk_button_new_with_label("<wbr>Save Image");<br>
g_signal_connect(G_OBJECT(pic_<wbr>button), "clicked",<br>
G_CALLBACK(save_images_cb), (gpointer)&data);<br>
button_window = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);<br>
gtk_box_pack_start (GTK_BOX(button_window), pic_button, FALSE, FALSE, 0);<br>
<br>
</span> data.pipeline = gst_pipeline_new("video-<wbr>pipeline");<br>
data.source = gst_element_factory_make ("videotestsrc", "play1");<br>
<span class=""> data.sink = gst_element_factory_make ("gtksink", "sink1");<br>
/* gst_base_sink_set_last_sample_<wbr>enabled(GST_BASE_SINK(data.<wbr>sink),TRUE);*/<br>
data.convert = gst_element_factory_make ("videoconvert", "convert1");<br>
data.caps = gst_element_factory_make ("capsfilter", "caps1");<br>
<br>
</span> caps = gst_caps_from_string("video/x-<wbr>raw,width=800,height=480,<wbr>framerate=25/1");<br>
g_object_set(G_OBJECT(data.<wbr>caps), "caps", caps, NULL);<br>
gst_caps_unref(caps);<br>
<br>
if ((!data.pipeline) || (!data.source) || (!data.sink) || (!data.caps) ||<br>
<span class=""> (!data.convert)){<br>
g_printerr ("Not all elements could be created.\n");<br>
return 0;<br>
}<br>
<br>
</span> gst_bin_add_many (GST_BIN (data.pipeline), data.source, data.caps, data.convert, data.sink, NULL);<br>
<br>
gst_element_link_many(data.<wbr>source, data.caps, data.convert, data.sink, NULL);<br>
<span class=""><br>
g_object_get (data.sink, "widget", &vid_window, NULL);<br>
</span><span class=""> gtk_box_pack_start (GTK_BOX(big_window), vid_window, FALSE, FALSE, 0);<br>
gtk_box_pack_start (GTK_BOX(big_window), button_window, FALSE, FALSE, 0);<br>
gtk_container_add (GTK_CONTAINER (main_window), big_window);<br>
gtk_widget_show_all(main_<wbr>window);<br>
<br>
</span> ret = gst_element_set_state(data.<wbr>pipeline, GST_STATE_READY);<br>
<span class=""> if (ret == GST_STATE_CHANGE_FAILURE) {<br>
printf("Could not set pipe to ready.\n");<br>
} else {<br>
</span> gst_element_set_state(data.<wbr>pipeline, GST_STATE_PLAYING);<br>
gtk_main ();<br>
gst_element_set_state(data.<wbr>pipeline, GST_STATE_NULL);<br>
gst_object_unref(data.<wbr>pipeline);<br>
gst_object_unref(data.source);<br>
gst_object_unref(data.caps);<br>
gst_object_unref(data.convert)<wbr>;<br>
gst_object_unref(data.sink);<br>
}<br>
return 0;<br>
<div class="HOEnZb"><div class="h5">}<br>
<br>
--<br>
Antonio Ospite<br>
<a href="https://ao2.it" rel="noreferrer" target="_blank">https://ao2.it</a><br>
<a href="https://twitter.com/ao2it" rel="noreferrer" target="_blank">https://twitter.com/ao2it</a><br>
<br>
A: Because it messes up the order in which people normally read text.<br>
See <a href="http://en.wikipedia.org/wiki/Posting_style" rel="noreferrer" target="_blank">http://en.wikipedia.org/wiki/<wbr>Posting_style</a><br>
Q: Why is top-posting such a bad thing?<br>
</div></div></blockquote></div><br></div>