AnsweredAssumed Answered

Raw to jpeg image conversion using gstreamer in C

Question asked by nikit biraj on Aug 26, 2013
Latest reply on Aug 28, 2013 by Leonardo Sandoval Gonzalez

Hi,

I am working on encoding a raw file image to jpeg image in C

Below is working structure in comand line to encode image :

 

gst-launch filesrc location=/home/root/one.raw blocksize=608256 ! \

'video/x-raw-yuv, format=(fourcc)I420,width=(int)704,height=(int)576,framerate=(fraction)0/1'

! ffmpegcolorspace ! 'video/x-raw-yuv,format=(fourcc)I420,width=(int)704,height=(int)576,,framerate=(fraction)0/1' ! vpuenc codec = 12 ! \

filesink location=/home/root/image.jpg

 

Below are pipeline structure :

app->src = gst_element_factory_make("filesrc", "mysrc");

app->encoder = gst_element_factory_make("vpuenc", "enc");

app->video_convert  = gst_element_factory_make ("ffmpegcolorspace",  "converter");

app->imagesink = gst_element_factory_make("filesink", "myvsink");

 

have created all elements, objects.

g_object_set (app->src, "blocksize", BUFF_SIZE, NULL);

where BUFF_SIZE is 608256

g_object_set (app->encoder, "codec", 12, NULL);

 

gst_bin_add_many(GST_BIN(app->pipeline), (GstElement*)app->src,app->video_convert,app->encoder,

                         app->imagesink, NULL);

 

filesrc location using : g_object_set(G_OBJECT(app->src),

                                "location", "/home/root/one.raw",NULL);

and,

filesink location using  : g_object_set(G_OBJECT(app->imagesink),

                                   "location", "/home/root/tr2.jpg",NULL);

 

I am getting link failed when I try to link app->src and app->video_convert, and

app->video_convert and app->encoder

Below is C code for linking :

link_ok = gst_element_link_filtered (app->src, app->video_convert,

                                                    gst_caps_new_simple ("video/x-raw-yuv",

                                                        "format", G_TYPE_STRING, "I420",

                                                        "width",G_TYPE_INT, 704,

                                                        "height",G_TYPE_INT, 576,

                                                        //"framerate",GST_TYPE_FRACTION, 0,1,

                                                        NULL));

and

link_ok = gst_element_link_filtered (app->video_convert, app->encoder,

                                                          gst_caps_new_simple ("video/x-raw-yuv",

                                                              "format", G_TYPE_STRING, "I420",

                                                              "width",G_TYPE_INT, 704,

                                                              "height",G_TYPE_INT, 576,

                                                              "framerate",GST_TYPE_FRACTION, 1,1,

                                                          //  "pixel-aspect-ratio",GST_TYPE_FRACTION,1,1,

                                                              NULL));

Surprisingly the same caps works in command line but if I link through C its giving error.

What am I doing wrong?

Please do help.

Outcomes